1
0

add elapsed time for each day to output

This commit is contained in:
2024-12-05 18:33:45 +01:00
parent e8b494859b
commit b5bcc8268f

View File

@@ -17,16 +17,7 @@ fn main() {
.iter()
.sorted_by_key(|entry| entry.0)
.for_each(|(d, f)| {
println!("Day {d}:");
let start = Instant::now();
f();
let duration = start.elapsed();
println!(
"{color}{italic}Took {duration:?}{reset_formatting}",
color = "\x1b[38;5;247m",
italic = "\x1b[3m",
reset_formatting = "\x1b[0m"
);
run(*d, f);
});
return;
};
@@ -40,6 +31,18 @@ fn main() {
return;
};
println!("Day {day}:");
f();
run(day, f);
}
fn run(d: u8, f: &fn()) {
println!("Day {d}:");
let start = Instant::now();
f();
let duration = start.elapsed();
println!(
"{color}{italic}Took {duration:?}{reset_formatting}",
color = "\x1b[38;5;247m",
italic = "\x1b[3m",
reset_formatting = "\x1b[0m"
);
}