Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
weijie.tong
committed
Jul 1, 2020
1 parent
e25004f
commit 229f314
Showing
10 changed files
with
660 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
jmh/src/jmh/java/org/roaringbitmap/aggregation/and/bestcase/Roaring64BitmapBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.roaringbitmap.aggregation.and.bestcase; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.roaringbitmap.longlong.Roaring64Bitmap; | ||
|
||
@State(Scope.Benchmark) | ||
public class Roaring64BitmapBenchmark { | ||
|
||
private Roaring64Bitmap bitmap1; | ||
private Roaring64Bitmap bitmap2; | ||
|
||
@Setup | ||
public void setup() { | ||
bitmap1 = new Roaring64Bitmap(); | ||
bitmap2 = new Roaring64Bitmap(); | ||
int k = 1 << 16; | ||
long i = Long.MAX_VALUE / 2; | ||
long base = i; | ||
for (; i < base + 10000; ++i) { | ||
bitmap1.add(i * k); | ||
} | ||
for (; i < base + 10050; ++i) { | ||
bitmap2.add(i * k); | ||
bitmap1.add(i * k + 13); | ||
} | ||
for (; i < base + 20000; ++i) { | ||
bitmap2.add(i * k); | ||
} | ||
bitmap1.add(i * k); | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap inplace_and() { | ||
Roaring64Bitmap b1 = bitmap1.clone(); | ||
b1.and(bitmap2); | ||
return b1; | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap justclone() { | ||
return bitmap1.clone(); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
jmh/src/jmh/java/org/roaringbitmap/aggregation/and/identical/Roaring64BitmapBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.roaringbitmap.aggregation.and.identical; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.roaringbitmap.longlong.Roaring64Bitmap; | ||
|
||
@State(Scope.Benchmark) | ||
public class Roaring64BitmapBenchmark { | ||
|
||
private Roaring64Bitmap bitmap1; | ||
private Roaring64Bitmap bitmap2; | ||
|
||
@Setup | ||
public void setup() { | ||
bitmap1 = new Roaring64Bitmap(); | ||
bitmap2 = new Roaring64Bitmap(); | ||
int k = 1 << 16; | ||
long i = Long.MAX_VALUE / 2; | ||
long base = i; | ||
for (; i < base + 10000; ++i) { | ||
bitmap1.add(i * k); | ||
bitmap2.add(i * k); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap inplace_and() { | ||
Roaring64Bitmap b1 = bitmap1.clone(); | ||
b1.and(bitmap2); | ||
return b1; | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap justclone() { | ||
return bitmap1.clone(); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
jmh/src/jmh/java/org/roaringbitmap/aggregation/and/worstcase/Roaring64BitmapBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.roaringbitmap.aggregation.and.worstcase; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.roaringbitmap.longlong.Roaring64Bitmap; | ||
|
||
@State(Scope.Benchmark) | ||
public class Roaring64BitmapBenchmark { | ||
|
||
private Roaring64Bitmap bitmap1; | ||
private Roaring64Bitmap bitmap2; | ||
|
||
@Setup | ||
public void setup() { | ||
bitmap1 = new Roaring64Bitmap(); | ||
bitmap2 = new Roaring64Bitmap(); | ||
int k = 1 << 16; | ||
long i = Long.MAX_VALUE / 2; | ||
long base = i; | ||
for (; i < base + 10000; ++i) { | ||
bitmap1.add(2 * i * k); | ||
bitmap2.add(2 * i * k + 1); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap inplace_and() { | ||
Roaring64Bitmap b1 = bitmap1.clone(); | ||
b1.and(bitmap2); | ||
return b1; | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap justclone() { | ||
return bitmap1.clone(); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
jmh/src/jmh/java/org/roaringbitmap/aggregation/andnot/bestcase/Roaring64BitmapBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.roaringbitmap.aggregation.andnot.bestcase; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.roaringbitmap.longlong.Roaring64Bitmap; | ||
|
||
@State(Scope.Benchmark) | ||
public class Roaring64BitmapBenchmark { | ||
|
||
private Roaring64Bitmap bitmap1; | ||
private Roaring64Bitmap bitmap2; | ||
|
||
@Setup | ||
public void setup() { | ||
bitmap1 = new Roaring64Bitmap(); | ||
bitmap2 = new Roaring64Bitmap(); | ||
int k = 1 << 16; | ||
long i = Long.MAX_VALUE / 2; | ||
long base = i; | ||
|
||
for (; i < base + 10000; ++i) { | ||
bitmap1.add(i * k); | ||
} | ||
for (; i < base + 10050; ++i) { | ||
bitmap2.add(i * k); | ||
bitmap1.add(i * k + 13); | ||
} | ||
for (; i < base + 20000; ++i) { | ||
bitmap2.add(i * k); | ||
} | ||
bitmap1.add(i * k); | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap inplace_andNot() { | ||
Roaring64Bitmap b1 = bitmap1.clone(); | ||
b1.andNot(bitmap2); | ||
return b1; | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap justclone() { | ||
return bitmap1.clone(); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...src/jmh/java/org/roaringbitmap/aggregation/andnot/identical/Roaring64BitmapBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.roaringbitmap.aggregation.andnot.identical; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.roaringbitmap.longlong.Roaring64Bitmap; | ||
|
||
@State(Scope.Benchmark) | ||
public class Roaring64BitmapBenchmark { | ||
|
||
private Roaring64Bitmap bitmap1; | ||
private Roaring64Bitmap bitmap2; | ||
|
||
@Setup | ||
public void setup() { | ||
bitmap1 = new Roaring64Bitmap(); | ||
bitmap2 = new Roaring64Bitmap(); | ||
int k = 1 << 16; | ||
long i = Long.MAX_VALUE / 2; | ||
long base = i; | ||
for (; i < base + 10000; ++i) { | ||
bitmap1.add(i * k); | ||
bitmap2.add(i * k); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap inplace_andNot() { | ||
Roaring64Bitmap b1 = bitmap1.clone(); | ||
b1.andNot(bitmap2); | ||
return b1; | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap justclone() { | ||
return bitmap1.clone(); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...src/jmh/java/org/roaringbitmap/aggregation/andnot/worstcase/Roaring64BitmapBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.roaringbitmap.aggregation.andnot.worstcase; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.roaringbitmap.longlong.Roaring64Bitmap; | ||
|
||
@State(Scope.Benchmark) | ||
public class Roaring64BitmapBenchmark { | ||
|
||
private Roaring64Bitmap bitmap1; | ||
private Roaring64Bitmap bitmap2; | ||
|
||
@Setup | ||
public void setup() { | ||
bitmap1 = new Roaring64Bitmap(); | ||
bitmap2 = new Roaring64Bitmap(); | ||
int k = 1 << 16; | ||
long i = Long.MAX_VALUE / 2; | ||
long base = i; | ||
for (; i < base + 10000; ++i) { | ||
bitmap1.add(2 * i * k); | ||
bitmap2.add(2 * i * k + 1); | ||
} | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap inplace_andNot() { | ||
Roaring64Bitmap b1 = bitmap1.clone(); | ||
b1.andNot(bitmap2); | ||
return b1; | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public Roaring64Bitmap justclone() { | ||
return bitmap1.clone(); | ||
} | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
jmh/src/jmh/java/org/roaringbitmap/cardinality64/Roaring64BmpCardinalityBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.roaringbitmap.cardinality64; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
import org.openjdk.jmh.runner.options.TimeValue; | ||
import org.roaringbitmap.longlong.Roaring64Bitmap; | ||
|
||
@State(Scope.Benchmark) | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public class Roaring64BmpCardinalityBenchmark { | ||
|
||
@BenchmarkMode(Mode.Throughput) | ||
@Benchmark | ||
public long getCardinality(CacheCardinalitiesBenchmarkState benchmarkState) { | ||
return benchmarkState.roaring64Bitmap.getLongCardinality(); | ||
} | ||
|
||
static final int SMALL_CARDINALITY = 100; | ||
// High cardinality: 1000 times the small test | ||
static final int HIGH_CARDINALITY = SMALL_CARDINALITY * 1000; | ||
|
||
@State(Scope.Benchmark) | ||
public static class CacheCardinalitiesBenchmarkState { | ||
final Roaring64Bitmap roaring64Bitmap = new Roaring64Bitmap(); | ||
|
||
// Try to generate many buckets with low cardinality bitmaps in order to stress-out the Map | ||
// overhead | ||
public CacheCardinalitiesBenchmarkState() { | ||
for (long i = 0; i < HIGH_CARDINALITY; i++) { | ||
long toAdd = i + i * Integer.MAX_VALUE; | ||
roaring64Bitmap.addLong(toAdd); | ||
} | ||
} | ||
} | ||
|
||
public static void main(String... args) throws Exception { | ||
Options opts = new OptionsBuilder().include(".*Roaring64BmpCardinalityBenchmark.*") | ||
.warmupTime(new TimeValue(1, TimeUnit.SECONDS)).warmupIterations(3) | ||
.measurementTime(new TimeValue(1, TimeUnit.SECONDS)).measurementIterations(3).forks(1) | ||
.build(); | ||
|
||
new Runner(opts).run(); | ||
} | ||
} |
Oops, something went wrong.