proxmox-backup/src/bin/test_chunk_speed.rs

51 lines
1.3 KiB
Rust
Raw Normal View History

extern crate proxmox_backup;
//use proxmox_backup::backup::chunker::*;
use proxmox_backup::backup::*;
fn main() {
let mut buffer = Vec::new();
2019-01-03 13:35:19 +00:00
for i in 0..20*1024*1024 {
for j in 0..4 {
let byte = ((i >> (j<<3))&0xff) as u8;
//println!("BYTE {}", byte);
buffer.push(byte);
}
}
2019-01-03 13:35:19 +00:00
let mut chunker = Chunker::new(64*1024);
2019-01-03 13:35:19 +00:00
let count = 5;
let start = std::time::SystemTime::now();
2019-01-03 13:35:19 +00:00
let mut chunk_count = 0;
for _i in 0..count {
let mut pos = 0;
2019-01-30 17:25:37 +00:00
let mut _last = 0;
while pos < buffer.len() {
let k = chunker.scan(&buffer[pos..]);
if k == 0 {
//println!("LAST {}", pos);
break;
} else {
2019-01-30 17:25:37 +00:00
_last = pos;
pos += k;
2019-01-03 13:35:19 +00:00
chunk_count += 1;
//println!("CHUNK {} {}", pos, pos-last);
}
}
}
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);
2019-01-03 13:35:19 +00:00
let avg_chunk_size = mbytecount/(chunk_count as f64);
let mbytes_per_sec = mbytecount/elapsed;
2019-01-03 13:35:19 +00:00
println!("SPEED = {} MB/s, avg chunk size = {} KB", mbytes_per_sec, avg_chunk_size*1024.0);
}