Skip to content

Commit

Permalink
Make read/write benchmark more fair
Browse files Browse the repository at this point in the history
Removes some extra allocations that lmdb & mmap can avoid
  • Loading branch information
cberner committed Aug 15, 2021
1 parent 0e4f7a3 commit fcb3414
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion benches/syscall_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ fn readwrite_bench(path: &Path) {
let start = SystemTime::now();
let mut checksum = 0u64;
let mut expected_checksum = 0u64;
let mut buffer = vec![0u8; 2000];
for i in &key_order {
let (key, value) = &pairs[*i % pairs.len()];
let mut mut_key = key.clone();
mut_key.extend_from_slice(&i.to_be_bytes());
let offset = i * (mut_key.len() + value.len()) + mut_key.len();
let mut buffer = vec![0u8; value.len()];

file.seek(SeekFrom::Start(offset as u64)).unwrap();
file.read_exact(&mut buffer).unwrap();
Expand Down

0 comments on commit fcb3414

Please sign in to comment.