Skip to content

Commit 234ac70

Browse files
authored
feat: make time command less noisy (#56)
1 parent c82e1e2 commit 234ac70

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/template/run_multi.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,29 @@ use super::{
1010
pub fn run_multi(days_to_run: &HashSet<Day>, is_release: bool, is_timed: bool) -> Option<Timings> {
1111
let mut timings: Vec<Timing> = Vec::with_capacity(days_to_run.len());
1212

13-
all_days().for_each(|day| {
14-
if day > 1 {
15-
println!();
16-
}
17-
18-
println!("{ANSI_BOLD}Day {day}{ANSI_RESET}");
19-
println!("------");
20-
21-
if !days_to_run.contains(&day) {
22-
println!("Skipped.");
23-
return;
24-
}
25-
26-
let output = child_commands::run_solution(day, is_timed, is_release).unwrap();
27-
28-
if output.is_empty() {
29-
println!("Not solved.");
30-
} else {
31-
let val = child_commands::parse_exec_time(&output, day);
32-
timings.push(val);
33-
}
34-
});
13+
let mut need_space = false;
14+
15+
// NOTE: use non-duplicate, sorted day values.
16+
all_days()
17+
.filter(|day| days_to_run.contains(day))
18+
.for_each(|day| {
19+
if need_space {
20+
println!();
21+
}
22+
need_space = true;
23+
24+
println!("{ANSI_BOLD}Day {day}{ANSI_RESET}");
25+
println!("------");
26+
27+
let output = child_commands::run_solution(day, is_timed, is_release).unwrap();
28+
29+
if output.is_empty() {
30+
println!("Not solved.");
31+
} else {
32+
let val = child_commands::parse_exec_time(&output, day);
33+
timings.push(val);
34+
}
35+
});
3536

3637
if is_timed {
3738
let timings = Timings { data: timings };

0 commit comments

Comments
 (0)