diff --git a/src/refit/client/REFITBenchmark.java b/src/refit/client/REFITBenchmark.java index 7373d4dd3950720da6d168435dd04642b4f196e5..d22074ccbdc340c1070e8f775fa25ae7f68d9e13 100644 --- a/src/refit/client/REFITBenchmark.java +++ b/src/refit/client/REFITBenchmark.java @@ -144,6 +144,9 @@ public class REFITBenchmark implements REFITStatisticsListener { // Wait for benchmark end statistics.start(); + // Delay the policy start a bit to make it very likely that the policy completes a short time + // after a statistics interval result is printed + REFITTime.sleep(79); policy.execute(); statistics.end(); diff --git a/src/refit/util/REFITIntervalStatistics.java b/src/refit/util/REFITIntervalStatistics.java index dba947b64707914d63a3629aa2770fd2acd16a94..f30d025ef325778b1e35ecb9b474d8b3069862f8 100644 --- a/src/refit/util/REFITIntervalStatistics.java +++ b/src/refit/util/REFITIntervalStatistics.java @@ -27,6 +27,7 @@ public class REFITIntervalStatistics extends Thread { private final WriterReaderPhaser eventPhaser; private final AtomicBoolean firstEvent; + public int lastEpochCounter; public long overallDurationInUs; public int overallEventCounter; public long overallEventValueAggregation; @@ -103,7 +104,13 @@ public class REFITIntervalStatistics extends Thread { long myEventValueMax = oldEvent.valueMax.get(); eventPhaser.readerUnlock(); + // don't print incomplete last interval + if (!running) { + break; + } + // update overall counters + lastEpochCounter = myResultIndex; overallEventCounter += myEventCount; overallEventValueAggregation += myEventValueAggregation; @@ -154,7 +161,7 @@ public class REFITIntervalStatistics extends Thread { eventPhaser.flipPhase(); eventPhaser.readerUnlock(); - listener.statisticsOverallResult(event.epochCounter - 1, + listener.statisticsOverallResult(lastEpochCounter, overallEventCounter, overallEventCounter / (float) (overallDurationInUs / (intervalInMs * 1000)), overallEventValueAggregation / (float) overallEventCounter);