File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,41 @@ pub fn btreemap_insert_10mib_values() -> BenchResult {
220
220
} )
221
221
}
222
222
223
+ // Read a range of entries but only process the key of each entry.
224
+ #[ bench( raw) ]
225
+ pub fn btreemap_read_keys_from_range ( ) -> BenchResult {
226
+ let mut btree = BTreeMap :: new ( DefaultMemoryImpl :: default ( ) ) ;
227
+ let size: u32 = 10_000 ;
228
+ for i in 0 ..size {
229
+ btree. insert ( i, vec ! [ 0 ; 1024 ] ) ;
230
+ }
231
+
232
+ bench_fn ( || {
233
+ btree
234
+ . range ( ( Bound :: Included ( 0 ) , Bound :: Included ( size) ) )
235
+ . map ( |entry| entry. 0 )
236
+ . sum :: < u32 > ( )
237
+ } )
238
+ }
239
+
240
+ // Read a range of entries but only process the value from every third entry.
241
+ #[ bench( raw) ]
242
+ pub fn btreemap_read_every_third_value_from_range ( ) -> BenchResult {
243
+ let mut btree = BTreeMap :: new ( DefaultMemoryImpl :: default ( ) ) ;
244
+ let size: u32 = 10_000 ;
245
+ for i in 0 ..size {
246
+ btree. insert ( i, vec ! [ 0 ; 1024 ] ) ;
247
+ }
248
+
249
+ bench_fn ( || {
250
+ btree
251
+ . range ( ( Bound :: Included ( 0 ) , Bound :: Included ( size) ) )
252
+ . filter ( |entry| entry. 0 % 3 == 0 )
253
+ . map ( |entry| entry. 1 . len ( ) )
254
+ . sum :: < usize > ( )
255
+ } )
256
+ }
257
+
223
258
#[ bench( raw) ]
224
259
pub fn btreemap_iter_small_values ( ) -> BenchResult {
225
260
iter_helper ( 10_000 , 0 , IterType :: Iter )
Original file line number Diff line number Diff line change @@ -425,6 +425,18 @@ benches:
425
425
heap_increase : 0
426
426
stable_memory_increase : 0
427
427
scopes : {}
428
+ btreemap_read_every_third_value_from_range :
429
+ total :
430
+ instructions : 160211242
431
+ heap_increase : 0
432
+ stable_memory_increase : 0
433
+ scopes : { }
434
+ btreemap_read_keys_from_range :
435
+ total :
436
+ instructions : 160211242
437
+ heap_increase : 0
438
+ stable_memory_increase : 0
439
+ scopes : { }
428
440
btreemap_remove_blob_128_1024 :
429
441
total :
430
442
instructions : 1842207367
You can’t perform that action at this time.
0 commit comments