fn bench_get_seq_iter(c: &mut Criterion) {
    let n = 100;
    let (_dir, env) = setup_bench_db(n);
    let txn = env.begin_ro_txn().unwrap();
    let db = txn.open_db(None).unwrap();

    c.bench_function("bench_get_seq_iter", |b| {
        b.iter(|| {
            let mut cursor = txn.cursor(&db).unwrap();
            let mut i = 0;
            let mut count = 0u32;

            for (key_len, data_len) in cursor
                .iter::<ObjectLength, ObjectLength>()
                .map(Result::unwrap)
            {
                i = i + *key_len + *data_len;
                count += 1;
            }
            for (key_len, data_len) in cursor
                .iter::<ObjectLength, ObjectLength>()
                .filter_map(Result::ok)
            {
                i = i + *key_len + *data_len;
                count += 1;
            }

            fn iterate<K: TransactionKind>(cursor: &mut Cursor<'_, K>) -> Result<()> {
                let mut i = 0;
                for result in cursor.iter::<ObjectLength, ObjectLength>() {
                    let (key_len, data_len) = result?;
                    i = i + *key_len + *data_len;
                }
                Ok(())
            }
            iterate(&mut cursor).unwrap();

            black_box(i);
            assert_eq!(count, n);
        })
    });
}
/// Benchmark of iterator sequential read performance.
Benchmark of iterator sequential read performance.
Benchmark of iterator sequential read performance .
fn bench_get_seq_iter(c: &mut Criterion) {
    let n = 100;
    let (_dir, env) = setup_bench_db(n);
    let txn = env.begin_ro_txn().unwrap();
    let db = txn.open_db(None).unwrap();
    c.bench_function("bench_get_seq_iter", |b| {
        b.iter(|| {
            let mut cursor = txn.cursor(&db).unwrap();
            let mut i = 0;
            let mut count = 0u32;
            for (key_len, data_len) in cursor
                .iter::<ObjectLength, ObjectLength>()
                .map(Result::unwrap)
            {
                i = i + *key_len + *data_len;
                count += 1;
            }
            for (key_len, data_len) in cursor
                .iter::<ObjectLength, ObjectLength>()
                .filter_map(Result::ok)
            {
                i = i + *key_len + *data_len;
                count += 1;
            }
            fn iterate<K: TransactionKind>(cursor: &mut Cursor<'_, K>) -> Result<()> {
                let mut i = 0;
                for result in cursor.iter::<ObjectLength, ObjectLength>() {
                    let (key_len, data_len) = result?;
                    i = i + *key_len + *data_len;
                }
                Ok(())
            }
            iterate(&mut cursor).unwrap();
            black_box(i);
            assert_eq!(count, n);
        })
    });
}
fn bench_get_seq_iter ( c : & mut Criterion ) { let n = 100 ; let ( _dir , env ) = setup_bench_db ( n ) ; let txn = env . begin_ro_txn ( ) . unwrap ( ) ; let db = txn . open_db ( None ) . unwrap ( ) ; c . bench_function ( " " , | b | { b . iter ( | | { let mut cursor = txn . cursor ( & db ) . unwrap ( ) ; let mut i = 0 ; let mut count = 0u32 ; for ( key_len , data_len ) in cursor . iter :: < ObjectLength , ObjectLength > ( ) . map ( Result :: unwrap ) { i = i + * key_len + * data_len ; count += 1 ; } for ( key_len , data_len ) in cursor . iter :: < ObjectLength , ObjectLength > ( ) . filter_map ( Result :: ok ) { i = i + * key_len + * data_len ; count += 1 ; } fn iterate < K : TransactionKind > ( cursor : & mut Cursor < ' _ , K > ) -> Result < ( ) > { let mut i = 0 ; for result in cursor . iter :: < ObjectLength , ObjectLength > ( ) { let ( key_len , data_len ) = result ? ; i = i + * key_len + * data_len ; } Ok ( ( ) ) } iterate ( & mut cursor ) . unwrap ( ) ; black_box ( i ) ; assert_eq ! ( count n ) ; } ) } ) ; }
Benchmark of iterator sequential read performance.
Benchmark of iterator sequential read performance .
c
&mut Criterion