Files
qdrant/lib/gridstore/benches/random_data_bench.rs
Andrey Vasnetsov 03c0fa2cf7 Universal IO: gridstore pages (#8223)
* [manunal] Gridstore page use universal IO

* fmt

* Apply review feedback for universal IO gridstore pages (#8230)

* Apply review feedback from PR #8223

- Use `super::Result` import in mmap.rs instead of fully-qualified `crate::universal_io::Result`
- Restructure ValuePointer destructuring in get_value and delete_value to
  first match Some(pointer), then destructure separately

* Replace Either<E, GridstoreError> with E: From<GridstoreError> in Gridstore::iter

Use a trait bound instead of Either to combine callback and gridstore
errors, allowing `?` to work directly on GridstoreError. This simplifies
callers by removing Either matching and io::Error conversion workarounds.

---------

Co-authored-by: qdrant-claw <qdrant-claw@users.noreply.github.com>

---------

Co-authored-by: qdrant-claw <qdrant-claw@users.noreply.github.com>
2026-02-25 19:46:00 +01:00

38 lines
1.3 KiB
Rust

use common::counter::hardware_counter::HardwareCounterCell;
use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
use gridstore::fixtures::{empty_storage, random_payload};
/// sized similarly to the real dataset for a fair comparison
const PAYLOAD_COUNT: u32 = 100_000;
pub fn random_data_bench(c: &mut Criterion) {
let (_dir, mut storage) = empty_storage();
let mut rng = rand::rng();
c.bench_function("write random payload", |b| {
let hw_counter = HardwareCounterCell::new();
let hw_counter_ref = hw_counter.ref_payload_io_write_counter();
b.iter_batched_ref(
|| random_payload(&mut rng, 2),
|payload| {
for i in 0..PAYLOAD_COUNT {
storage.put_value(i, payload, hw_counter_ref).unwrap();
}
},
BatchSize::SmallInput,
)
});
c.bench_function("read random payload", |b| {
let hw_counter = HardwareCounterCell::new();
b.iter(|| {
for i in 0..PAYLOAD_COUNT {
let res = storage.get_value::<false>(i, &hw_counter).unwrap();
assert!(res.is_some());
}
});
});
}
criterion_group!(benches, random_data_bench);
criterion_main!(benches);