Files
vector/lib/segment/benches/in_memory_id_tracker.rs
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

36 lines
1010 B
Rust

use std::time::Instant;
use common::types::PointOffsetType;
use criterion::{Criterion, criterion_group, criterion_main};
use rand::Rng;
use segment::id_tracker::IdTracker;
use segment::id_tracker::in_memory_id_tracker::InMemoryIdTracker;
use segment::types::ExtendedPointId;
fn benchmark(c: &mut Criterion) {
c.bench_function("idtracker", |b| {
b.iter_custom(|i| {
let mut id_tracker = InMemoryIdTracker::new();
let mut rand = rand::rng();
let ids: Vec<i32> = (0..i).map(|_| rand.random_range(0..100_000)).collect();
let start = Instant::now();
for external in 0..i {
id_tracker
.set_link(
ExtendedPointId::NumId(external),
ids[external as usize] as PointOffsetType,
)
.unwrap();
}
start.elapsed()
})
});
}
criterion_group!(benches, benchmark);
criterion_main!(benches);