forked from cloudflare/boringtun
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mybench.rs
34 lines (30 loc) · 1.06 KB
/
mybench.rs
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
31
32
33
34
// Copyright (c) 2019 Quentin Kniep. All rights reserved.
// SPDX-License-Identifier: BSD-3-Clause
use boringtun::noise::tests::tests::{wireguard_handshake_1, wireguard_handshake_n};
use criterion::{black_box, criterion_group, criterion_main, Criterion, ParameterizedBenchmark};
use std::time::Duration;
fn bench_handshake(c: &mut Criterion) {
c.bench(
"Level 3",
ParameterizedBenchmark::new(
"NPackets",
|b, param| b.iter_custom(|iters| {
let mut total_time = Duration::default();
for _ in 0..iters {
total_time += black_box(wireguard_handshake_n(*param));
}
total_time
}),
vec![1u32, 2000u32],
)
);
c.bench_function("Handshake", |b| b.iter_custom(|iters| {
let mut total_time = Duration::default();
for _ in 0..iters {
total_time += black_box(wireguard_handshake_1());
}
total_time
}));
}
criterion_group!(benches, bench_handshake);
criterion_main!(benches);