From ed5ed6f6f34a5a28687c3abee8221d0f11968d7b Mon Sep 17 00:00:00 2001 From: Abhishek Shah Date: Wed, 28 Feb 2024 23:23:19 +0530 Subject: [PATCH] black box --- lib/benches/bench.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/benches/bench.rs b/lib/benches/bench.rs index 7678fc3..d665455 100644 --- a/lib/benches/bench.rs +++ b/lib/benches/bench.rs @@ -32,39 +32,39 @@ fn cold_start_get(c: &mut Criterion) { group.finish(); } fn set_many_keys(c: &mut Criterion) { - let mut group = c.benchmark_group("SET/RM"); + let mut group = c.benchmark_group("SET & RM"); let temp_dir = TempDir::new().unwrap(); let mut store = KvStore::open(&temp_dir.path()).unwrap(); let test_data: Vec<(String, String)> = generate_test_data(); - group.bench_function("kvs: set key", |b: &mut Bencher<_>| { + group.bench_function("kvs: SET key", |b: &mut Bencher<_>| { b.iter(|| { - for (k, v) in test_data.clone().into_iter() { + black_box(for (k, v) in test_data.clone().into_iter() { store.set(k, v).unwrap(); - } + }) }) }); - group.bench_function("kvs: remove keys", |b| { + group.bench_function("kvs: Remove keys", |b| { b.iter(|| { - for (k, _) in test_data.clone().into_iter() { + black_box(for (k, _) in test_data.clone().into_iter() { store.remove(k).unwrap(); - } + }) }) }); let temp_dir = TempDir::new().unwrap(); let mut store = SledKvsEngine::open(&temp_dir.path()).unwrap(); let test_data: Vec<(String, String)> = generate_test_data(); - group.bench_function("sled: set key", |b: &mut Bencher<_>| { + group.bench_function("sled: SET key", |b: &mut Bencher<_>| { b.iter(|| { - for (k, v) in test_data.clone().into_iter() { + black_box(for (k, v) in test_data.clone().into_iter() { store.set(k, v).unwrap(); - } + }) }) }); - group.bench_function("sled: remove keys", |b| { + group.bench_function("sled: Remove keys", |b| { b.iter(|| { - for (k, _) in test_data.clone().into_iter() { + black_box(for (k, _) in test_data.clone().into_iter() { store.remove(k).unwrap(); - } + }) }) }); group.finish();