Skip to content

Commit

Permalink
add simple test for timing checks
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Jul 12, 2019
1 parent f6407a0 commit ecb9fd5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions phf_generator/Cargo.toml
Expand Up @@ -10,3 +10,9 @@ edition = "2018"
[dependencies]
rand = { version = "0.7", features = ["small_rng"] }
phf_shared = { version = "0.7.24", path = "../phf_shared" }
# for stable black_box()
criterion = { version = "0.2", optional = true }

[[bin]]
name = "gen_hash_test"
required-features = ["criterion"]
18 changes: 18 additions & 0 deletions phf_generator/src/bin/gen_hash_test.rs
@@ -0,0 +1,18 @@
use criterion::*;

use rand::distributions::Alphanumeric;
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};

use phf_generator::generate_hash;

fn gen_vec(len: usize) -> Vec<String> {
let mut rng = SmallRng::seed_from_u64(0xAAAAAAAAAAAAAAAA).sample_iter(Alphanumeric);

(0 .. len).map(move |_| rng.by_ref().take(64).collect::<String>()).collect()
}

fn main() {
let data = black_box(gen_vec(1_000_000));
black_box(generate_hash(&data));
}

0 comments on commit ecb9fd5

Please sign in to comment.