From 46942daf0292d2cce4cf5b46b0831ef4ffed0526 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 18 Jan 2025 09:28:37 +0200 Subject: Fix benchmark --- log_db/benches/benchmark.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'log_db') diff --git a/log_db/benches/benchmark.rs b/log_db/benches/benchmark.rs index dc853b6..148c0b4 100644 --- a/log_db/benches/benchmark.rs +++ b/log_db/benches/benchmark.rs @@ -104,17 +104,17 @@ pub fn get_existing_compacted(c: &mut Criterion) { .expect("Failed to initialize DB"); let mut insts = Vec::new(); + let mut inst_index = 0; for size in [100_000, 1_000_000, 10_000_000] { println!("Prefilling DB to {} entries", size); prefill_db(&mut db, &mut insts, size, true).expect("Failed to prefill DB"); - let mut inst_it = insts.iter(); group.bench_with_input(BenchmarkId::from_parameter(size), &size, |b, &_size| { b.iter(|| { - let result = db - .get(black_box(&Value::Int(inst_it.next().unwrap().id))) - .unwrap(); - assert!(result.is_some()) + let id = insts[inst_index].id; + let result = db.get(black_box(&Value::Int(id))).unwrap(); + assert!(result.is_some()); + inst_index = (inst_index + 1) % insts.len(); }); }); } -- cgit v1.3