forked from rust-phf/rust-phf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now we have benchmarks and a file to run.
- Loading branch information
1 parent
dfecaf1
commit 1919661
Showing
7 changed files
with
68 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use std::time::Instant; | ||
use std::io::prelude::*; | ||
use std::fs::File; | ||
|
||
fn main() { | ||
let pws = phf_bench::get_pws(500_000); | ||
let start = Instant::now(); | ||
let pws_hash = phf_generator::generate_hash(&pws); | ||
println!("Duration: {:?}", Instant::now() - start); | ||
let mut dummy = File::create("/dev/null").expect("opening /dev/null"); | ||
write!(dummy, "{:?}", pws_hash).expect("writing to /dev/null"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#![feature(test, extern_crate_item_prelude)] | ||
extern crate test; | ||
|
||
use xz2::read::XzDecoder; | ||
use std::fs::File; | ||
use std::env; | ||
use std::io::{self, prelude::*}; | ||
use std::path::Path; | ||
|
||
|
||
pub fn get_pws(count: usize) -> Vec<String> { | ||
let input_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap_or(".".into())) | ||
.join("data/rockyou.txt.xz"); | ||
let input = io::BufReader::new(XzDecoder::new(File::open(input_path).unwrap())); | ||
|
||
input.split(b'\n') | ||
.map(|line| line.unwrap()) | ||
.filter_map(|word| String::from_utf8(word).ok()) | ||
.take(count) | ||
.collect() | ||
|
||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use test::Bencher; | ||
use phf_generator::generate_hash; | ||
use super::get_pws; | ||
|
||
const PASSWORD_COUNT: usize = 100_000; | ||
|
||
#[bench] | ||
fn bench_100_000(b: &mut Bencher) { | ||
let pws = get_pws(PASSWORD_COUNT); | ||
b.iter(|| generate_hash(&pws)) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters