-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathproposal.rs
98 lines (92 loc) · 3.88 KB
/
proposal.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use criterion::{
async_executor::AsyncStdExecutor as FuturesExecutor, black_box, criterion_group, criterion_main, BatchSize,
Criterion,
};
use crate::utils::*;
#[path = "utils/mod.rs"]
mod utils;
fn proposal_add_bench(c: &mut Criterion) {
let mut group = c.benchmark_group("Add proposal f(group size)");
for (case, ciphersuite, credential, in_memory) in MlsTestCase::values() {
for i in (GROUP_RANGE).step_by(GROUP_STEP) {
group.bench_with_input(case.benchmark_id(i + 1, in_memory), &i, |b, i| {
b.to_async(FuturesExecutor).iter_batched(
|| {
async_std::task::block_on(async {
let (central, id, ..) =
setup_mls_and_add_clients(ciphersuite, credential.as_ref(), in_memory, *i).await;
let (kp, ..) = rand_key_package(ciphersuite).await;
(central, id, kp)
})
},
|(central, id, kp)| async move {
let context = central.new_transaction().await.unwrap();
black_box(context.new_add_proposal(&id, kp).await.unwrap());
context.finish().await.unwrap();
},
BatchSize::SmallInput,
)
});
}
}
group.finish();
}
fn proposal_remove_bench(c: &mut Criterion) {
let mut group = c.benchmark_group("Remove proposal f(group size)");
for (case, ciphersuite, credential, in_memory) in MlsTestCase::values() {
for i in (GROUP_RANGE).step_by(GROUP_STEP) {
group.bench_with_input(case.benchmark_id(i + 1, in_memory), &i, |b, i| {
b.to_async(FuturesExecutor).iter_batched(
|| {
async_std::task::block_on(async {
let (central, id, client_ids, ..) =
setup_mls_and_add_clients(ciphersuite, credential.as_ref(), in_memory, *i).await;
(central, id, client_ids.first().unwrap().clone())
})
},
|(central, id, client_id)| async move {
let context = central.new_transaction().await.unwrap();
black_box(context.new_remove_proposal(&id, client_id).await.unwrap());
context.finish().await.unwrap();
},
BatchSize::SmallInput,
)
});
}
}
group.finish();
}
fn proposal_update_bench(c: &mut Criterion) {
let mut group = c.benchmark_group("Update proposal f(group size)");
for (case, ciphersuite, credential, in_memory) in MlsTestCase::values() {
for i in (GROUP_RANGE).step_by(GROUP_STEP) {
group.bench_with_input(case.benchmark_id(i + 1, in_memory), &i, |b, i| {
b.to_async(FuturesExecutor).iter_batched(
|| {
async_std::task::block_on(async {
let (central, id, ..) =
setup_mls_and_add_clients(ciphersuite, credential.as_ref(), in_memory, *i).await;
(central, id)
})
},
|(central, id)| async move {
let context = central.new_transaction().await.unwrap();
black_box(context.new_update_proposal(&id).await.unwrap());
context.finish().await.unwrap();
},
BatchSize::SmallInput,
)
});
}
}
group.finish();
}
criterion_group!(
name = proposal;
config = criterion();
targets =
proposal_add_bench,
proposal_remove_bench,
proposal_update_bench,
);
criterion_main!(proposal);