mirror of
https://github.com/mailscope/kumomta.git
synced 2026-10-27 16:56:13 +00:00
dkim: add comparitive benchmark against mail-auth
```
signing/sign Simple time: [1.2990 ms 1.3002 ms 1.3015 ms]
thrpt: [2.3581 MiB/s 2.3603 MiB/s 2.3626 MiB/s]
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild
signing/sign Relaxed time: [1.2942 ms 1.2955 ms 1.2968 ms]
thrpt: [2.3665 MiB/s 2.3689 MiB/s 2.3712 MiB/s]
Found 4 outliers among 100 measurements (4.00%)
1 (1.00%) low mild
1 (1.00%) high mild
2 (2.00%) high severe
mail-auth signing/sign Simple
time: [487.97 µs 488.22 µs 488.48 µs]
thrpt: [6.2826 MiB/s 6.2860 MiB/s 6.2892 MiB/s]
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high severe
mail-auth signing/sign Relaxed
time: [494.68 µs 495.68 µs 496.68 µs]
thrpt: [6.1789 MiB/s 6.1913 MiB/s 6.2039 MiB/s]
```
This commit is contained in:
Generated
+1
@@ -665,6 +665,7 @@ dependencies = [
|
||||
"ed25519-dalek",
|
||||
"futures",
|
||||
"indexmap",
|
||||
"mail-auth",
|
||||
"mailparse",
|
||||
"memchr",
|
||||
"nom",
|
||||
|
||||
@@ -29,9 +29,10 @@ tracing = "0.1"
|
||||
trust-dns-resolver = "0.22"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1.25", features = ["macros"] }
|
||||
regex = "1"
|
||||
criterion = "0.3"
|
||||
mail-auth = "0.3"
|
||||
regex = "1"
|
||||
tokio = { version = "1.25", features = ["macros"] }
|
||||
|
||||
[[bench]]
|
||||
name = "sign"
|
||||
|
||||
@@ -3,7 +3,6 @@ use cfdkim::{DkimPrivateKey, ParsedEmail, SignerBuilder};
|
||||
use chrono::TimeZone;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion, SamplingMode, Throughput};
|
||||
use rsa::pkcs1::DecodeRsaPrivateKey;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
||||
let email_text = r#"Subject: subject
|
||||
@@ -50,12 +49,11 @@ aliquet eu tortor nec hendrerit. Aliquam in arcu ac erat venenatis pretium at si
|
||||
ipsum dolor sit a.
|
||||
"#
|
||||
.replace("\n", "\r\n");
|
||||
let email = ParsedEmail::parse_bytes(email_text.as_bytes()).unwrap();
|
||||
|
||||
for canon in [Type::Simple, Type::Relaxed] {
|
||||
let email = ParsedEmail::parse_bytes(email_text.as_bytes()).unwrap();
|
||||
|
||||
let private_key =
|
||||
rsa::RsaPrivateKey::read_pkcs1_pem_file(Path::new("./test/keys/2022.private")).unwrap();
|
||||
rsa::RsaPrivateKey::read_pkcs1_pem_file("./test/keys/2022.private").unwrap();
|
||||
let time = chrono::Utc.with_ymd_and_hms(2021, 1, 1, 0, 0, 1).unwrap();
|
||||
|
||||
let signer = SignerBuilder::new()
|
||||
@@ -78,6 +76,31 @@ ipsum dolor sit a.
|
||||
});
|
||||
group.finish();
|
||||
}
|
||||
|
||||
{
|
||||
use mail_auth::common::crypto::{RsaKey, Sha256};
|
||||
use mail_auth::dkim::{Canonicalization, DkimSigner};
|
||||
|
||||
for canon in [Canonicalization::Simple, Canonicalization::Relaxed] {
|
||||
let key_data = std::fs::read_to_string("./test/keys/2022.private").unwrap();
|
||||
let key = RsaKey::<Sha256>::from_rsa_pem(&key_data).unwrap();
|
||||
|
||||
let signer = DkimSigner::from_key(key)
|
||||
.domain("example.com")
|
||||
.selector("s20")
|
||||
.headers(["From", "Subject"])
|
||||
.header_canonicalization(canon)
|
||||
.body_canonicalization(canon);
|
||||
|
||||
let mut group = c.benchmark_group("mail-auth signing");
|
||||
group.sampling_mode(SamplingMode::Flat);
|
||||
group.throughput(Throughput::Bytes(email_text.len() as u64));
|
||||
group.bench_function(&format!("sign {canon:?}"), |b| {
|
||||
b.iter(|| signer.sign(black_box(email_text.as_bytes())).unwrap())
|
||||
});
|
||||
group.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
|
||||
Reference in New Issue
Block a user