Merge pull request #251 from linkmauve/use-getrandom

Use getrandom instead of rand for benches
This commit is contained in:
Alexander Zaitsev 2022-01-23 13:34:09 +03:00 committed by GitHub
commit 82cb917883
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -20,7 +20,7 @@ thiserror = "1.0.7"
[dev-dependencies]
bencher = "0.1"
rand = "0.8"
getrandom = "0.2"
walkdir = "2"
[features]

View file

@ -3,7 +3,7 @@ use bencher::{benchmark_group, benchmark_main};
use std::io::{Cursor, Read, Write};
use bencher::Bencher;
use rand::Rng;
use getrandom::getrandom;
use zip::{ZipArchive, ZipWriter};
fn generate_random_archive(size: usize) -> Vec<u8> {
@ -14,7 +14,7 @@ fn generate_random_archive(size: usize) -> Vec<u8> {
writer.start_file("random.dat", options).unwrap();
let mut bytes = vec![0u8; size];
rand::thread_rng().fill_bytes(&mut bytes);
getrandom(&mut bytes).unwrap();
writer.write_all(&bytes).unwrap();
writer.finish().unwrap().into_inner()