Per-stage timing output
This commit is contained in:
parent
6a232907c5
commit
fe7ba339b5
@ -242,12 +242,24 @@ impl PassDebugArtifact {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn stage_names() -> Vec<&'static str> {
|
||||||
|
vec![
|
||||||
|
"tokenizing",
|
||||||
|
"parsing",
|
||||||
|
"symbol-table",
|
||||||
|
"typechecking",
|
||||||
|
"ast-reduction",
|
||||||
|
"ast-walking-evaluation"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
impl ProgrammingLanguageInterface for Schala {
|
impl ProgrammingLanguageInterface for Schala {
|
||||||
fn get_language_name(&self) -> String { format!("Schala") }
|
fn get_language_name(&self) -> String { format!("Schala") }
|
||||||
fn get_source_file_suffix(&self) -> String { format!("schala") }
|
fn get_source_file_suffix(&self) -> String { format!("schala") }
|
||||||
|
|
||||||
fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse {
|
fn run_computation(&mut self, request: ComputationRequest) -> ComputationResponse {
|
||||||
let ComputationRequest { source, debug_requests } = request;
|
let ComputationRequest { source, debug_requests } = request;
|
||||||
|
let stage_names = stage_names();
|
||||||
self.source_reference.load_new_source(source);
|
self.source_reference.load_new_source(source);
|
||||||
|
|
||||||
let token_debug_artifact = None;
|
let token_debug_artifact = None;
|
||||||
@ -258,17 +270,37 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
let eval_debug_artifact = None;
|
let eval_debug_artifact = None;
|
||||||
|
|
||||||
let sw = Stopwatch::start_new();
|
let sw = Stopwatch::start_new();
|
||||||
|
let mut stage_durations = Vec::new();
|
||||||
|
|
||||||
let main_output: Result<String, String> = tokenizing(source, self, token_debug_artifact)
|
let main_output: Result<String, String> = {
|
||||||
.and_then(|tokens| parsing(tokens, self, parsing_debug_artifact))
|
let output = tokenizing(source, self, token_debug_artifact);
|
||||||
.and_then(|ast| symbol_table(ast, self, symbol_debug_artifact))
|
stage_durations.push((stage_names[0].to_string(), sw.elapsed()));
|
||||||
.and_then(|ast| typechecking(ast, self, typechecking_debug_artifact))
|
output
|
||||||
.and_then(|ast| ast_reducing(ast, self, reducing_debug_artifact))
|
}.and_then(|tokens| {
|
||||||
.and_then(|reduced_ast| eval(reduced_ast, self, eval_debug_artifact));
|
let output = parsing(tokens, self, parsing_debug_artifact);
|
||||||
|
stage_durations.push((stage_names[1].to_string(), sw.elapsed()));
|
||||||
|
output
|
||||||
|
}).and_then(|ast| {
|
||||||
|
let output = symbol_table(ast, self, symbol_debug_artifact);
|
||||||
|
stage_durations.push((stage_names[2].to_string(), sw.elapsed()));
|
||||||
|
output
|
||||||
|
}).and_then(|ast| {
|
||||||
|
let output = typechecking(ast, self, typechecking_debug_artifact);
|
||||||
|
stage_durations.push((stage_names[3].to_string(), sw.elapsed()));
|
||||||
|
output
|
||||||
|
}).and_then(|ast| {
|
||||||
|
let output = ast_reducing(ast, self, reducing_debug_artifact);
|
||||||
|
stage_durations.push((stage_names[4].to_string(), sw.elapsed()));
|
||||||
|
output
|
||||||
|
}).and_then(|reduced_ast| {
|
||||||
|
let output = eval(reduced_ast, self, eval_debug_artifact);
|
||||||
|
stage_durations.push((stage_names[5].to_string(), sw.elapsed()));
|
||||||
|
output
|
||||||
|
});
|
||||||
|
|
||||||
let total_duration = sw.elapsed();
|
let total_duration = sw.elapsed();
|
||||||
let global_output_stats = GlobalOutputStats {
|
let global_output_stats = GlobalOutputStats {
|
||||||
total_duration, stage_durations: None,
|
total_duration, stage_durations
|
||||||
};
|
};
|
||||||
|
|
||||||
ComputationResponse {
|
ComputationResponse {
|
||||||
@ -280,10 +312,7 @@ impl ProgrammingLanguageInterface for Schala {
|
|||||||
|
|
||||||
fn request_meta(&mut self, request: LangMetaRequest) -> LangMetaResponse {
|
fn request_meta(&mut self, request: LangMetaRequest) -> LangMetaResponse {
|
||||||
match request {
|
match request {
|
||||||
LangMetaRequest::StageNames => LangMetaResponse::StageNames(
|
LangMetaRequest::StageNames => LangMetaResponse::StageNames(stage_names().iter().map(|s| s.to_string()).collect()),
|
||||||
vec!["tokenizing".into(), "parsing".into(), "typechecking".into(), "symbol-table".into(),
|
|
||||||
"ast-reduction".into(), "ast-walking-evaluation".into()]
|
|
||||||
),
|
|
||||||
LangMetaRequest::Docs { source } => self.handle_docs(source),
|
LangMetaRequest::Docs { source } => self.handle_docs(source),
|
||||||
LangMetaRequest::ImmediateDebug(debug_request) =>
|
LangMetaRequest::ImmediateDebug(debug_request) =>
|
||||||
LangMetaResponse::ImmediateDebug(self.handle_debug_immediate(debug_request)),
|
LangMetaResponse::ImmediateDebug(self.handle_debug_immediate(debug_request)),
|
||||||
|
@ -31,7 +31,7 @@ pub struct ComputationResponse {
|
|||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct GlobalOutputStats {
|
pub struct GlobalOutputStats {
|
||||||
pub total_duration: time::Duration,
|
pub total_duration: time::Duration,
|
||||||
pub stage_durations: Option<Vec<(String, time::Duration)>>
|
pub stage_durations: Vec<(String, time::Duration)>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)]
|
||||||
|
Loading…
Reference in New Issue
Block a user