Skip to content

Commit

Permalink
test: Add massive benchmark for prefix/postfix
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Dec 23, 2023
1 parent 617b25e commit b0bf31a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions benches/criterion_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,45 @@ fn trie_benchmark(c: &mut Criterion) {
}
});
});

c.bench_function("trie_massive_prefixes_match", |b| {
let mut t = ptrie::Trie::new();
let keys = generate_keys();
for key in &keys {
t.insert(black_box(key.bytes()), black_box(key.clone()));
}
b.iter(|| {
for key in &keys {
assert!(!t.find_prefixes(black_box(key.bytes())).is_empty());
}
});
});

c.bench_function("trie_massive_longest_prefixes_match", |b| {
let mut t = ptrie::Trie::new();
let keys = generate_keys();
for key in &keys {
t.insert(black_box(key.bytes()), black_box(key.clone()));
}
b.iter(|| {
for key in &keys {
assert!(t.find_longest_prefix(black_box(key.bytes())).is_some());
}
});
});

c.bench_function("trie_massive_postfixes_match", |b| {
let mut t = ptrie::Trie::new();
let keys = generate_keys();
for key in &keys {
t.insert(black_box(key.bytes()), black_box(key.clone()));
}
b.iter(|| {
for key in &keys {
assert!(!t.find_postfixes(black_box(key.bytes())).is_empty());
}
});
});
}

fn hashmap_benchmark(c: &mut Criterion) {
Expand Down

0 comments on commit b0bf31a

Please sign in to comment.