From 6162bae1acbaadf6e68543de39d60aa54883af5a Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 25 May 2019 22:21:52 -0700 Subject: [PATCH] Per-stage computation times --- schala-repl/src/repl/directives.rs | 10 ++++++++++ schala-repl/src/repl/mod.rs | 4 ++++ schala-repl/src/repl/repl_options.rs | 2 ++ 3 files changed, 16 insertions(+) diff --git a/schala-repl/src/repl/directives.rs b/schala-repl/src/repl/directives.rs index 0f7ae82..5c7945c 100644 --- a/schala-repl/src/repl/directives.rs +++ b/schala-repl/src/repl/directives.rs @@ -90,6 +90,16 @@ pub fn get_directives(language_state: &mut Box) -> None })), CommandTree::terminal("off", None, vec![], Box::new(turn_off)), + ]), + CommandTree::nonterm("stage-times", Some("Computation time per-stage"), vec![ + CommandTree::terminal("on", None, vec![], Box::new(|repl: &mut Repl, _: &[&str]| { + repl.options.show_stage_times = true; + None + })), + CommandTree::terminal("off", None, vec![], Box::new(|repl: &mut Repl, _: &[&str]| { + repl.options.show_stage_times = false; + None + })), ]) ] ), diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index 12ad8a0..32e7a26 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -197,6 +197,10 @@ impl Repl { buf.push_str(&format!("Total duration: {:?}\n", response.global_output_stats.total_duration)); } + if self.options.show_stage_times { + buf.push_str(&format!("{:?}\n", response.global_output_stats.stage_durations)); + } + buf.push_str(&match response.main_output { Ok(s) => s, Err(e) => format!("{} {}", "Error".red(), e) diff --git a/schala-repl/src/repl/repl_options.rs b/schala-repl/src/repl/repl_options.rs index 2f07bf0..b14f624 100644 --- a/schala-repl/src/repl/repl_options.rs +++ b/schala-repl/src/repl/repl_options.rs @@ -8,6 +8,7 @@ use std::fs::File; pub struct ReplOptions { pub debug_asks: HashSet, pub show_total_time: bool, + pub show_stage_times: bool, } impl ReplOptions { @@ -15,6 +16,7 @@ impl ReplOptions { ReplOptions { debug_asks: HashSet::new(), show_total_time: true, + show_stage_times: false, } }