@@ -59,10 +59,14 @@ pub fn keys_query(c: &mut Criterion) {
59
59
60
60
// Benchmark memory store.
61
61
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
+ ) ;
66
70
67
71
// Benchmark sqlite store.
68
72
@@ -72,10 +76,14 @@ pub fn keys_query(c: &mut Criterion) {
72
76
. block_on ( OlmMachine :: with_store ( alice_id ( ) , alice_device_id ( ) , store, None ) )
73
77
. unwrap ( ) ;
74
78
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
+ ) ;
79
87
80
88
{
81
89
let _guard = runtime. enter ( ) ;
@@ -102,51 +110,65 @@ pub fn keys_claiming(c: &mut Criterion) {
102
110
103
111
let name = format ! ( "{count} one-time keys" ) ;
104
112
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 ( ) ;
117
166
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
+ ) ;
150
172
151
173
group. finish ( )
152
174
}
@@ -174,7 +196,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
174
196
175
197
// Benchmark memory store.
176
198
177
- group. bench_function ( BenchmarkId :: new ( "memory store " , & name) , |b| {
199
+ group. bench_function ( BenchmarkId :: new ( "Room key sharing [memory] " , & name) , |b| {
178
200
b. to_async ( & runtime) . iter ( || async {
179
201
let requests = machine
180
202
. share_room_key (
@@ -206,7 +228,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
206
228
runtime. block_on ( machine. mark_request_as_sent ( & txn_id, & keys_query_response) ) . unwrap ( ) ;
207
229
runtime. block_on ( machine. mark_request_as_sent ( & txn_id, & response) ) . unwrap ( ) ;
208
230
209
- group. bench_function ( BenchmarkId :: new ( "sqlite store " , & name) , |b| {
231
+ group. bench_function ( BenchmarkId :: new ( "Room key sharing [SQLite] " , & name) , |b| {
210
232
b. to_async ( & runtime) . iter ( || async {
211
233
let requests = machine
212
234
. share_room_key (
@@ -254,7 +276,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
254
276
255
277
// Benchmark memory store.
256
278
257
- group. bench_function ( BenchmarkId :: new ( "memory store " , & name) , |b| {
279
+ group. bench_function ( BenchmarkId :: new ( "Devices collecting [memory] " , & name) , |b| {
258
280
b. to_async ( & runtime) . iter_with_large_drop ( || async {
259
281
machine. get_missing_sessions ( users. iter ( ) . map ( Deref :: deref) ) . await . unwrap ( )
260
282
} )
@@ -271,7 +293,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
271
293
272
294
runtime. block_on ( machine. mark_request_as_sent ( & txn_id, & response) ) . unwrap ( ) ;
273
295
274
- group. bench_function ( BenchmarkId :: new ( "sqlite store " , & name) , |b| {
296
+ group. bench_function ( BenchmarkId :: new ( "Devices collecting [SQLite] " , & name) , |b| {
275
297
b. to_async ( & runtime) . iter ( || async {
276
298
machine. get_missing_sessions ( users. iter ( ) . map ( Deref :: deref) ) . await . unwrap ( )
277
299
} )
0 commit comments