Skip to content

Commit

Permalink
Use getrandom instead of rand for benches
Browse files Browse the repository at this point in the history
The current code didn’t build, and this one includes fewer dependencies
than the full rand set of crates.
  • Loading branch information
linkmauve committed Sep 6, 2021
1 parent 7edf248 commit b031ab7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ thiserror = "1.0"

[dev-dependencies]
bencher = "0.1"
rand = "0.7"
getrandom = "0.2"
walkdir = "2"

[features]
Expand Down
4 changes: 2 additions & 2 deletions benches/read_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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()
Expand Down

0 comments on commit b031ab7

Please sign in to comment.