diff --git a/src/cli/run.rs b/src/cli/run.rs index e768d363b8..c7e02b41c8 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -173,6 +173,8 @@ impl Run { self.validate_task(task)?; } + let timer = std::time::Instant::now(); + let pool = rayon::ThreadPoolBuilder::new() .num_threads(self.jobs() + 1) .build()?; @@ -195,6 +197,9 @@ impl Run { run(&task); } }); + + miseprintln!("finished in {}", format_duration(timer.elapsed())); + Ok(()) } @@ -211,6 +216,8 @@ impl Run { .map(|(k, v)| (k.clone(), v.clone())) .collect(); + let timer = std::time::Instant::now(); + if let Some(file) = &task.file { self.exec_file(file, task, &env, &prefix)?; } else { @@ -223,6 +230,12 @@ impl Run { } } + miseprintln!( + "{} finished in {}", + prefix, + format_duration(timer.elapsed()) + ); + self.save_checksum(task)?; Ok(()) @@ -531,6 +544,15 @@ fn get_color() -> Color { static COLOR_IDX: AtomicUsize = AtomicUsize::new(0); COLORS[COLOR_IDX.fetch_add(1, Ordering::Relaxed) % COLORS.len()] } + +fn format_duration(dur: std::time::Duration) -> String { + if dur < std::time::Duration::new(1, 0) { + format!("{:.0?}", dur) + } else { + format!("{:.2?}", dur) + } +} + #[cfg(test)] mod tests { use crate::file;