Skip to content

Commit

Permalink
feat: make time command less noisy (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
tguichaoua authored Dec 11, 2023
1 parent c82e1e2 commit 234ac70
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/template/run_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@ use super::{
pub fn run_multi(days_to_run: &HashSet<Day>, is_release: bool, is_timed: bool) -> Option<Timings> {
let mut timings: Vec<Timing> = Vec::with_capacity(days_to_run.len());

all_days().for_each(|day| {
if day > 1 {
println!();
}

println!("{ANSI_BOLD}Day {day}{ANSI_RESET}");
println!("------");

if !days_to_run.contains(&day) {
println!("Skipped.");
return;
}

let output = child_commands::run_solution(day, is_timed, is_release).unwrap();

if output.is_empty() {
println!("Not solved.");
} else {
let val = child_commands::parse_exec_time(&output, day);
timings.push(val);
}
});
let mut need_space = false;

// NOTE: use non-duplicate, sorted day values.
all_days()
.filter(|day| days_to_run.contains(day))
.for_each(|day| {
if need_space {
println!();
}
need_space = true;

println!("{ANSI_BOLD}Day {day}{ANSI_RESET}");
println!("------");

let output = child_commands::run_solution(day, is_timed, is_release).unwrap();

if output.is_empty() {
println!("Not solved.");
} else {
let val = child_commands::parse_exec_time(&output, day);
timings.push(val);
}
});

if is_timed {
let timings = Timings { data: timings };
Expand Down

0 comments on commit 234ac70

Please sign in to comment.