@@ -23,7 +23,7 @@ use std::io::BufWriter;
23
23
use std:: io:: Write ;
24
24
use std:: path:: { Path , PathBuf } ;
25
25
use std:: process;
26
- use std:: process:: { Command , Stdio } ;
26
+ use std:: process:: Command ;
27
27
use std:: time:: Duration ;
28
28
use std:: { str, time:: Instant } ;
29
29
use tokio:: runtime:: Runtime ;
@@ -39,7 +39,8 @@ use collector::runtime::{profile_runtime, RuntimeCompilationOpts};
39
39
use collector:: toolchain:: {
40
40
create_toolchain_from_published_version, get_local_toolchain, Sysroot , Toolchain ,
41
41
} ;
42
- use collector:: utils:: wait_for_future;
42
+ use collector:: utils:: cachegrind:: cachegrind_diff;
43
+ use collector:: utils:: { is_installed, wait_for_future} ;
43
44
44
45
fn n_normal_benchmarks_remaining ( n : usize ) -> String {
45
46
let suffix = if n == 1 { "" } else { "s" } ;
@@ -123,10 +124,6 @@ fn check_installed(name: &str) -> anyhow::Result<()> {
123
124
Ok ( ( ) )
124
125
}
125
126
126
- fn is_installed ( name : & str ) -> bool {
127
- Command :: new ( name) . output ( ) . is_ok ( )
128
- }
129
-
130
127
fn generate_cachegrind_diffs (
131
128
id1 : & str ,
132
129
id2 : & str ,
@@ -161,15 +158,9 @@ fn generate_cachegrind_diffs(
161
158
let id_diff = format ! ( "{}-{}" , id1, id2) ;
162
159
let cgout1 = out_dir. join ( filename ( "cgout" , id1) ) ;
163
160
let cgout2 = out_dir. join ( filename ( "cgout" , id2) ) ;
164
- let cgfilt_diff = out_dir. join ( filename ( "cgfilt-diff" , & id_diff) ) ;
165
161
let cgann_diff = out_dir. join ( filename ( "cgann-diff" , & id_diff) ) ;
166
162
167
- if let Err ( e) = cg_diff ( & cgout1, & cgout2, & cgfilt_diff) {
168
- errors. incr ( ) ;
169
- eprintln ! ( "collector error: {:?}" , e) ;
170
- continue ;
171
- }
172
- if let Err ( e) = cg_annotate ( & cgfilt_diff, & cgann_diff) {
163
+ if let Err ( e) = cachegrind_diff ( & cgout1, & cgout2, & cgann_diff) {
173
164
errors. incr ( ) ;
174
165
eprintln ! ( "collector error: {:?}" , e) ;
175
166
continue ;
@@ -182,47 +173,6 @@ fn generate_cachegrind_diffs(
182
173
annotated_diffs
183
174
}
184
175
185
- /// Compares two Cachegrind output files using cg_diff and writes result to path.
186
- fn cg_diff ( cgout1 : & Path , cgout2 : & Path , path : & Path ) -> anyhow:: Result < ( ) > {
187
- if !is_installed ( "cg_diff" ) {
188
- anyhow:: bail!( "`cg_diff` not installed." ) ;
189
- }
190
- let output = Command :: new ( "cg_diff" )
191
- . arg ( r"--mod-filename=s/\/rustc\/[^\/]*\///" )
192
- . arg ( "--mod-funcname=s/[.]llvm[.].*//" )
193
- . arg ( cgout1)
194
- . arg ( cgout2)
195
- . stderr ( Stdio :: inherit ( ) )
196
- . output ( )
197
- . context ( "failed to run `cg_diff`" ) ?;
198
-
199
- if !output. status . success ( ) {
200
- anyhow:: bail!( "failed to generate cachegrind diff" ) ;
201
- }
202
-
203
- fs:: write ( path, output. stdout ) . context ( "failed to write `cg_diff` output" ) ?;
204
-
205
- Ok ( ( ) )
206
- }
207
-
208
- /// Post process Cachegrind output file and writes resutl to path.
209
- fn cg_annotate ( cgout : & Path , path : & Path ) -> anyhow:: Result < ( ) > {
210
- let output = Command :: new ( "cg_annotate" )
211
- . arg ( "--show-percs=no" )
212
- . arg ( cgout)
213
- . stderr ( Stdio :: inherit ( ) )
214
- . output ( )
215
- . context ( "failed to run `cg_annotate`" ) ?;
216
-
217
- if !output. status . success ( ) {
218
- anyhow:: bail!( "failed to annotate cachegrind output" ) ;
219
- }
220
-
221
- fs:: write ( path, output. stdout ) . context ( "failed to write `cg_annotate` output" ) ?;
222
-
223
- Ok ( ( ) )
224
- }
225
-
226
176
#[ allow( clippy:: too_many_arguments) ]
227
177
fn profile_compile (
228
178
toolchain : & Toolchain ,
0 commit comments