From ea6789e5b33540270f5de3edb54264e6892fad73 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Thu, 20 Oct 2022 21:42:07 +0200 Subject: Group Benchmarks, and make parameters more sane. The previous parameters for benchmarks were based on gut-feeling. Now each hash-length has 3 benchmarks: - Typical is a typical user input - Max Divisions is a full generate_password_part run - Worst Case is the worst user input possible: Base 2. --- benches/leet.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 benches/leet.rs (limited to 'benches/leet.rs') diff --git a/benches/leet.rs b/benches/leet.rs new file mode 100644 index 0000000..ef3b649 --- /dev/null +++ b/benches/leet.rs @@ -0,0 +1,49 @@ +mod mock_hashers; + +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use passwordmaker_rs::{HashAlgorithm, LeetLevel}; +use mock_hashers::Pwm; + +fn criterion_bench_16bytes_post_leet(c: &mut Criterion) { + let pwm = Pwm::new( + HashAlgorithm::Md5, + passwordmaker_rs::UseLeetWhenGenerating::After { level: LeetLevel::Six }, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./", + "", + "", + 150, + "", + "" + ).unwrap(); + c.bench_function("16 bytes with post_leet", |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_pre_leet(c: &mut Criterion) { + let pwm = Pwm::new( + HashAlgorithm::Md5, + passwordmaker_rs::UseLeetWhenGenerating::Before { level: LeetLevel::Six }, + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./", + "", + "", + 150, + "", + "" + ).unwrap(); + c.bench_function("16 bytes with pre_leet", |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_post_leet, + criterion_bench_16bytes_pre_leet +); +criterion_main!(benches); -- cgit v1.2.3