From 1d38a07cf8b9ac04e265ccaddfa4e18bd56b683e Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 16 Aug 2018 01:47:21 -0700 Subject: [PATCH] Add timing debugging print --- schala-repl/src/language.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 2cead50..ad9abb4 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -70,14 +70,22 @@ impl UnfinishedComputation { impl FinishedComputation { pub fn to_repl(&self) -> String { let mut buf = String::new(); - for ((stage, artifact), duration) in self.artifacts.iter().zip(self.durations.iter()) { + for (stage, artifact) in self.artifacts.iter() { let color = artifact.text_color; let stage = stage.color(color).bold(); let output = artifact.debug_output.color(color); - let timing = (duration.as_secs() as f64) + (duration.subsec_nanos() as f64 * 1e-9); - write!(&mut buf, "{} ({}s): {}\n", stage, timing, output).unwrap(); + write!(&mut buf, "{}: {}\n", stage, output).unwrap(); } + let debug_timing = true; + if debug_timing { + write!(&mut buf, "Timing: ").unwrap(); + for duration in self.durations.iter() { + let timing = (duration.as_secs() as f64) + (duration.subsec_nanos() as f64 * 1e-9); + write!(&mut buf, "{}s, ", timing).unwrap() + } + write!(&mut buf, "\n").unwrap(); + } match self.text_output { Ok(ref output) => write!(&mut buf, "{}", output).unwrap(), Err(ref err) => write!(&mut buf, "{} {}", "Error: ".red().bold(), err).unwrap(),