adjust time output and add overall time

This commit is contained in:
fuckwit 2023-11-15 20:39:11 +01:00
parent c925597f8f
commit 9b89f18a5f

View File

@ -1,4 +1,4 @@
use std::time::Instant; use std::time::{Instant, Duration};
use aoc::util::parse::ParseExt; use aoc::util::parse::ParseExt;
@ -44,6 +44,8 @@ fn main() {
.filter(|s| day == Some(s.day) || day.is_none()) .filter(|s| day == Some(s.day) || day.is_none())
.collect(); .collect();
let count = solutions.len();
let mut overall_duration = Duration::new(0, 0);
for Solution { for Solution {
year, year,
day, day,
@ -54,10 +56,12 @@ fn main() {
let start = Instant::now(); let start = Instant::now();
let (aw1, aw2) = (run)(input); let (aw1, aw2) = (run)(input);
let elapsed = start.elapsed(); let elapsed = start.elapsed();
println!("{year} Day {day:02} ({})", elapsed.as_micros()); overall_duration += elapsed;
println!("{year} Day {day:02} ({:?})", elapsed);
println!(" Part 1: {aw1}"); println!(" Part 1: {aw1}");
println!(" Part 2: {aw2}"); println!(" Part 2: {aw2}");
} }
println!("Total solutions: {count} ({overall_duration:?})")
} }
fn solutions() -> impl Iterator<Item = Solution> { fn solutions() -> impl Iterator<Item = Solution> {