Skip to content

Commit 5e49954

Browse files
committed
Stop any previously running collection before starting the current one
1 parent 50c5ea2 commit 5e49954

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

collector/src/rustc-fake.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,16 @@ fn main() {
8383
}
8484

8585
"xperf-stat" | "xperf-stat-self-profile" => {
86-
// Read the path to tracelog.exe from either an environment variable, falling back to assuming it's on the PATH.
86+
// Read the path to xperf.exe and tracelog.exe from an environment variable, falling back to assuming it's on the PATH.
87+
let xperf = std::env::var("XPERF").unwrap_or("xperf.exe".to_string());
88+
let mut cmd = Command::new(&xperf);
89+
assert!(cmd.output().is_ok(), "xperf.exe could not be started");
90+
91+
// go ahead and run xperf -stop counters in case there are leftover counters running from a failed prior attempt
92+
let mut cmd = Command::new(&xperf);
93+
cmd.args(&["-stop", "counters"]);
94+
cmd.status().expect("failed to spawn xperf");
95+
8796
let tracelog = std::env::var("TRACELOG").unwrap_or("tracelog.exe".to_string());
8897
let mut cmd = Command::new(tracelog);
8998
assert!(cmd.output().is_ok(), "tracelog.exe could not be started");
@@ -115,10 +124,6 @@ fn main() {
115124
dur.subsec_nanos()
116125
);
117126

118-
let xperf = std::env::var("XPERF").unwrap_or("xperf.exe".to_string());
119-
let mut cmd = Command::new(&xperf);
120-
assert!(cmd.output().is_ok(), "xperf.exe could not be started");
121-
122127
let xperf = |args: &[&str]| {
123128
let mut cmd = Command::new(&xperf);
124129
cmd.args(args);

0 commit comments

Comments
 (0)