Skip to content

Commit

Permalink
Fix bench following old rand update
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Aug 19, 2022
1 parent 7280b4f commit 779590d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mla/benches/bench_archive.rs
Expand Up @@ -11,6 +11,7 @@ use rand::distributions::{Alphanumeric, Distribution};
use rand::seq::index::sample;
use rand::SeedableRng;
use rand_chacha::ChaChaRng;
use rand::RngCore;
use std::collections::HashMap;
use std::io::{self, Cursor, Read};
use std::time::{Duration, Instant};
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

0 comments on commit 779590d

Please sign in to comment.