use of org.apache.ignite.util.deque.FastSizeDeque in project ignite by apache.
the class GridCircularBufferPerformanceTest method testDequeueThroughput.
/**
* @throws Exception If failed.
*/
public void testDequeueThroughput() throws Exception {
final FastSizeDeque<Integer> buf = new FastSizeDeque<>(new ConcurrentLinkedDeque<>());
final LongAdder cnt = new LongAdder();
final AtomicBoolean finished = new AtomicBoolean();
multithreadedAsync(new Callable<Object>() {
@Override
public Object call() throws Exception {
while (!finished.get()) {
U.sleep(5000);
info("Ops/sec: " + cnt.sumThenReset() / 5);
}
return null;
}
}, 1);
final int size = 256 * 1024;
multithreaded(new Callable<Object>() {
@Override
public Object call() throws Exception {
while (!finished.get()) {
buf.add(1);
if (buf.sizex() > size)
buf.poll();
cnt.increment();
}
return null;
}
}, 8);
info("Buffer: " + buf);
}
Aggregations