summaryrefslogtreecommitdiffstats
path: root/openpgp/benches/merge_cert.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2021-08-27 12:02:51 +0200
committerJustus Winter <justus@sequoia-pgp.org>2021-08-27 12:11:07 +0200
commit214324aab97df7b6d8fb3193e204122bb61aee32 (patch)
tree8cff45b882655c3b889ccb22bd79c2547b83a924 /openpgp/benches/merge_cert.rs
parentcacf32aed3eacb65b11be0adc1b4f290a1af8ec8 (diff)
openpgp: De-duplicate cert components before checking signatures.
- Before we do anything, we'll order and deduplicate the components. If two components are the same, they will be merged, and their signatures will also be deduplicated. This improves the performance considerably when we update a certificate, because the certificates will be most likely almost identical, and we avoid about half of the signature verifications. - And indeed, benchmarking shows a 45% performance improvement on a typical cert. - Fixes #644.
Diffstat (limited to 'openpgp/benches/merge_cert.rs')
-rw-r--r--openpgp/benches/merge_cert.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/openpgp/benches/merge_cert.rs b/openpgp/benches/merge_cert.rs
new file mode 100644
index 00000000..a628e60a
--- /dev/null
+++ b/openpgp/benches/merge_cert.rs
@@ -0,0 +1,20 @@
+use criterion::{
+ criterion_group, Criterion,
+};
+
+use sequoia_openpgp as openpgp;
+use openpgp::cert::Cert;
+use openpgp::parse::Parse;
+
+/// Benchmark merging a typical cert with itself.
+fn bench_merge_certs(c: &mut Criterion) {
+ let mut group = c.benchmark_group("merge cert with itself");
+ let neal = Cert::from_bytes(include_bytes!("../tests/data/keys/neal.pgp"))
+ .unwrap();
+ group.bench_function("neal.pgp", |b| b.iter(|| {
+ neal.clone().merge_public(neal.clone()).unwrap();
+ }));
+ group.finish();
+}
+
+criterion_group!(benches, bench_merge_certs);