Debian Codegraph @

third_party/rust/mls-rs/benches/group_receive_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 let mut bench_group = c.benchmark_group("group_receive_commit");
11
12 for (i, mut group_states) in group_states.into_iter().enumerate() {
13 bench_group.bench_with_input(
14 BenchmarkId::new(format!("{BENCH_CIPHER_SUITE:?}"), i),
15 &i,
16 |b, _| {
17 b.iter_batched_ref(
18 || {
19 let commit = group_states.sender.commit(Vec::new()).unwrap();
20 group_states.sender.clear_pending_commit();
21 (commit, group_states.receiver.clone())
22 },
23 move |(commit, receiver)| {
24 receiver
25 .process_incoming_message(commit.commit_message.clone())
26 .unwrap();
27 },
28 BatchSize::SmallInput,
29 )
30 },
31 );
32 }
33
34 bench_group.finish();
35 }
36
37 criterion::criterion_group!(benches, bench);
38 criterion::criterion_main!(benches);