mirror of
https://github.com/qdrant/qdrant.git
synced 2026-08-06 10:00:58 -05:00
* build(deps): bump rand_distr from 0.5.1 to 0.6.0 Bumps [rand_distr](https://github.com/rust-random/rand_distr) from 0.5.1 to 0.6.0. - [Release notes](https://github.com/rust-random/rand_distr/releases) - [Changelog](https://github.com/rust-random/rand_distr/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-random/rand_distr/compare/0.5.1...0.6.0) --- updated-dependencies: - dependency-name: rand_distr dependency-version: 0.6.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Migrate main code base to rand 0.10 * Migrate tests * Migrate benches --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: timvisee <tim@visee.me>
55 lines
1.5 KiB
Rust
55 lines
1.5 KiB
Rust
use std::hint::black_box;
|
|
|
|
use crc::{CRC_32_ISCSI, Crc};
|
|
use criterion::{Criterion, criterion_group, criterion_main};
|
|
use rand::Rng;
|
|
|
|
pub const CASTAGNOLI: Crc<u32> = Crc::<u32>::new(&CRC_32_ISCSI);
|
|
|
|
pub fn criterion_benchmark_4k(c: &mut Criterion) {
|
|
let mut buffer = [0u8; 8192];
|
|
let mut rng = rand::rng();
|
|
rng.fill_bytes(&mut buffer);
|
|
|
|
let mut group = c.benchmark_group("8k");
|
|
group.throughput(criterion::Throughput::Bytes(8192));
|
|
group.bench_function("crc", |b| {
|
|
b.iter(|| {
|
|
let mut digest = CASTAGNOLI.digest();
|
|
digest.update(&buffer);
|
|
black_box(digest.finalize());
|
|
})
|
|
});
|
|
|
|
group.bench_function("crc32c", |b| {
|
|
b.iter(|| {
|
|
black_box(crc32c::crc32c(&buffer));
|
|
})
|
|
});
|
|
}
|
|
|
|
pub fn criterion_benchmark_1024k(c: &mut Criterion) {
|
|
let mut buffer = [0u8; 1048576];
|
|
let mut rng = rand::rng();
|
|
rng.fill_bytes(&mut buffer);
|
|
|
|
let mut group = c.benchmark_group("1M");
|
|
group.throughput(criterion::Throughput::Bytes(1048576));
|
|
group.bench_function("crc", |b| {
|
|
b.iter(|| {
|
|
let mut digest = CASTAGNOLI.digest();
|
|
digest.update(&buffer);
|
|
black_box(digest.finalize());
|
|
})
|
|
});
|
|
|
|
group.bench_function("crc32c", |b| {
|
|
b.iter(|| {
|
|
black_box(crc32c::crc32c(&buffer));
|
|
})
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, criterion_benchmark_4k, criterion_benchmark_1024k);
|
|
criterion_main!(benches);
|