Search in sources :

Example 21 with Pointer

use of org.directmemory.memory.Pointer in project DirectMemory by raffaeleguidi.

the class ConcurrentTests2 method retrieveCatchThemAll.

@BenchmarkOptions(benchmarkRounds = 1000000, warmupRounds = 0, concurrency = 100)
@Test
public void retrieveCatchThemAll() {
    String key = "test-" + (rndGen.nextInt(entries) + 1);
    Pointer p = map.get(key);
    read.incrementAndGet();
    if (p != null) {
        got.incrementAndGet();
        byte[] payload = MemoryManager.retrieve(p);
        if (key.equals(new String(payload)))
            good.incrementAndGet();
        else
            bad.incrementAndGet();
    } else {
        logger.info("did not find key " + key);
        missed.incrementAndGet();
    }
}
Also used : Pointer(org.directmemory.memory.Pointer) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Aggregations

Pointer (org.directmemory.memory.Pointer)21 Test (org.junit.Test)12 BenchmarkOptions (com.carrotsearch.junitbenchmarks.BenchmarkOptions)4 OffHeapMemoryBuffer (org.directmemory.memory.OffHeapMemoryBuffer)4 IOException (java.io.IOException)2 Random (java.util.Random)2 MapMaker (com.google.common.collect.MapMaker)1