Search in sources :

Example 36 with BenchmarkOptions

use of com.carrotsearch.junitbenchmarks.BenchmarkOptions in project druid by druid-io.

the class BitmapCreationBenchmark method testToImmutableByteArray.

@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000)
@Test
public void testToImmutableByteArray() {
    ImmutableBitmap immutableBitmap = factory.makeImmutableBitmap(baseMutableBitmap);
    Assert.assertArrayEquals(baseBytes, immutableBitmap.toBytes());
}
Also used : ImmutableBitmap(org.apache.druid.collections.bitmap.ImmutableBitmap) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 37 with BenchmarkOptions

use of com.carrotsearch.junitbenchmarks.BenchmarkOptions in project druid by druid-io.

the class BenchmarkIndexibleWrites method testConcurrentWrites.

@BenchmarkOptions(warmupRounds = 100, benchmarkRounds = 100, clock = Clock.REAL_TIME, callgc = true)
@Ignore
@Test
public /**
 * CALLEN - 2015-01-15 - OSX - Java 1.7.0_71-b14
 *   BenchmarkIndexibleWrites.testConcurrentWrites[0]: [measured 100 out of 200 rounds, threads: 1 (sequential)]
 *   round: 0.24 [+- 0.01], round.block: 0.00 [+- 0.00], round.gc: 0.02 [+- 0.00], GC.calls: 396, GC.time: 1.88, time.total: 50.60, time.warmup: 24.84, time.bench: 25.77
 *   BenchmarkIndexibleWrites.testConcurrentWrites[1]: [measured 100 out of 200 rounds, threads: 1 (sequential)]
 *   round: 0.15 [+- 0.01], round.block: 0.00 [+- 0.00], round.gc: 0.02 [+- 0.00], GC.calls: 396, GC.time: 2.11, time.total: 33.14, time.warmup: 16.09, time.bench: 17.05
 */
void testConcurrentWrites() throws ExecutionException, InterruptedException {
    final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(concurrentThreads, new ThreadFactoryBuilder().setDaemon(false).setNameFormat("indexible-writes-benchmark-%d").build()));
    final AtomicInteger index = new AtomicInteger(0);
    List<ListenableFuture<?>> futures = new ArrayList<>();
    final Integer loops = totalIndexSize / concurrentThreads;
    for (int i = 0; i < concurrentThreads; ++i) {
        futures.add(executorService.submit(new Runnable() {

            @Override
            public void run() {
                for (int i = 0; i < loops; ++i) {
                    final Integer idx = index.getAndIncrement();
                    concurrentIndexible.set(idx, idx);
                }
            }
        }));
    }
    Futures.allAsList(futures).get();
    Assert.assertTrue(StringUtils.format("Index too small %d, expected %d across %d loops", index.get(), totalIndexSize, loops), index.get() >= totalIndexSize);
    for (int i = 0; i < index.get(); ++i) {
        Assert.assertEquals(i, concurrentIndexible.get(i).intValue());
    }
    concurrentIndexible.clear();
    futures.clear();
    executorService.shutdown();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Ignore(org.junit.Ignore) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 38 with BenchmarkOptions

use of com.carrotsearch.junitbenchmarks.BenchmarkOptions in project druid by druid-io.

the class CostBalancerStrategyBenchmark method testBenchmark.

@Test
@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000)
public void testBenchmark() {
    DataSegment segment = CostBalancerStrategyTest.getSegment(1000, "testds", interval1);
    selected = strategy.findNewSegmentHomeReplicator(segment, serverHolderList);
}
Also used : DataSegment(org.apache.druid.timeline.DataSegment) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 39 with BenchmarkOptions

use of com.carrotsearch.junitbenchmarks.BenchmarkOptions in project DirectMemory by raffaeleguidi.

the class ConcurrentTests2 method retrieveCatchHalfOfThem.

@BenchmarkOptions(benchmarkRounds = 1000000, warmupRounds = 0, concurrency = 100)
@Test
public void retrieveCatchHalfOfThem() {
    String key = "test-" + (rndGen.nextInt(entries * 2) + 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 {
        missed.incrementAndGet();
    }
}
Also used : Pointer(org.directmemory.memory.Pointer) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 40 with BenchmarkOptions

use of com.carrotsearch.junitbenchmarks.BenchmarkOptions 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

BenchmarkOptions (com.carrotsearch.junitbenchmarks.BenchmarkOptions)42 Test (org.junit.Test)42 DirectByteBufferAllocator (org.apache.parquet.bytes.DirectByteBufferAllocator)10 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)6 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)6 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 ByteBufferInputStream (org.apache.parquet.bytes.ByteBufferInputStream)6 Binary (org.apache.parquet.io.api.Binary)6 Ignore (org.junit.Ignore)6 ArrayList (java.util.ArrayList)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 Pointer (org.directmemory.memory.Pointer)4 BasicDBObject (com.mongodb.BasicDBObject)3 MutableBitmap (io.druid.collections.bitmap.MutableBitmap)3 LinkedList (java.util.LinkedList)3 MutableBitmap (org.apache.druid.collections.bitmap.MutableBitmap)3 DeltaBinaryPackingValuesWriter (org.apache.parquet.column.values.delta.DeltaBinaryPackingValuesWriter)3 BinaryPlainValuesReader (org.apache.parquet.column.values.plain.BinaryPlainValuesReader)3 PlainValuesWriter (org.apache.parquet.column.values.plain.PlainValuesWriter)3