Last active
July 9, 2023 08:34
-
-
Save jexp/1039dd5bb3aaa245226bd060c38cee9c to your computer and use it in GitHub Desktop.
RoaringBitMap Benchmark with jbang based on https://xam.dk/blog/jbang-reproducers/
This file contains hidden or 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
//JAVA 20 | |
//DEPS org.roaringbitmap:RoaringBitmap:0.9.45 | |
//DEPS org.openjdk.jmh:jmh-generator-annprocess:1.36 | |
package de.jexp.rbm; | |
import org.openjdk.jmh.annotations.*; | |
import org.roaringbitmap.RoaringBitmap; | |
import java.util.BitSet; | |
@State(Scope.Thread) | |
public class BitMapOpsComparision { | |
private final static int BM_SIZE = 20_000_000; | |
private RoaringBitmap rbm1; | |
private RoaringBitmap rbm2; | |
private BitSet bs1; | |
private BitSet bs2; | |
public static void main(String[] args) throws Exception { | |
org.openjdk.jmh.Main.main(args); | |
} | |
@Setup | |
public void setup() { | |
rbm1 = RoaringBitmap.bitmapOfRange(0, BM_SIZE/2); | |
rbm2 = RoaringBitmap.bitmapOfRange(BM_SIZE/2,BM_SIZE); | |
bs1 = new BitSet(BM_SIZE); | |
bs1.set(0, BM_SIZE/2); | |
bs2 = new BitSet(BM_SIZE); | |
bs2.set(BM_SIZE/2, BM_SIZE); | |
} | |
@Benchmark | |
public RoaringBitmap rbmOR() { | |
return RoaringBitmap.or(rbm1, rbm2); | |
} | |
@Benchmark | |
public BitSet bsOR() { | |
BitSet result = (BitSet) bs1.clone(); | |
result.or(bs2); | |
return result; | |
} | |
@Benchmark | |
public RoaringBitmap rbmAND() { | |
return RoaringBitmap.and(rbm1, rbm2); | |
} | |
@Benchmark | |
public BitSet bsAND() { | |
BitSet result = (BitSet) bs1.clone(); | |
result.and(bs2); | |
return result; | |
} | |
@Benchmark | |
public RoaringBitmap rbmAND_NOT() { | |
return RoaringBitmap.andNot(rbm1, rbm2); | |
} | |
@Benchmark | |
public BitSet bsAND_NOT() { | |
BitSet result = (BitSet) bs1.clone(); | |
result.andNot(bs2); | |
return result; | |
} | |
@Benchmark | |
public RoaringBitmap rbmXOR() { | |
return RoaringBitmap.xor(rbm1, rbm2); | |
} | |
@Benchmark | |
public BitSet bsXOR() { | |
BitSet result = (BitSet) bs1.clone(); | |
result.xor(bs2); | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment