Debian Codegraph @

third_party/rust/mls-rs/benches/group_commit.rs

raw
1 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 // Copyright by contributors to this project.
3 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
4
5 use criterion::{BatchSize, BenchmarkId, Criterion};
6 use mls_rs::test_utils::benchmarks::{load_group_states, BENCH_CIPHER_SUITE};
7
8 fn bench(c: &mut Criterion) {
9 let group_states = load_group_states();
10
11 let mut bench_group = c.benchmark_group("group_commit");
12
13 for (i, group_states) in group_states.into_iter().enumerate() {
14 bench_group.bench_with_input(
15 BenchmarkId::new(format!("{BENCH_CIPHER_SUITE:?}"), i),
16 &i,
17 |b, _| {
18 b.iter_batched_ref(
19 || group_states.sender.clone(),
20 move |sender| sender.commit(vec![]).unwrap(),
21 BatchSize::SmallInput,
22 )
23 },
24 );
25 }
26 }
27
28 criterion::criterion_group!(benches, bench);
29 criterion::criterion_main!(benches);