From 3329ae8c2e0c3356007861f901e2c47a076edff6 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 2 Jan 2019 19:16:55 +0100 Subject: [PATCH] add benchmark for chunker We get about 300MB/s - so this is still not fast enough Note: This is quite slow with debug target, so please compile with --release --- src/bin/test_chunk_speed.rs | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/bin/test_chunk_speed.rs diff --git a/src/bin/test_chunk_speed.rs b/src/bin/test_chunk_speed.rs new file mode 100644 index 00000000..99f475e0 --- /dev/null +++ b/src/bin/test_chunk_speed.rs @@ -0,0 +1,43 @@ +extern crate proxmox_backup; + +use proxmox_backup::backup::chunker::*; + +fn main() { + + let mut buffer = Vec::new(); + + for i in 0..1024*1024 { + for j in 0..4 { + let byte = ((i >> (j<<3))&0xff) as u8; + //println!("BYTE {}", byte); + buffer.push(byte); + } + } + let mut chunker = Chunker::new(512*1024); + + let count = 100; + + let start = std::time::SystemTime::now(); + + for _i in 0..count { + let mut pos = 0; + while pos < buffer.len() { + let k = chunker.scan(&buffer[pos..]); + if k == 0 { + //println!("LAST {}", pos); + break; + } else { + pos += k; + //println!("CHUNK {}", pos); + } + } + } + + let elapsed = start.elapsed().unwrap(); + let elapsed = (elapsed.as_secs() as f64) + + (elapsed.subsec_millis() as f64)/1000.0; + + let mbytecount = ((count*buffer.len()) as f64) / (1024.0*1024.0); + let mbytes_per_sec = mbytecount/elapsed; + println!("SPEED = {} MB/s", mbytes_per_sec); +}