Files
Tim Viséeandtimvisee a7442a0dfc Bump Rust edition to 2024 (#6042)
* Bump Rust edition to 2024

* gen is a reserved keyword now

* Remove ref mut on references

* Mark extern C as unsafe

* Wrap unsafe function bodies in unsafe block

* Geo hash implements Copy, don't reference but pass by value instead

* Replace secluded self import with parent

* Update execute_cluster_read_operation with new match semantics

* Fix lifetime issue

* Replace map_or with is_none_or

* set_var is unsafe now

* Reformat
2025-03-21 11:38:56 +01:00

44 lines
999 B
Rust

#[cfg(not(target_os = "windows"))]
mod prof;
use collection::hash_ring::HashRing;
use criterion::{Criterion, criterion_group, criterion_main};
use rand::Rng;
fn hash_ring_bench(c: &mut Criterion) {
let mut group = c.benchmark_group("hash-ring-bench");
let mut ring_raw = HashRing::raw();
let mut ring_fair = HashRing::fair(100);
// add 10 shards to ring
for i in 0..10 {
ring_raw.add(i);
ring_fair.add(i);
}
let mut rnd = rand::rng();
group.bench_function("hash-ring-fair", |b| {
b.iter(|| {
let point = rnd.random_range(0..100000);
let _shard = ring_fair.get(&point);
})
});
group.bench_function("hash-ring-raw", |b| {
b.iter(|| {
let point = rnd.random_range(0..100000);
let _shard = ring_raw.get(&point);
})
});
}
criterion_group! {
name = benches;
config = Criterion::default();
targets = hash_ring_bench,
}
criterion_main!(benches);