Skip to content

Commit

Permalink
perf: calculate exe_seq only when info logging is enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Amin Yahyaabadi <[email protected]>
  • Loading branch information
aminya committed Nov 27, 2023
1 parent e2863f7 commit 3b52b81
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/engine/dag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,16 @@ impl Dag {
/// topological sorting, and cancel the execution of subsequent tasks if an
/// error is encountered during task execution.
pub(crate) async fn run(&self) -> bool {
let mut exe_seq = String::from("[Start]");
self.exe_sequence
.iter()
.for_each(|id| exe_seq.push_str(&format!(" -> {}", self.tasks[id].name())));
info!("{} -> [End]", exe_seq);
info!(
"[Start]{} -> [End]",
(|| {
let mut exe_seq = String::new();
self.exe_sequence
.iter()
.for_each(|id| exe_seq.push_str(&format!(" -> {}", self.tasks[id].name())));
exe_seq
})()
);
let mut handles = Vec::new();
self.exe_sequence.iter().for_each(|id| {
handles.push((*id, self.execute_task(&self.tasks[id])));
Expand Down

0 comments on commit 3b52b81

Please sign in to comment.