From 2c0f98bda863c8b5e9f6d13a29aa7837d9b7e739 Mon Sep 17 00:00:00 2001 From: Ty Date: Fri, 8 Dec 2023 23:04:40 -0700 Subject: [PATCH] Benchmark improvement --- src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3574aa2..b2e03dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -184,11 +184,8 @@ async fn main() { }; let mut timings = Vec::::new(); let large = input_type == InputType::Large; - for _ in 1..warmup { - day.solve(part, large); - } - for i in 1..=n { + for i in 1..=(n+warmup) { let start = Instant::now(); day.solve(part, large); let end = Instant::now(); @@ -197,6 +194,7 @@ async fn main() { print!("\r{:.2}%", (i as f32 / n as f32) * 100.0); let _ = std::io::stdout().flush(); } + timings.drain(..=(warmup as usize)); let avg = (timings.iter().sum::() / n).as_nanos(); let deviation = (avg - timings.iter().min().unwrap().as_nanos()) .max(timings.iter().max().unwrap().as_nanos() - avg);