Skip to content

Commit ae26991

Browse files
committed
Stop any previously running collection before starting the current one
Also update the collection name so it's obvious that it is related to the rustc-perf tool.
1 parent b7a5286 commit ae26991

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

collector/src/rustc-fake.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,21 @@ 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 rustc-perf-counters` in case there are leftover counters running from a failed prior attempt
92+
let mut cmd = Command::new(&xperf);
93+
cmd.args(&["-stop", "rustc-perf-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");
9099

91-
cmd.args(&["-start", "counters", "-f", "counters.etl", "-eflag", "CSWITCH+PROC_THREAD+LOADER", "-PMC", "InstructionRetired,TotalCycles:CSWITCH"]);
100+
cmd.args(&["-start", "rustc-perf-counters", "-f", "counters.etl", "-eflag", "CSWITCH+PROC_THREAD+LOADER", "-PMC", "InstructionRetired,TotalCycles:CSWITCH"]);
92101
let status = cmd.status().expect("failed to spawn tracelog");
93102
assert!(status.success(), "tracelog did not complete successfully");
94103

@@ -115,17 +124,13 @@ 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);
125130
assert!(cmd.status().expect("failed to spawn xperf").success(), "xperf did not complete successfully");
126131
};
127132

128-
xperf(&["-stop", "counters"]);
133+
xperf(&["-stop", "rustc-perf-counters"]);
129134
xperf(&["-merge", "counters.etl", "pmc_counters_merged.etl"]);
130135
xperf(&["-i", "pmc_counters_merged.etl", "-o", "pmc_counters.txt"]);
131136

0 commit comments

Comments
 (0)