Skip to content

Commit 5f228f4

Browse files
committed
bench: set up a Tokio context when dropping the sqlite store
Signed-off-by: Benjamin Bouvier <public@benj.me>
1 parent 93f5562 commit 5f228f4

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

benchmarks/benches/crypto_bench.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ pub fn keys_query(c: &mut Criterion) {
8080
.iter(|| async { machine.mark_request_as_sent(&txn_id, response).await.unwrap() })
8181
});
8282

83+
{
84+
let _guard = runtime.enter();
85+
drop(machine);
86+
}
87+
8388
group.finish()
8489
}
8590

@@ -108,7 +113,10 @@ pub fn keys_claiming(c: &mut Criterion) {
108113
(machine, &runtime, &txn_id)
109114
},
110115
move |(machine, runtime, txn_id)| {
111-
runtime.block_on(machine.mark_request_as_sent(txn_id, response)).unwrap()
116+
runtime.block_on(async {
117+
machine.mark_request_as_sent(txn_id, response).await.unwrap();
118+
drop(machine);
119+
})
112120
},
113121
BatchSize::SmallInput,
114122
)
@@ -130,7 +138,10 @@ pub fn keys_claiming(c: &mut Criterion) {
130138
(machine, &runtime, &txn_id)
131139
},
132140
move |(machine, runtime, txn_id)| {
133-
runtime.block_on(machine.mark_request_as_sent(txn_id, response)).unwrap()
141+
runtime.block_on(async {
142+
machine.mark_request_as_sent(txn_id, response).await.unwrap();
143+
drop(machine)
144+
})
134145
},
135146
BatchSize::SmallInput,
136147
)
@@ -180,6 +191,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
180191
machine.invalidate_group_session(room_id).await.unwrap();
181192
})
182193
});
194+
183195
let dir = tempfile::tempdir().unwrap();
184196
let store = Arc::new(runtime.block_on(SqliteCryptoStore::open(dir.path(), None)).unwrap());
185197

@@ -209,6 +221,11 @@ pub fn room_key_sharing(c: &mut Criterion) {
209221
})
210222
});
211223

224+
{
225+
let _guard = runtime.enter();
226+
drop(machine);
227+
}
228+
212229
group.finish()
213230
}
214231

@@ -249,6 +266,11 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
249266
})
250267
});
251268

269+
{
270+
let _guard = runtime.enter();
271+
drop(machine);
272+
}
273+
252274
group.finish()
253275
}
254276

0 commit comments

Comments
 (0)