Search in sources :

Example 21 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 LinkedList<>();
    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(String.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) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) LinkedList(java.util.LinkedList) Ignore(org.junit.Ignore) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 22 with BenchmarkOptions

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

the class BitmapCreationBenchmark method testRandomAddition.

@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 10)
@Test
public void testRandomAddition() {
    MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
    for (int i : randIndex) {
        mutableBitmap.add(i);
    }
    Assert.assertEquals(numBits, mutableBitmap.size());
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 23 with BenchmarkOptions

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

the class BitmapCreationBenchmark method testLinearAdditionDescending.

@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000)
@Test
public void testLinearAdditionDescending() {
    MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
    for (int i = numBits - 1; i >= 0; --i) {
        mutableBitmap.add(i);
    }
    Assert.assertEquals(numBits, mutableBitmap.size());
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 24 with BenchmarkOptions

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

the class BitmapCreationBenchmark method testFromImmutableByteArray.

@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000)
@Test
public void testFromImmutableByteArray() {
    ImmutableBitmap immutableBitmap = factory.mapImmutableBitmap(baseByteBuffer);
    Assert.assertEquals(numBits, immutableBitmap.size());
}
Also used : ImmutableBitmap(io.druid.collections.bitmap.ImmutableBitmap) Test(org.junit.Test) BenchmarkOptions(com.carrotsearch.junitbenchmarks.BenchmarkOptions)

Example 25 with BenchmarkOptions

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

the class BitmapCreationBenchmark method testLinearAddition.

@BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000)
@Test
public void testLinearAddition() {
    MutableBitmap mutableBitmap = factory.makeEmptyMutableBitmap();
    for (int i = 0; i < numBits; ++i) {
        mutableBitmap.add(i);
    }
    Assert.assertEquals(numBits, mutableBitmap.size());
}
Also used : MutableBitmap(io.druid.collections.bitmap.MutableBitmap) 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