Switch to monotonic System.nanoTime()
This commit is contained in:
parent
1d744181ec
commit
5d2613873c
|
@ -170,11 +170,11 @@ public class Promise<T> implements Future<T> {
|
|||
if (delay == -1) {
|
||||
while (this.isPending()) this.wait();
|
||||
} else {
|
||||
long targetTime = System.currentTimeMillis() + unit.toMillis(delay);
|
||||
long targetTime = System.nanoTime() + unit.toNanos(delay);
|
||||
while (this.isPending()) {
|
||||
long now = System.currentTimeMillis();
|
||||
long now = System.nanoTime();
|
||||
if (now >= targetTime) throw TIMEOUT_WAITING_FOR_PROMISE_RESOLUTION;
|
||||
this.wait(targetTime - now);
|
||||
this.wait(TimeUnit.NANOSECONDS.toMillis(targetTime - now));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class Main extends Entity {
|
|||
t.message_(_forwarders.get(0), new IForwarder.SetPeer(_forwarders.get(_nActors - 1)));
|
||||
t.later(t0 -> {
|
||||
t0.log().info("Start");
|
||||
this._startTime = System.currentTimeMillis();
|
||||
this._startTime = System.nanoTime();
|
||||
_forwarders.forEach(a -> t0.message_(a, new IForwarder.HandleMessage(0)));
|
||||
});
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class Main extends Entity {
|
|||
if (body instanceof IForwarder.HandleMessage) {
|
||||
this._remainingToReceive--;
|
||||
if (this._remainingToReceive == 0) {
|
||||
double delta = (System.currentTimeMillis() - this._startTime) / 1000.0;
|
||||
double delta = (System.nanoTime() - this._startTime) / 1000000000.0;
|
||||
long nMessages = (long) _nActors * (long) _nRounds;
|
||||
double hz = nMessages / delta;
|
||||
turn.quit();
|
||||
|
|
Loading…
Reference in New Issue