make Sled store benchmarks use SledStore again

This commit is contained in:
Benjamin Kampmann
2022-03-01 11:52:52 +01:00
parent 33be17d5d0
commit ca18fca20b
2 changed files with 16 additions and 8 deletions

View File

@@ -64,6 +64,7 @@ http = "0.2.4"
indoc = "1.0.3"
matches = "0.1.8"
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }
matrix-sdk-sled = { version = "0.1.0", path = "../matrix-sdk-sled", features = ["encryption"] }
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
criterion = { version = "0.3.4", features = [

View File

@@ -15,6 +15,7 @@ use ruma::{
};
use serde_json::Value;
use tokio::runtime::Builder;
use matrix_sdk_sled::CryptoStore as SledCryptoStore;
fn alice_id() -> &'static UserId {
user_id!("@alice:example.org")
@@ -67,8 +68,9 @@ pub fn keys_query(c: &mut Criterion) {
.iter(|| async { machine.mark_request_as_sent(&txn_id, response).await.unwrap() })
});
let _dir = tempfile::tempdir().unwrap();
let machine = OlmMachine::new(alice_id(), alice_device_id());
let dir = tempfile::tempdir().unwrap();
let store = Box::new(SledCryptoStore::open_with_passphrase(dir, None).unwrap());
let machine = runtime.block_on(OlmMachine::new_with_store(alice_id().into(), alice_device_id().into(), store)).unwrap();
group.bench_with_input(BenchmarkId::new("sled store", &name), &response, |b, response| {
b.to_async(&runtime)
@@ -112,8 +114,10 @@ pub fn keys_claiming(c: &mut Criterion) {
group.bench_with_input(BenchmarkId::new("sled store", &name), &response, |b, response| {
b.iter_batched(
|| {
let _dir = tempfile::tempdir().unwrap();
let machine = OlmMachine::new(alice_id(), alice_device_id());
let dir = tempfile::tempdir().unwrap();
let store = Box::new(SledCryptoStore::open_with_passphrase(dir, None).unwrap());
let machine = runtime.block_on(OlmMachine::new_with_store(alice_id().into(), alice_device_id().into(), store)).unwrap();
runtime
.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response))
.unwrap();
@@ -170,9 +174,10 @@ pub fn room_key_sharing(c: &mut Criterion) {
machine.invalidate_group_session(room_id).await.unwrap();
})
});
let dir = tempfile::tempdir().unwrap();
let store = Box::new(SledCryptoStore::open_with_passphrase(dir, None).unwrap());
let _dir = tempfile::tempdir().unwrap();
let machine = OlmMachine::new(alice_id(), alice_device_id());
let machine = runtime.block_on(OlmMachine::new_with_store(alice_id().into(), alice_device_id().into(), store)).unwrap();
runtime.block_on(machine.mark_request_as_sent(&txn_id, &keys_query_response)).unwrap();
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();
@@ -223,8 +228,10 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
})
});
let _dir = tempfile::tempdir().unwrap();
let machine = OlmMachine::new(alice_id(), alice_device_id());
let dir = tempfile::tempdir().unwrap();
let store = Box::new(SledCryptoStore::open_with_passphrase(dir, None).unwrap());
let machine = runtime.block_on(OlmMachine::new_with_store(alice_id().into(), alice_device_id().into(), store)).unwrap();
runtime.block_on(machine.mark_request_as_sent(&txn_id, &response)).unwrap();