}
Collection<Measurement> run(int targetReps) throws Exception {
long timeToStop = startTick + options.maxTotalRuntimeNanos - options.timingIntervalNanos;
Queue<Measurement> measurements = new LinkedList<Measurement>();
LastNValues recentValues = new LastNValues(options.reportedIntervals);
log.notifyMeasurementPhaseStarting();
for (int trials = 0; trials < 1; trials++) {
int reps = 5;
if (options.gcBeforeEach) Util.forceGc();
log.notifyMeasurementStarting();
long nanos = invokeTimeMethod(reps);
double nanos_per_rep = nanos / reps;
double seconds = (double) nanos_per_rep / 1000000000;
double messages_per_second = totalMessages / seconds;
Measurement m = new Measurement();
m.value = messages_per_second;
m.weight = 1;
m.unit = "Messages per Second";
m.description = "";
double nanosPerRep = m.value / m.weight;
log.notifyMeasurementEnding(nanosPerRep);
measurements.add(m);
if (measurements.size() > options.reportedIntervals) {
measurements.remove();
}
recentValues.add(nanosPerRep);
if (shouldShortCircuit(recentValues)) {
break;
}
}