aboutsummaryrefslogtreecommitdiff
path: root/benches
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2022-10-19 21:28:36 +0200
committerAndreas Grois <andi@grois.info>2022-10-19 21:28:36 +0200
commitbc9bd89c17dc41d9b1434866ac2d522070f46597 (patch)
tree1c9a57c6be182ac457c4d91f37e69122effb3c31 /benches
parent308e4ec700b9047836876b4581d24bfe7b1a7e2d (diff)
Make some asserts debug_asserts. Add more benches.
Now that work on performance has started, accurate readings are important.
Diffstat (limited to 'benches')
-rw-r--r--benches/hashrate.rs75
1 files changed, 70 insertions, 5 deletions
diff --git a/benches/hashrate.rs b/benches/hashrate.rs
index 2bb0f97..9691410 100644
--- a/benches/hashrate.rs
+++ b/benches/hashrate.rs
@@ -57,7 +57,7 @@ impl HasherList for MockHashes {
type Pwm<'a> = PasswordMaker<'a, MockHashes>;
-fn criterion_bench_32bit(c: &mut Criterion) {
+fn criterion_bench_32bytes(c: &mut Criterion) {
let pwm = Pwm::new(
HashAlgorithm::Sha256,
passwordmaker_rs::UseLeetWhenGenerating::NotAtAll,
@@ -76,7 +76,45 @@ fn criterion_bench_32bit(c: &mut Criterion) {
}));
}
-fn criterion_bench_16bit(c: &mut Criterion) {
+fn criterion_bench_32bytes_extreme(c: &mut Criterion) {
+ let pwm = Pwm::new(
+ HashAlgorithm::Sha256,
+ passwordmaker_rs::UseLeetWhenGenerating::NotAtAll,
+ "XY",
+ "",
+ "",
+ 150,
+ "",
+ ""
+ ).unwrap();
+ c.bench_function("32 bytes extreme", |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_20bytes(c: &mut Criterion) {
+ let pwm = Pwm::new(
+ HashAlgorithm::Ripemd160,
+ passwordmaker_rs::UseLeetWhenGenerating::NotAtAll,
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={}|[]\\:\";'<>?,./",
+ "",
+ "",
+ 150,
+ "",
+ ""
+ ).unwrap();
+ c.bench_function("20 bytes", |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(c: &mut Criterion) {
let pwm = Pwm::new(
HashAlgorithm::Md5,
passwordmaker_rs::UseLeetWhenGenerating::NotAtAll,
@@ -95,7 +133,26 @@ fn criterion_bench_16bit(c: &mut Criterion) {
}));
}
-fn criterion_bench_16bit_post_leet(c: &mut Criterion) {
+fn criterion_bench_16bytes_extreme(c: &mut Criterion) {
+ let pwm = Pwm::new(
+ HashAlgorithm::Md5,
+ passwordmaker_rs::UseLeetWhenGenerating::NotAtAll,
+ "XY",
+ "",
+ "",
+ 150,
+ "",
+ ""
+ ).unwrap();
+ c.bench_function("16 bytes extreme", |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_post_leet(c: &mut Criterion) {
let pwm = Pwm::new(
HashAlgorithm::Md5,
passwordmaker_rs::UseLeetWhenGenerating::After { level: LeetLevel::Six },
@@ -114,7 +171,7 @@ fn criterion_bench_16bit_post_leet(c: &mut Criterion) {
}));
}
-fn criterion_bench_16bit_pre_leet(c: &mut Criterion) {
+fn criterion_bench_16bytes_pre_leet(c: &mut Criterion) {
let pwm = Pwm::new(
HashAlgorithm::Md5,
passwordmaker_rs::UseLeetWhenGenerating::Before { level: LeetLevel::Six },
@@ -133,5 +190,13 @@ fn criterion_bench_16bit_pre_leet(c: &mut Criterion) {
}));
}
-criterion_group!(benches, criterion_bench_32bit, criterion_bench_16bit, criterion_bench_16bit_post_leet, criterion_bench_16bit_pre_leet);
+criterion_group!(benches,
+ criterion_bench_32bytes,
+ criterion_bench_32bytes_extreme,
+ criterion_bench_20bytes,
+ criterion_bench_16bytes,
+ criterion_bench_16bytes_extreme,
+ criterion_bench_16bytes_post_leet,
+ criterion_bench_16bytes_pre_leet
+);
criterion_main!(benches);