Skip to content

Commit

Permalink
fix: bench
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Oct 21, 2024
1 parent e777808 commit 0a7ee52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion benches/level_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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| {
Expand Down
4 changes: 2 additions & 2 deletions src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 0a7ee52

Please sign in to comment.