in perf/src/main/java/com/spotify/ffwd/FastForwardPerf.java [138:170]
private void once() throws Exception {
final FastForward client = FastForward.setup();
final long period = (even * 1000000) / count;
while (true) {
int i = batch.position.getAndIncrement();
if (i >= count) {
break;
}
final Metric m = batch.metric.value(i * 1.0);
if (even == 0) {
client.send(m);
continue;
}
final long now = System.nanoTime();
// what is the expected time that we should run?
final long expected = batch.started + (i * period) / threads;
final long diff = (expected - now) / 1000000;
if (diff > 0) {
Thread.sleep(diff);
}
client.send(m);
}
}