From 0fa844bcf9799d70045b72c17da174af55d5d2ab Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 16 Aug 2018 01:43:42 -0700 Subject: [PATCH] Print timing in debug info --- schala-repl/src/language.rs | 5 +++-- schala-repl/src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 79d4052..2cead50 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -70,11 +70,12 @@ impl UnfinishedComputation { impl FinishedComputation { pub fn to_repl(&self) -> String { let mut buf = String::new(); - for (stage, artifact) in self.artifacts.iter() { + for ((stage, artifact), duration) in self.artifacts.iter().zip(self.durations.iter()) { let color = artifact.text_color; let stage = stage.color(color).bold(); let output = artifact.debug_output.color(color); - write!(&mut buf, "{}: {}\n", stage, output).unwrap(); + let timing = (duration.as_secs() as f64) + (duration.subsec_nanos() as f64 * 1e-9); + write!(&mut buf, "{} ({}s): {}\n", stage, timing, output).unwrap(); } match self.text_output { diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index 872bfd1..763e7c3 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -452,7 +452,7 @@ impl Repl { let color = "green"; format!("*{}", desc.name.color(color)) } else { - desc.name + desc.name } }) .intersperse(format!(" -> "))