al.bind();
Excerpt excerpt = tsc.createExcerpt();
Excerpt excerpt2 = tsc2.createExcerpt();
Histogram hist = new Histogram(100000, 1);
long totalTime = 0, longDelays = 0;
for (int i = 0; i < RUNS; i++) {
excerpt.startExcerpt(8);
excerpt.writeLong(nanoTime());
excerpt.finish();
do {
busyWait();
} while (!excerpt2.index(i));
long time1 = nanoTime();
long time0 = excerpt2.readLong();
excerpt2.finish();
if (i >= WARMUP) {
final long latency = time1 - time0;
if (latency < 0 || latency > 100000) {
longDelays++;
System.out.println(latency);
}
hist.sample(latency);
totalTime += latency;
}
}
t.join();
tsc.close();
tsc2.close();
System.out.printf("The average RTT latency was %,d ns. The 50/99 / 99.9/99.99%%tile latencies were %,d/%,d / %,d/%,d. There were %,d delays over 100 μs%n",
totalTime / RUNS, hist.percentile(0.5), hist.percentile(0.99), hist.percentile(0.999), hist.percentile(0.9999), longDelays);
al.release();
}