@@ -187,11 +187,14 @@ fn reading(c: &mut Criterion) {
187
187
188
188
while events. peek ( ) . is_some ( ) {
189
189
let events_chunk = events. by_ref ( ) . take ( 80 ) . collect :: < Vec < _ > > ( ) ;
190
+
190
191
if events_chunk. is_empty ( ) {
191
192
break ;
192
193
}
194
+
193
195
lc. push_items_back ( events_chunk) ;
194
196
lc. push_gap_back ( Gap { prev_token : format ! ( "gap{num_gaps}" ) } ) ;
197
+
195
198
num_gaps += 1 ;
196
199
}
197
200
@@ -205,30 +208,47 @@ fn reading(c: &mut Criterion) {
205
208
// Define the throughput.
206
209
group. throughput ( Throughput :: Elements ( num_events) ) ;
207
210
208
- // Get a bencher.
209
- group. bench_function ( BenchmarkId :: new ( store_name, num_events) , |bencher| {
210
- // Bench the routine.
211
- bencher. to_async ( & runtime) . iter ( || async {
212
- // Load the last chunk first,
213
- let ( last_chunk, chunk_id_gen) =
214
- store. load_last_chunk ( linked_chunk_id) . await . unwrap ( ) ;
215
-
216
- let mut lc =
217
- lazy_loader:: from_last_chunk :: < 128 , _ , _ > ( last_chunk, chunk_id_gen)
218
- . expect ( "no error when reconstructing the linked chunk" )
219
- . expect ( "there is a linked chunk in the store" ) ;
220
-
221
- // Then load until the start of the linked chunk.
222
- let mut cur_chunk_id = lc. chunks ( ) . next ( ) . unwrap ( ) . identifier ( ) ;
223
- while let Some ( prev) =
224
- store. load_previous_chunk ( linked_chunk_id, cur_chunk_id) . await . unwrap ( )
225
- {
226
- cur_chunk_id = prev. identifier ;
227
- lazy_loader:: insert_new_first_chunk ( & mut lc, prev)
228
- . expect ( "no error when linking the previous lazy-loaded chunk" ) ;
229
- }
230
- } )
231
- } ) ;
211
+ // Bench the lazy loader.
212
+ group. bench_function (
213
+ BenchmarkId :: new ( format ! ( "lazy_loader/{store_name}" ) , num_events) ,
214
+ |bencher| {
215
+ // Bench the routine.
216
+ bencher. to_async ( & runtime) . iter ( || async {
217
+ // Load the last chunk first,
218
+ let ( last_chunk, chunk_id_gen) =
219
+ store. load_last_chunk ( linked_chunk_id) . await . unwrap ( ) ;
220
+
221
+ let mut lc =
222
+ lazy_loader:: from_last_chunk :: < 128 , _ , _ > ( last_chunk, chunk_id_gen)
223
+ . expect ( "no error when reconstructing the linked chunk" )
224
+ . expect ( "there is a linked chunk in the store" ) ;
225
+
226
+ // Then load until the start of the linked chunk.
227
+ let mut cur_chunk_id = lc. chunks ( ) . next ( ) . unwrap ( ) . identifier ( ) ;
228
+ while let Some ( prev) =
229
+ store. load_previous_chunk ( linked_chunk_id, cur_chunk_id) . await . unwrap ( )
230
+ {
231
+ cur_chunk_id = prev. identifier ;
232
+ lazy_loader:: insert_new_first_chunk ( & mut lc, prev)
233
+ . expect ( "no error when linking the previous lazy-loaded chunk" ) ;
234
+ }
235
+ } )
236
+ } ,
237
+ ) ;
238
+
239
+ // Bench the metadata loader.
240
+ group. bench_function (
241
+ BenchmarkId :: new ( format ! ( "metadata/{store_name}" ) , num_events) ,
242
+ |bencher| {
243
+ // Bench the routine.
244
+ bencher. to_async ( & runtime) . iter ( || async {
245
+ let _metadata = store
246
+ . load_all_chunks_metadata ( linked_chunk_id)
247
+ . await
248
+ . expect ( "metadata must load" ) ;
249
+ } )
250
+ } ,
251
+ ) ;
232
252
233
253
{
234
254
let _guard = runtime. enter ( ) ;
0 commit comments