@@ -132,21 +132,16 @@ fn check_measureme_installed() -> Result<(), String> {
132132 }
133133}
134134
135- fn check_installed ( name : & str ) -> anyhow:: Result < ( ) > {
136- if !is_installed ( name) {
137- anyhow:: bail!( "`{}` is not installed but must be" , name) ;
138- }
139- Ok ( ( ) )
140- }
141-
142- fn generate_cachegrind_diffs (
135+ #[ allow( clippy:: too_many_arguments) ]
136+ fn generate_diffs (
143137 id1 : & str ,
144138 id2 : & str ,
145139 out_dir : & Path ,
146140 benchmarks : & [ Benchmark ] ,
147141 profiles : & [ Profile ] ,
148142 scenarios : & [ Scenario ] ,
149143 errors : & mut BenchmarkErrors ,
144+ profiler : & Profiler ,
150145) -> Vec < PathBuf > {
151146 let mut annotated_diffs = Vec :: new ( ) ;
152147 for benchmark in benchmarks {
@@ -166,22 +161,28 @@ fn generate_cachegrind_diffs(
166161 } ) {
167162 let filename = |prefix, id| {
168163 format ! (
169- "{}-{}-{}-{:?}-{}" ,
170- prefix, id, benchmark. name, profile, scenario
164+ "{}-{}-{}-{:?}-{}{}" ,
165+ prefix,
166+ id,
167+ benchmark. name,
168+ profile,
169+ scenario,
170+ profiler. postfix( )
171171 )
172172 } ;
173173 let id_diff = format ! ( "{}-{}" , id1, id2) ;
174- let cgout1 = out_dir. join ( filename ( "cgout" , id1) ) ;
175- let cgout2 = out_dir. join ( filename ( "cgout" , id2) ) ;
176- let cgann_diff = out_dir. join ( filename ( "cgann-diff" , & id_diff) ) ;
174+ let prefix = profiler. prefix ( ) ;
175+ let left = out_dir. join ( filename ( prefix, id1) ) ;
176+ let right = out_dir. join ( filename ( prefix, id2) ) ;
177+ let output = out_dir. join ( filename ( & format ! ( "{prefix}-diff" ) , & id_diff) ) ;
177178
178- if let Err ( e) = cachegrind_diff ( & cgout1 , & cgout2 , & cgann_diff ) {
179+ if let Err ( e) = profiler . diff ( & left , & right , & output ) {
179180 errors. incr ( ) ;
180181 eprintln ! ( "collector error: {:?}" , e) ;
181182 continue ;
182183 }
183184
184- annotated_diffs. push ( cgann_diff ) ;
185+ annotated_diffs. push ( output ) ;
185186 }
186187 }
187188 }
@@ -1145,29 +1146,25 @@ fn main_result() -> anyhow::Result<i32> {
11451146 let id1 = get_toolchain_and_profile ( local. rustc . as_str ( ) , "1" ) ?;
11461147 let id2 = get_toolchain_and_profile ( rustc2. as_str ( ) , "2" ) ?;
11471148
1148- if profiler == Profiler :: Cachegrind {
1149- check_installed ( "valgrind" ) ?;
1150- check_installed ( "cg_annotate" ) ?;
1151-
1152- let diffs = generate_cachegrind_diffs (
1153- & id1,
1154- & id2,
1155- & out_dir,
1156- & benchmarks,
1157- profiles,
1158- scenarios,
1159- & mut errors,
1160- ) ;
1161- if let [ diff] = & diffs[ ..] {
1162- let short = out_dir. join ( "cgann-diff-latest" ) ;
1163- std:: fs:: copy ( diff, & short) . expect ( "copy to short path" ) ;
1164- eprintln ! ( "Original diff at: {}" , diff. to_string_lossy( ) ) ;
1165- eprintln ! ( "Short path: {}" , short. to_string_lossy( ) ) ;
1166- } else {
1167- eprintln ! ( "Diffs:" ) ;
1168- for diff in diffs {
1169- eprintln ! ( "{}" , diff. to_string_lossy( ) ) ;
1170- }
1149+ let diffs = generate_diffs (
1150+ & id1,
1151+ & id2,
1152+ & out_dir,
1153+ & benchmarks,
1154+ profiles,
1155+ scenarios,
1156+ & mut errors,
1157+ & profiler,
1158+ ) ;
1159+ if let [ diff] = & diffs[ ..] {
1160+ let short = out_dir. join ( format ! ( "{}-diff-latest" , profiler. prefix( ) ) ) ;
1161+ std:: fs:: copy ( diff, & short) . expect ( "copy to short path" ) ;
1162+ eprintln ! ( "Original diff at: {}" , diff. to_string_lossy( ) ) ;
1163+ eprintln ! ( "Short path: {}" , short. to_string_lossy( ) ) ;
1164+ } else {
1165+ eprintln ! ( "Diffs:" ) ;
1166+ for diff in diffs {
1167+ eprintln ! ( "{}" , diff. to_string_lossy( ) ) ;
11711168 }
11721169 }
11731170 } else {
0 commit comments