diff options
author | Andreas Grois <andi@grois.info> | 2022-10-20 21:45:43 +0200 |
---|---|---|
committer | Andreas Grois <andi@grois.info> | 2022-10-20 21:45:43 +0200 |
commit | e484af8f3c683e81d6445a4d66972ca1fa6897a6 (patch) | |
tree | f225e0c0228a576efc7d3b7974ccc7e8526f258b /benches/hashrate_16.rs | |
parent | be766f81b6985b9df3da39d78fb19ec4383075c7 (diff) | |
parent | ea6789e5b33540270f5de3edb54264e6892fad73 (diff) |
Merge branch 'main' into feature/heap-allocation-free-base-conversion
Diffstat (limited to 'benches/hashrate_16.rs')
-rw-r--r-- | benches/hashrate_16.rs | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/benches/hashrate_16.rs b/benches/hashrate_16.rs new file mode 100644 index 0000000..20602d0 --- /dev/null +++ b/benches/hashrate_16.rs @@ -0,0 +1,69 @@ +mod mock_hashers; + +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use passwordmaker_rs::HashAlgorithm; +use mock_hashers::Pwm; + +fn criterion_bench_16bytes_typical(c: &mut Criterion) { + let pwm = Pwm::new( + HashAlgorithm::Md5, + passwordmaker_rs::UseLeetWhenGenerating::NotAtAll, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./", + "", + "", + 12, + "", + "" + ).unwrap(); + c.bench_function("16 bytes typical", |b| b.iter(|| { + pwm.generate( + black_box("This is a long string. With many, many characters. For no particular reason.".to_owned()), + black_box("And another relatively long string for no reason other than it being long.".to_owned()) + ) + })); +} + +fn criterion_bench_16bytes_full_divide(c: &mut Criterion) { + let pwm = Pwm::new( + HashAlgorithm::Md5, + passwordmaker_rs::UseLeetWhenGenerating::NotAtAll, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./", + "", + "", + 20, + "", + "" + ).unwrap(); + c.bench_function("16 bytes full divide", |b| b.iter(|| { + pwm.generate( + black_box("This is a long string. With many, many characters. For no particular reason.".to_owned()), + black_box("And another relatively long string for no reason other than it being long.".to_owned()) + ) + })); +} + +fn criterion_bench_16bytes_worst_case(c: &mut Criterion) { + let pwm = Pwm::new( + HashAlgorithm::Md5, + passwordmaker_rs::UseLeetWhenGenerating::NotAtAll, + "XY", + "", + "", + 128, + "", + "" + ).unwrap(); + c.bench_function("16 bytes worst case", |b| b.iter(|| { + pwm.generate( + black_box("This is a long string. With many, many characters. For no particular reason.".to_owned()), + black_box("And another relatively long string for no reason other than it being long.".to_owned()) + ) + })); +} + +criterion_group!(benches, + criterion_bench_16bytes_typical, + criterion_bench_16bytes_full_divide, + criterion_bench_16bytes_worst_case, +); +criterion_main!(benches); |