benches: Benchmark the sled store as well in the key query/claim benches

master
Damir Jelić 2021-03-02 11:18:10 +01:00
parent 48903a24d2
commit 4ccb5a1cb9
1 changed files with 49 additions and 7 deletions

View File

@ -56,17 +56,35 @@ pub fn keys_query(c: &mut Criterion) {
let mut group = c.benchmark_group("Keys querying"); let mut group = c.benchmark_group("Keys querying");
group.throughput(Throughput::Elements(count as u64)); group.throughput(Throughput::Elements(count as u64));
let name = format!("{} device and cross signing keys", count);
group.bench_with_input( group.bench_with_input(
BenchmarkId::new( BenchmarkId::new("memory store", &name),
"Keys querying",
"150 device keys parsing and signature checking",
),
&response, &response,
|b, response| { |b, response| {
b.to_async(FuturesExecutor) b.to_async(FuturesExecutor)
.iter(|| async { machine.mark_request_as_sent(&uuid, response).await.unwrap() }) .iter(|| async { machine.mark_request_as_sent(&uuid, response).await.unwrap() })
}, },
); );
let dir = tempfile::tempdir().unwrap();
let machine = block_on(OlmMachine::new_with_default_store(
&alice_id(),
&alice_device_id(),
dir.path(),
None,
))
.unwrap();
group.bench_with_input(
BenchmarkId::new("sled store", &name),
&response,
|b, response| {
b.to_async(FuturesExecutor)
.iter(|| async { machine.mark_request_as_sent(&uuid, response).await.unwrap() })
},
);
group.finish() group.finish()
} }
@ -81,13 +99,13 @@ pub fn keys_claiming(c: &mut Criterion) {
.values() .values()
.fold(0, |acc, d| acc + d.len()); .fold(0, |acc, d| acc + d.len());
let mut group = c.benchmark_group("Keys claiming throughput"); let mut group = c.benchmark_group("Olm session creation");
group.throughput(Throughput::Elements(count as u64)); group.throughput(Throughput::Elements(count as u64));
let name = format!("{} one-time keys claiming and session creation", count); let name = format!("{} one-time keys", count);
group.bench_with_input( group.bench_with_input(
BenchmarkId::new("One-time keys claiming", &name), BenchmarkId::new("memory store", &name),
&response, &response,
|b, response| { |b, response| {
b.iter_batched( b.iter_batched(
@ -101,6 +119,30 @@ 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 = block_on(OlmMachine::new_with_default_store(
&alice_id(),
&alice_device_id(),
dir.path(),
None,
))
.unwrap();
block_on(machine.mark_request_as_sent(&uuid, &keys_query_response)).unwrap();
machine
},
move |machine| block_on(machine.mark_request_as_sent(&uuid, response)).unwrap(),
BatchSize::SmallInput,
)
},
);
group.finish() group.finish()
} }