Skip to content

Commit 46b0113

Browse files
committed
tests: Rename some crypto benchmarks
This is mostly due to codspeed not showing the group name, so we're repeating this info in the benchmark ID.
1 parent 09eff8c commit 46b0113

File tree

1 file changed

+78
-56
lines changed

1 file changed

+78
-56
lines changed

benchmarks/benches/crypto_bench.rs

Lines changed: 78 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,14 @@ pub fn keys_query(c: &mut Criterion) {
5959

6060
// Benchmark memory store.
6161

62-
group.bench_with_input(BenchmarkId::new("memory store", &name), &response, |b, response| {
63-
b.to_async(&runtime)
64-
.iter(|| async { machine.mark_request_as_sent(&txn_id, response).await.unwrap() })
65-
});
62+
group.bench_with_input(
63+
BenchmarkId::new("Device keys query [memory]", &name),
64+
&response,
65+
|b, response| {
66+
b.to_async(&runtime)
67+
.iter(|| async { machine.mark_request_as_sent(&txn_id, response).await.unwrap() })
68+
},
69+
);
6670

6771
// Benchmark sqlite store.
6872

@@ -72,10 +76,14 @@ pub fn keys_query(c: &mut Criterion) {
7276
.block_on(OlmMachine::with_store(alice_id(), alice_device_id(), store, None))
7377
.unwrap();
7478

75-
group.bench_with_input(BenchmarkId::new("sqlite store", &name), &response, |b, response| {
76-
b.to_async(&runtime)
77-
.iter(|| async { machine.mark_request_as_sent(&txn_id, response).await.unwrap() })
78-
});
79+
group.bench_with_input(
80+
BenchmarkId::new("Device keys query [SQLite]", &name),
81+
&response,
82+
|b, response| {
83+
b.to_async(&runtime)
84+
.iter(|| async { machine.mark_request_as_sent(&txn_id, response).await.unwrap() })
85+
},
86+
);
7987

8088
{
8189
let _guard = runtime.enter();
@@ -102,51 +110,65 @@ pub fn keys_claiming(c: &mut Criterion) {
102110

103111
let name = format!("{count} one-time keys");
104112

105-
group.bench_with_input(BenchmarkId::new("memory store", &name), &response, |b, response| {
106-
b.iter_batched(
107-
|| {
108-
let machine = runtime.block_on(OlmMachine::new(alice_id(), alice_device_id()));
109-
runtime
110-
.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response))
111-
.unwrap();
112-
(machine, &runtime, &txn_id)
113-
},
114-
move |(machine, runtime, txn_id)| {
115-
runtime.block_on(async {
116-
machine.mark_request_as_sent(txn_id, response).await.unwrap();
113+
group.bench_with_input(
114+
BenchmarkId::new("One-time keys claiming [memory]", &name),
115+
&response,
116+
|b, response| {
117+
b.iter_batched(
118+
|| {
119+
let machine = runtime.block_on(OlmMachine::new(alice_id(), alice_device_id()));
120+
runtime
121+
.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response))
122+
.unwrap();
123+
(machine, &runtime, &txn_id)
124+
},
125+
move |(machine, runtime, txn_id)| {
126+
runtime.block_on(async {
127+
machine.mark_request_as_sent(txn_id, response).await.unwrap();
128+
drop(machine);
129+
})
130+
},
131+
criterion::BatchSize::SmallInput,
132+
)
133+
},
134+
);
135+
136+
group.bench_with_input(
137+
BenchmarkId::new("One-time keys claiming [SQLite]", &name),
138+
&response,
139+
|b, response| {
140+
b.iter_batched(
141+
|| {
142+
let dir = tempfile::tempdir().unwrap();
143+
let store = Arc::new(
144+
runtime.block_on(SqliteCryptoStore::open(dir.path(), None)).unwrap(),
145+
);
146+
147+
let machine = runtime
148+
.block_on(OlmMachine::with_store(
149+
alice_id(),
150+
alice_device_id(),
151+
store,
152+
None,
153+
))
154+
.unwrap();
155+
runtime
156+
.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response))
157+
.unwrap();
158+
(machine, &runtime, &txn_id)
159+
},
160+
move |(machine, runtime, txn_id)| {
161+
runtime.block_on(async {
162+
machine.mark_request_as_sent(txn_id, response).await.unwrap();
163+
});
164+
165+
let _ = runtime.enter();
117166
drop(machine);
118-
})
119-
},
120-
criterion::BatchSize::SmallInput,
121-
)
122-
});
123-
124-
group.bench_with_input(BenchmarkId::new("sqlite store", &name), &response, |b, response| {
125-
b.iter_batched(
126-
|| {
127-
let dir = tempfile::tempdir().unwrap();
128-
let store =
129-
Arc::new(runtime.block_on(SqliteCryptoStore::open(dir.path(), None)).unwrap());
130-
131-
let machine = runtime
132-
.block_on(OlmMachine::with_store(alice_id(), alice_device_id(), store, None))
133-
.unwrap();
134-
runtime
135-
.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response))
136-
.unwrap();
137-
(machine, &runtime, &txn_id)
138-
},
139-
move |(machine, runtime, txn_id)| {
140-
runtime.block_on(async {
141-
machine.mark_request_as_sent(txn_id, response).await.unwrap();
142-
});
143-
144-
let _ = runtime.enter();
145-
drop(machine);
146-
},
147-
criterion::BatchSize::SmallInput,
148-
)
149-
});
167+
},
168+
criterion::BatchSize::SmallInput,
169+
)
170+
},
171+
);
150172

151173
group.finish()
152174
}
@@ -174,7 +196,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
174196

175197
// Benchmark memory store.
176198

177-
group.bench_function(BenchmarkId::new("memory store", &name), |b| {
199+
group.bench_function(BenchmarkId::new("Room key sharing [memory]", &name), |b| {
178200
b.to_async(&runtime).iter(|| async {
179201
let requests = machine
180202
.share_room_key(
@@ -206,7 +228,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
206228
runtime.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response)).unwrap();
207229
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();
208230

209-
group.bench_function(BenchmarkId::new("sqlite store", &name), |b| {
231+
group.bench_function(BenchmarkId::new("Room key sharing [SQLite]", &name), |b| {
210232
b.to_async(&runtime).iter(|| async {
211233
let requests = machine
212234
.share_room_key(
@@ -254,7 +276,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
254276

255277
// Benchmark memory store.
256278

257-
group.bench_function(BenchmarkId::new("memory store", &name), |b| {
279+
group.bench_function(BenchmarkId::new("Devices collecting [memory]", &name), |b| {
258280
b.to_async(&runtime).iter_with_large_drop(|| async {
259281
machine.get_missing_sessions(users.iter().map(Deref::deref)).await.unwrap()
260282
})
@@ -271,7 +293,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
271293

272294
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();
273295

274-
group.bench_function(BenchmarkId::new("sqlite store", &name), |b| {
296+
group.bench_function(BenchmarkId::new("Devices collecting [SQLite]", &name), |b| {
275297
b.to_async(&runtime).iter(|| async {
276298
machine.get_missing_sessions(users.iter().map(Deref::deref)).await.unwrap()
277299
})

0 commit comments

Comments
 (0)