Skip to content
Snippets Groups Projects
Commit 597fa99f authored by Michael Eischer's avatar Michael Eischer
Browse files

Fix benchmark interval count jitter

As the benchmark policy and the interval statistics start at
nearly exactly the same time this could cause the interval statistics
to report one interval too much or not.

This change slightly delays to policy start and suppresses printing
of the last incomplete interval. That way the first interval captures
slightly too little data (but that doesn't matter as it's normally cut
off anyways) and the last incomplete interval only captures data
for the fraction of a second.
parent 2ca510ac
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment