aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2023-05-28 12:24:45 -0700
committerJack O'Connor <[email protected]>2023-05-28 12:24:45 -0700
commit176fdf8893f933577d87130d97519dcd00d491b8 (patch)
treec95ef695c076dc0547d58fe55f2ff05217440579
parent4e8d73ad7bfa56e428ad610f602399af43b85fcd (diff)
add XOF benchmarks
-rw-r--r--benches/bench.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/benches/bench.rs b/benches/bench.rs
index 5efb9e6..4169ea7 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -515,3 +515,46 @@ fn bench_two_updates(b: &mut Bencher) {
hasher.finalize()
});
}
+
+fn bench_xof(b: &mut Bencher, len: usize) {
+ b.bytes = len as u64;
+ let mut output = [0u8; 64 * BLOCK_LEN];
+ let output_slice = &mut output[..len];
+ let mut xof = blake3::Hasher::new().finalize_xof();
+ b.iter(|| xof.fill(output_slice));
+}
+
+#[bench]
+fn bench_xof_01_block(b: &mut Bencher) {
+ bench_xof(b, BLOCK_LEN);
+}
+
+#[bench]
+fn bench_xof_02_blocks(b: &mut Bencher) {
+ bench_xof(b, 2 * BLOCK_LEN);
+}
+
+#[bench]
+fn bench_xof_04_blocks(b: &mut Bencher) {
+ bench_xof(b, 4 * BLOCK_LEN);
+}
+
+#[bench]
+fn bench_xof_08_blocks(b: &mut Bencher) {
+ bench_xof(b, 8 * BLOCK_LEN);
+}
+
+#[bench]
+fn bench_xof_16_blocks(b: &mut Bencher) {
+ bench_xof(b, 16 * BLOCK_LEN);
+}
+
+#[bench]
+fn bench_xof_32_blocks(b: &mut Bencher) {
+ bench_xof(b, 32 * BLOCK_LEN);
+}
+
+#[bench]
+fn bench_xof_64_blocks(b: &mut Bencher) {
+ bench_xof(b, 64 * BLOCK_LEN);
+}