Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bench following old rand update #129

Merged
merged 1 commit into from Aug 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions mla/benches/bench_archive.rs
Expand Up @@ -9,6 +9,7 @@ use mla::Layers;
use mla::{ArchiveReader, ArchiveWriter};
use rand::distributions::{Alphanumeric, Distribution};
use rand::seq::index::sample;
use rand::RngCore;
use rand::SeedableRng;
use rand_chacha::ChaChaRng;
use std::collections::HashMap;
Expand All @@ -34,7 +35,9 @@ pub fn multiple_layers_multiple_block_size(c: &mut Criterion) {
// Setup
// Use a deterministic RNG in tests, for reproductability. DO NOT DO THIS IS IN ANY RELEASED BINARY!
let mut rng = ChaChaRng::seed_from_u64(0);
let key = StaticSecret::new(&mut rng);
let mut bytes = [0u8; 32];
rng.fill_bytes(&mut bytes);
let key = StaticSecret::from(bytes);

let mut group = c.benchmark_group("multiple_layers_multiple_block_size");
group.measurement_time(Duration::from_secs(10));
Expand Down Expand Up @@ -128,7 +131,9 @@ pub fn multiple_compression_quality(c: &mut Criterion) {
fn iter_decompress(iters: u64, size: u64, layers: Layers) -> Duration {
// Prepare data
let mut rng = ChaChaRng::seed_from_u64(0);
let key = StaticSecret::new(&mut rng);
let mut bytes = [0u8; 32];
rng.fill_bytes(&mut bytes);
let key = StaticSecret::from(bytes);
let data: Vec<u8> = Alphanumeric
.sample_iter(&mut rng)
.take((size * iters) as usize)
Expand Down Expand Up @@ -198,7 +203,9 @@ fn build_archive<'a>(
) -> ArchiveReader<'a, io::Cursor<Vec<u8>>> {
// Setup
let mut rng = ChaChaRng::seed_from_u64(0);
let key = StaticSecret::new(&mut rng);
let mut bytes = [0u8; 32];
rng.fill_bytes(&mut bytes);
let key = StaticSecret::from(bytes);
let file = Vec::new();

// Create the initial archive with `iters` files of `size` bytes
Expand Down