use of net.openhft.chronicle.core.util.NanoSampler in project Chronicle-Queue by OpenHFT.
the class QueueMultiThreadedJLBHBenchmark method init.
@Override
public void init(JLBH jlbh) {
this.jlbh = jlbh;
IOTools.deleteDirWithFiles(path, 10);
sourceQueue = createQueueInstance();
sinkQueue = useSingleQueueInstance ? sourceQueue : createQueueInstance();
appender = sourceQueue.acquireAppender().disableThreadSafetyCheck(true);
tailer = sinkQueue.createTailer().disableThreadSafetyCheck(true);
NanoSampler readProbe = jlbh.addProbe("read");
writeProbe = jlbh.addProbe("write");
if (usePretoucher) {
pretoucherExecutorService = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("pretoucher", true));
pretoucherExecutorService.scheduleAtFixedRate(() -> sourceQueue.acquireAppender().pretouch(), 1, 200, TimeUnit.MILLISECONDS);
}
tailerThread = new Thread(() -> {
try (final AffinityLock affinityLock = AffinityLock.acquireLock(tailerAffinity)) {
Datum datum2 = new Datum(messageSize);
while (!stopped) {
long beforeReadNs = System.nanoTime();
try (DocumentContext dc = tailer.readingDocument()) {
if (!dc.isPresent())
continue;
datum2.readMarshallable(dc.wire().bytes());
long now = System.nanoTime();
jlbh.sample(now - datum2.ts);
readProbe.sampleNanos(now - beforeReadNs);
}
}
}
});
tailerThread.start();
}
Aggregations