From c1d1c806748be741b0a55e95468c3247b1b9bb9a Mon Sep 17 00:00:00 2001 From: marvin-j97 Date: Mon, 21 Oct 2024 23:00:42 +0200 Subject: [PATCH] fix: bench --- benches/level_manifest.rs | 6 +++++- src/tree/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/benches/level_manifest.rs b/benches/level_manifest.rs index b26e4d2..91277a2 100644 --- a/benches/level_manifest.rs +++ b/benches/level_manifest.rs @@ -5,6 +5,8 @@ fn iterate_segments(c: &mut Criterion) { let mut group = c.benchmark_group("Iterate level manifest"); group.sample_size(10); + std::fs::create_dir_all(".bench").unwrap(); + for segment_count in [0, 1, 5, 10, 100, 500, 1_000, 2_000, 4_000] { group.bench_function(format!("iterate {segment_count} segments"), |b| { let folder = tempfile::tempdir_in(".bench").unwrap(); @@ -28,7 +30,9 @@ fn find_segment(c: &mut Criterion) { let mut group = c.benchmark_group("Find segment in disjoint level"); group.sample_size(10); - for segment_count in [1u64, 5, 10, 100, 500, 1_000, 2_000, 4_000] { + std::fs::create_dir_all(".bench").unwrap(); + + for segment_count in [1u64, 4, 5, 10, 100, 500, 1_000, 2_000, 4_000] { group.bench_function( format!("find segment in {segment_count} segments - binary search"), |b| { diff --git a/src/tree/mod.rs b/src/tree/mod.rs index 05dd439..6f81f9a 100644 --- a/src/tree/mod.rs +++ b/src/tree/mod.rs @@ -630,8 +630,8 @@ impl Tree { let level_manifest = self.levels.read().expect("lock is poisoned"); for level in &level_manifest.levels { - // NOTE: Based on benchmarking, binary search is only worth it after ~4 segments - if level.len() >= 5 { + // NOTE: Based on benchmarking, binary search is only worth it with ~4 segments + if level.len() >= 4 { if let Some(level) = level.as_disjoint() { // TODO: unit test in disjoint level: // [a:5, a:4] [a:3, b:5]