Skip to content

Commit

Permalink
add deserialize ByteBuffer benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Tan-JiaLiang committed Dec 25, 2024
1 parent e21b864 commit 1b0cecd
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.util.Random;

Expand Down Expand Up @@ -65,7 +66,7 @@ public void testDeserialize() throws Exception {
.setOutputPerIteration(true);

benchmark.addCase(
"without-buffer",
"deserialize(DataInput)",
10,
() -> {
try (LocalFileIO.LocalSeekableInputStream seekableStream =
Expand All @@ -78,7 +79,7 @@ public void testDeserialize() throws Exception {
});

benchmark.addCase(
"with-buffer",
"deserialize(DataInput, byte[])",
10,
() -> {
try (LocalFileIO.LocalSeekableInputStream seekableStream =
Expand All @@ -90,6 +91,21 @@ public void testDeserialize() throws Exception {
}
});

benchmark.addCase(
"deserialize(ByteBuffer)",
10,
() -> {
try (LocalFileIO.LocalSeekableInputStream seekableStream =
new LocalFileIO.LocalSeekableInputStream(file);
DataInputStream input = new DataInputStream(seekableStream)) {
byte[] bytes = new byte[(int) file.length()];
input.readFully(bytes);
new RoaringBitmap().deserialize(ByteBuffer.wrap(bytes));
} catch (IOException e) {
throw new RuntimeException(e);
}
});

benchmark.run();
}
}

0 comments on commit 1b0cecd

Please sign in to comment.