Skip to content

Commit 66a8543

Browse files
committed
most interesting hash_str test
1 parent 369b324 commit 66a8543

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

benches/creation.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@ fn criterion_benchmark(c: &mut Criterion) {
6565
});
6666
});
6767

68+
let s = raft.clone();
69+
let precomputed_host = hash_str::HashStrHost::new();
70+
let mut precomputed_cache = hash_str::HashStrCache::new();
71+
let precomputed: Vec<_> = s
72+
.iter()
73+
.map(|s| precomputed_cache.intern_with(&precomputed_host, s))
74+
.collect();
75+
c.bench_function("single raft hash_str local precomputed", move |b| {
76+
let mut cache = hash_str::HashStrCache::new();
77+
b.iter(|| {
78+
cache.clear();
79+
for s in precomputed.iter().cycle().take(100_000) {
80+
black_box(cache.cache(s));
81+
}
82+
});
83+
});
84+
6885
let s = raft.clone();
6986
c.bench_function("single raft string-interner", move |b| {
7087
b.iter(|| {

0 commit comments

Comments
 (0)