Search in sources :

Example 1 with FastSizeDeque

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);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) FastSizeDeque(org.apache.ignite.util.deque.FastSizeDeque) LongAdder(java.util.concurrent.atomic.LongAdder)

Aggregations

AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 LongAdder (java.util.concurrent.atomic.LongAdder)1 FastSizeDeque (org.apache.ignite.util.deque.FastSizeDeque)1