use casual_logger::{Extension, Log};
use std::thread;
use std::time::Instant;
fn main() {
let stopwatch = Instant::now();
Log::set_file_name("performance-check");
Log::set_file_ext(Extension::Log);
Log::set_retention_days(2);
Log::set_development(true);
Log::remove_old_logs();
let mut count = 0;
let size = 100_000;
for i in 0..size {
Log::infoln(&format!("Hello, world!! {}", i));
count += 1;
}
let size = 30_000;
thread::spawn(move || {
for i in 0..size {
Log::infoln(&format!("Good morning! {}", i));
count += 1;
}
});
thread::spawn(move || {
for i in 0..size {
Log::infoln(&format!("Good afternoon! {}", i));
count += 1;
}
});
thread::spawn(move || {
for i in 0..size {
Log::infoln(&format!("Good night! {}", i));
count += 1;
}
});
Log::wait();
println!(
"Performance: {} records, {} ms.",
count,
stopwatch.elapsed().as_millis(),
)
}