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()
|
.iter()
|
||||||
.sorted_by_key(|entry| entry.0)
|
.sorted_by_key(|entry| entry.0)
|
||||||
.for_each(|(d, f)| {
|
.for_each(|(d, f)| {
|
||||||
println!("Day {d}:");
|
run(*d, f);
|
||||||
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"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -40,6 +31,18 @@ fn main() {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("Day {day}:");
|
run(day, f);
|
||||||
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