use std::{
thread::sleep,
time::{Duration, Instant},
};
use indicatif::{ProgressBar, ProgressIterator, ProgressStyle};
fn main() {
let iterations = 1000;
let blocksizes: [usize; 7] = [16, 64, 256, 1024, 4096, 16384, 65536];
let mut elapsed: [Duration; 7] = [Duration::ZERO; 7];
for (pos, blocksize) in blocksizes.iter().enumerate() {
let sty = ProgressStyle::default_spinner()
.tick_strings(&[
"▹▹▹▹▹",
"▸▹▹▹▹",
"▹▸▹▹▹",
"▹▹▸▹▹",
"▹▹▹▸▹",
"▹▹▹▹▸",
"▪▪▪▪▪",
])
.template("{prefix} {pos:>4}/{len:4} Iterations per second: {per_sec} {spinner} {msg}")
.unwrap();
let pb = ProgressBar::new(iterations);
pb.set_style(sty);
pb.enable_steady_tick(Duration::from_millis(120));
pb.set_prefix(format!("Doing test with Blocksize {:5?}:", blocksize));
for _ in (0..iterations).progress_with(pb) {
let now = Instant::now();
sleep(Duration::from_millis(1));
elapsed[pos] += now.elapsed();
}
}
}