Skip to content

Commit

Permalink
[ARROW-5881][Java] Provide benchmark for allBitsNull
Browse files Browse the repository at this point in the history
  • Loading branch information
liyafan82 committed Jul 11, 2019
1 parent 3deedaf commit c57cb6d
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class BitVectorHelperBenchmarks {

private ArrowBuf validityBuffer;

private ArrowBuf oneBitValidityBuffer;

/**
* Setup benchmarks.
*/
Expand All @@ -65,6 +67,11 @@ public void prepare() {
BitVectorHelper.setValidityBit(validityBuffer, i, (byte) 0);
}
}

// only one 1 bit in the middle of the buffer
oneBitValidityBuffer = allocator.buffer(VALIDITY_BUFFER_CAPACITY / 8);
oneBitValidityBuffer.setZero(0, VALIDITY_BUFFER_CAPACITY / 8);
BitVectorHelper.setValidityBit(oneBitValidityBuffer, VALIDITY_BUFFER_CAPACITY / 2, (byte) 1);
}

/**
Expand All @@ -73,6 +80,7 @@ public void prepare() {
@TearDown
public void tearDown() {
validityBuffer.close();
oneBitValidityBuffer.close();
allocator.close();
}

Expand All @@ -83,6 +91,13 @@ public int getNullCountBenchmark() {
return BitVectorHelper.getNullCount(validityBuffer, VALIDITY_BUFFER_CAPACITY);
}

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public boolean allBitsNullBenchmark() {
return BitVectorHelper.allBitsNullOrig(oneBitValidityBuffer, VALIDITY_BUFFER_CAPACITY);
}

//@Test
public static void main(String [] args) throws RunnerException {
Options opt = new OptionsBuilder()
Expand Down

0 comments on commit c57cb6d

Please sign in to comment.