Skip to content

Commit

Permalink
[Feat] Benchmark with Criterion Continued
Browse files Browse the repository at this point in the history
  • Loading branch information
Gifted-s committed Jan 9, 2025
1 parent 57c3be6 commit c8bc590
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion bench/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit c8bc590

Please sign in to comment.