Add timing debugging print

This commit is contained in:
greg 2018-08-16 01:47:21 -07:00
parent 0fa844bcf9
commit 1d38a07cf8

View File

@ -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(),