Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Sep 20th, 2018 57 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #[cfg(test)]
  2. mod test {
  3.     extern crate rand;
  4.     extern crate tempdir; // 0.3.7
  5.     extern crate test;
  6.     use self::test::Bencher;
  7.     use self::rand::Rng;
  8.    
  9.      #[bench]
  10.     fn bench_read_regular(b: &mut Bencher) {
  11.         let mut rng = rand::thread_rng();
  12.         let tempdir = tempdir::TempDir::new("rust-test").unwrap().into_path();
  13.         let mut db = DB::<Array32u8>::new(tempdir.clone(), true).unwrap();
  14.  
  15.         for _ in 0.. 10000 {
  16.             let key: [u8; 32] = rng.gen();
  17.             let val_len: u16 = rng.gen();
  18.             let val = iter::repeat_with(|| rng.gen()).take(val_len as usize).collect::<Vec<u8>>();
  19.             db.create(&Array32u8(key), &val[..]).unwrap();
  20.         }
  21.  
  22. //        let n = test::black_box(1000);
  23.         let read_opts = ReadOptions::new();
  24.         let mut iter = db.database.iter(read_opts);
  25.         let mut v = Vec::<([u8;32], Vec<u8> )>::new();
  26.         b.iter(|| {
  27.             for (val, key) in iter {
  28.                 v.push( (val.0, key) );
  29.             }
  30.         });
  31.  
  32.     }
  33. }
  34.  
  35.  
  36. /*
  37. [E0507]: cannot move out of captured outer variable in an `FnMut` closure
  38.    --> src/dal.rs:172:31
  39.     |
  40. 24 |         let mut iter = db.database.iter(read_opts);
  41.     |             -------- captured outer variable
  42. ...
  43. 27 |             for (val, key) in iter {
  44.     |                               ^^^^ cannot move out of captured outer variable in an `FnMut` closure
  45.  
  46.  
  47. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top