Skip to content

Instantly share code, notes, and snippets.

private class CustomBitSetList {
final int bucket_size = 1024;
int offset = -1;
int currentBucketIdx = 0;
ArrayList<FixedBitSet> buckets = new ArrayList<>(16);
FixedBitSet currentBucket = new FixedBitSet(bucket_size);
CustomBitSetList() {
Benchmark Mode Cnt Score Error Units
MyBenchmark.testLuceneBitSetGrowByDoubleLarge thrpt 10 5.098 ± 0.152 ops/s
MyBenchmark.testLuceneBitSetGrowByDoubleSmall thrpt 10 521.420 ± 23.501 ops/s
MyBenchmark.testLuceneBitSetGrowByOneLarge thrpt 10 3.763 ± 0.227 ops/s
MyBenchmark.testLuceneBitSetGrowByOneSmall thrpt 10 407.312 ± 14.617 ops/s
Benchmark Mode Cnt Score Error Units
MyBenchmark.testCustomBitSetSmall thrpt 10 143.324 ± 24.399 ops/s
MyBenchmark.testCustomBitSetWrapperLarge thrpt 10 0.251 ± 0.163 ops/s
MyBenchmark.testLuceneBitSetGrowByDoubleLarge thrpt 10 51.219 ± 1.172 ops/s
MyBenchmark.testLuceneBitSetGrowByDoubleSmall thrpt 10 5278.155 ± 204.776 ops/s
MyBenchmark.testLuceneBitSetGrowByOneLarge thrpt 10 40.555 ± 1.277 ops/s
MyBenchmark.testLuceneBitSetGrowByOneSmall thrpt 10 4125.909 ± 200.244 ops/s
package org.sample;
import org.apache.lucene.util.LongBitSet;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.openjdk.jmh.annotations.Benchmark;
import java.util.ArrayList;
public class MyBenchmark {
Result "testWithoutIf":
905846726.800 ±(99.9%) 3858743.057 ops/s [Average]
(min, avg, max) = (836690777.086, 905846726.800, 943887137.592), stdev = 16338159.725
CI (99.9%): [901987983.743, 909705469.857] (assumes normal distribution)
# Run complete. Total time: 00:06:45
Benchmark Mode Cnt Score Error Units
MyBenchmark.testWithoutIf thrpt 200 905846726.800 ± 3858743.057 ops/s
@Test
public void testLog() {
Object[] array = new Object[] {1, 2};
double avg = 0.0;
for (int x = 0; x < 1000; x++) {
long start = System.currentTimeMillis();
for (int i = 0; i < 100_000_000; i++) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("a {} string {}", array[0], array[1]);
}