Skip to content

Commit d520d7c

Browse files
committed
something something
1 parent 7a08048 commit d520d7c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::path::Path;
1616
use std::process::{
1717
Child, ChildStderr, ChildStdout, Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio,
1818
};
19+
use std::time::{Duration, Instant};
1920
use std::sync::{Arc, Mutex};
2021

2122
use build_helper::ci::CiEnv;
@@ -75,7 +76,7 @@ pub struct CommandCacheKey {
7576
#[derive(Default, Clone)]
7677
pub struct CommandProfile {
7778
pub count: usize,
78-
pub total_duration: Duration,
79+
pub max_duration: Duration,
7980
}
8081

8182
#[derive(Default)]
@@ -89,22 +90,21 @@ impl CommandProfiler {
8990
let mut stats = self.stats.lock().unwrap();
9091
let entry = stats.entry(key).or_default();
9192
entry.count += 1;
92-
entry.total_duration += duration;
93+
entry.max_duration = std::cmp::max(entry.max_duration, duration);
9394
}
9495

9596
pub fn report_slowest(&self, top_n: usize) {
9697
let stats = self.stats.lock().unwrap();
9798
let mut entries: Vec<_> = stats.iter().collect();
98-
entries.sort_by_key(|(_, stat)| std::cmp::Reverse(stat.total_duration));
99+
entries.sort_by_key(|(_, stat)| std::cmp::Reverse(stat.max_duration));
99100

100101
println!("\nTop {top_n} slowest commands:");
101102
for (key, profile) in entries.into_iter().take(top_n) {
102103
println!(
103-
"- {:?} (count: {}, total: {:.2?}, avg: {:.2?})",
104+
"- {:?} (count: {}, max_duration: {:.2?})",
104105
key.program,
105106
profile.count,
106-
profile.total_duration,
107-
profile.total_duration / profile.count as u32
107+
profile.max_duration,
108108
);
109109
}
110110
}
@@ -122,7 +122,7 @@ impl CommandProfiler {
122122
"envs": key.envs,
123123
"cwd": key.cwd,
124124
"count": profile.count,
125-
"total_duration_ms": profile.total_duration.as_millis(),
125+
"max_duration_ms": profile.max_duration.as_millis(),
126126
})
127127
})
128128
.collect();

0 commit comments

Comments
 (0)