File: verify_message.rs

package info (click to toggle)
rust-sequoia-openpgp 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 9,372 kB
  • sloc: sh: 6; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 854 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use criterion::{criterion_group, BenchmarkId, Criterion, Throughput};

use sequoia_openpgp as openpgp;
use openpgp::cert::Cert;

use crate::common::{decrypt, encrypt};

fn verify(bytes: &[u8], sender: &Cert) {
    let mut sink = Vec::new();
    decrypt::verify(&mut sink, bytes, sender).unwrap();
}

fn bench_verify(c: &mut Criterion) {
    let mut group = c.benchmark_group("verify message");

    encrypt::messages()
        .for_each(|m| {
            let signed = encrypt::sign(m, encrypt::sender()).unwrap();
            group.throughput(Throughput::Bytes(signed.len() as u64));
            group.bench_with_input(
                BenchmarkId::new("verify", m.len()),
                &signed,
                |b, s| b.iter(|| verify(s, encrypt::sender())),
            );
        });

    group.finish();
}

criterion_group!(benches, bench_verify);