Browse Source

Actually report Hz

main
Tony Garnock-Jones 11 months ago
parent
commit
d169c1277b
  1. 7
      src/test/java/org/syndicate_lang/actors/example/example2/Main.java

7
src/test/java/org/syndicate_lang/actors/example/example2/Main.java

@ -19,6 +19,7 @@ public class Main implements IForwarder {
public final int _nActors;
public final int _nRounds;
public int _remainingToReceive;
public long _startTime = 0;
public Main(int nActors, int nRounds) {
this._nActors = nActors;
@ -36,6 +37,7 @@ public class Main implements IForwarder {
_actors.add(a.asyncProxy(IForwarder.class));
}
Actor.log().info("Start");
this._startTime = System.currentTimeMillis();
_actors.forEach((a) -> a.handleMessage(0));
}
@ -43,8 +45,11 @@ public class Main implements IForwarder {
public void handleMessage(int hopCount) {
this._remainingToReceive--;
if (this._remainingToReceive == 0) {
long delta = System.currentTimeMillis() - this._startTime;
long nMessages = _nActors * _nRounds;
double hz = nMessages / (delta / 1000.0);
Actor.current().stop();
Actor.log().info("Stop after " + (_nActors * _nRounds) + " messages");
Actor.log().info("Stop after " + nMessages + " messages; " + hz + " Hz");
}
}
}
Loading…
Cancel
Save