diff --git a/bench/benchmark.rs b/bench/benchmark.rs index 52bf677..b197599 100644 --- a/bench/benchmark.rs +++ b/bench/benchmark.rs @@ -22,7 +22,30 @@ fn insert_many(c: &mut Criterion) { }); } +fn get_many(c: &mut Criterion) { + let root = tempdir().unwrap(); + let path = root.path().join("default"); + let rt = runtime::Runtime::new().unwrap(); + let mut store = { rt.block_on(async { DataStore::open("benchmark", path).await.unwrap() }) }; + rt.block_on(async { + for e in 1..=3000 { + let e = e.to_string(); + store.put(&e, &e).await.unwrap(); + } + }); + + c.bench_function("get_many", |b| { + b.iter(|| { + rt.block_on(async { + for e in 1..=3000 { + let e = e.to_string(); + store.get(&e).await.unwrap(); + } + }); + }); + }); +} -criterion_group!(benches, insert_many); +criterion_group!(benches, insert_many, get_many); criterion_main!(benches);