in gflog-benchmark/src/main/java/com/epam/deltix/gflog/benchmark/util/LatencyBenchmarkRunner.java [57:101]
private static void run(final String name, final Consumer<BenchmarkState> command) throws Exception {
System.out.printf("Benchmark: %s. Warmup: %s s. Duration: %s s. Interval: %s ns. " +
"Threads: %s. Batch: %s. Catchup: %s. Affinity (base,step): %s,%s.%n",
name, WARMUP_S, DURATION_S, INTERVAL_NS, THREADS, BATCH, CATCHUP, AFFINITY_BASE, AFFINITY_STEP);
final AtomicBoolean active = new AtomicBoolean(true);
final AtomicBoolean measure = new AtomicBoolean(false);
final ThreadRunner[] runners = new ThreadRunner[THREADS];
for (int i = 0; i < THREADS; i++) {
final int affinity = (AFFINITY_BASE < 0 || AFFINITY_STEP < 0) ? -1 : (AFFINITY_BASE + i * AFFINITY_STEP);
final ThreadRunner runner = new ThreadRunner(command, active, measure, INTERVAL_NS, BATCH, affinity);
runner.start();
runners[i] = runner;
}
System.gc();
Thread.sleep(TimeUnit.SECONDS.toMillis(WARMUP_S));
System.out.printf("Benchmark: %s. Measuring.%n", name);
final long start = System.currentTimeMillis();
measure.set(true);
Thread.sleep(TimeUnit.SECONDS.toMillis(DURATION_S));
active.set(false);
final long end = System.currentTimeMillis();
final long took = end - start;
final Histogram histogram = newHistogram();
for (final ThreadRunner runner : runners) {
runner.join();
histogram.add(runner.histogram);
}
System.out.printf("Benchmark: %s. Took: %s ms. Throughput: %.0f msg/s. Latency: %n",
name, took, 1000.0 * histogram.getTotalCount() * BATCH / took);
histogram.outputPercentileDistribution(System.out, (double) BATCH);
System.out.println();
}