add elapsed time for each day to output
This commit is contained in:
27
src/main.rs
27
src/main.rs
@@ -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"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user