@@ -3,6 +3,7 @@ use crate::compile::benchmark::codegen_backend::CodegenBackend;
33use crate :: compile:: benchmark:: patch:: Patch ;
44use crate :: compile:: benchmark:: profile:: Profile ;
55use crate :: compile:: benchmark:: scenario:: Scenario ;
6+ use crate :: compile:: benchmark:: target:: Target ;
67use crate :: compile:: execute:: { CargoProcess , Processor } ;
78use crate :: toolchain:: Toolchain ;
89use crate :: utils:: wait_for_future;
@@ -20,6 +21,7 @@ pub mod codegen_backend;
2021pub ( crate ) mod patch;
2122pub mod profile;
2223pub mod scenario;
24+ pub mod target;
2325
2426fn default_runs ( ) -> usize {
2527 3
@@ -180,6 +182,7 @@ impl Benchmark {
180182 cwd : & ' a Path ,
181183 profile : Profile ,
182184 backend : CodegenBackend ,
185+ target : Target ,
183186 ) -> CargoProcess < ' a > {
184187 let mut cargo_args = self
185188 . config
@@ -220,10 +223,12 @@ impl Benchmark {
220223 . collect ( ) ,
221224 touch_file : self . config . touch_file . clone ( ) ,
222225 jobserver : None ,
226+ target,
223227 }
224228 }
225229
226230 /// Run a specific benchmark under a processor + profiler combination.
231+ #[ allow( clippy:: too_many_arguments) ]
227232 pub async fn measure (
228233 & self ,
229234 processor : & mut dyn Processor ,
@@ -232,6 +237,7 @@ impl Benchmark {
232237 backends : & [ CodegenBackend ] ,
233238 toolchain : & Toolchain ,
234239 iterations : Option < usize > ,
240+ targets : & [ Target ] ,
235241 ) -> anyhow:: Result < ( ) > {
236242 if self . config . disabled {
237243 eprintln ! ( "Skipping {}: disabled" , self . name) ;
@@ -263,10 +269,15 @@ impl Benchmark {
263269 }
264270
265271 eprintln ! ( "Preparing {}" , self . name) ;
266- let mut target_dirs: Vec < ( ( CodegenBackend , Profile ) , TempDir ) > = vec ! [ ] ;
272+ let mut target_dirs: Vec < ( ( CodegenBackend , Profile , Target ) , TempDir ) > = vec ! [ ] ;
267273 for backend in backends {
268274 for profile in & profiles {
269- target_dirs. push ( ( ( * backend, * profile) , self . make_temp_dir ( & self . path ) ?) ) ;
275+ for target in targets {
276+ target_dirs. push ( (
277+ ( * backend, * profile, * target) ,
278+ self . make_temp_dir ( & self . path ) ?,
279+ ) ) ;
280+ }
270281 }
271282 }
272283
@@ -304,15 +315,21 @@ impl Benchmark {
304315 )
305316 . context ( "jobserver::new" ) ?;
306317 let mut threads = Vec :: with_capacity ( target_dirs. len ( ) ) ;
307- for ( ( backend, profile) , prep_dir) in & target_dirs {
318+ for ( ( backend, profile, target ) , prep_dir) in & target_dirs {
308319 let server = server. clone ( ) ;
309320 let thread = s. spawn :: < _ , anyhow:: Result < ( ) > > ( move || {
310321 wait_for_future ( async move {
311322 let server = server. clone ( ) ;
312- self . mk_cargo_process ( toolchain, prep_dir. path ( ) , * profile, * backend)
313- . jobserver ( server)
314- . run_rustc ( false )
315- . await ?;
323+ self . mk_cargo_process (
324+ toolchain,
325+ prep_dir. path ( ) ,
326+ * profile,
327+ * backend,
328+ * target,
329+ )
330+ . jobserver ( server)
331+ . run_rustc ( false )
332+ . await ?;
316333 Ok :: < ( ) , anyhow:: Error > ( ( ) )
317334 } ) ?;
318335 Ok ( ( ) )
@@ -343,12 +360,13 @@ impl Benchmark {
343360 let mut timing_dirs: Vec < ManuallyDrop < TempDir > > = vec ! [ ] ;
344361
345362 let benchmark_start = std:: time:: Instant :: now ( ) ;
346- for ( ( backend, profile) , prep_dir) in & target_dirs {
363+ for ( ( backend, profile, target ) , prep_dir) in & target_dirs {
347364 let backend = * backend;
348365 let profile = * profile;
366+ let target = * target;
349367 eprintln ! (
350- "Running {}: {:?} + {:?} + {:?}" ,
351- self . name, profile, scenarios, backend
368+ "Running {}: {:?} + {:?} + {:?} + {:?} " ,
369+ self . name, profile, scenarios, backend, target ,
352370 ) ;
353371
354372 // We want at least two runs for all benchmarks (since we run
@@ -370,7 +388,7 @@ impl Benchmark {
370388
371389 // A full non-incremental build.
372390 if scenarios. contains ( & Scenario :: Full ) {
373- self . mk_cargo_process ( toolchain, cwd, profile, backend)
391+ self . mk_cargo_process ( toolchain, cwd, profile, backend, target )
374392 . processor ( processor, Scenario :: Full , "Full" , None )
375393 . run_rustc ( true )
376394 . await ?;
@@ -381,7 +399,7 @@ impl Benchmark {
381399 // An incremental from scratch (slowest incremental case).
382400 // This is required for any subsequent incremental builds.
383401 if scenarios. iter ( ) . any ( |s| s. is_incr ( ) ) {
384- self . mk_cargo_process ( toolchain, cwd, profile, backend)
402+ self . mk_cargo_process ( toolchain, cwd, profile, backend, target )
385403 . incremental ( true )
386404 . processor ( processor, Scenario :: IncrFull , "IncrFull" , None )
387405 . run_rustc ( true )
@@ -390,7 +408,7 @@ impl Benchmark {
390408
391409 // An incremental build with no changes (fastest incremental case).
392410 if scenarios. contains ( & Scenario :: IncrUnchanged ) {
393- self . mk_cargo_process ( toolchain, cwd, profile, backend)
411+ self . mk_cargo_process ( toolchain, cwd, profile, backend, target )
394412 . incremental ( true )
395413 . processor ( processor, Scenario :: IncrUnchanged , "IncrUnchanged" , None )
396414 . run_rustc ( true )
@@ -405,7 +423,7 @@ impl Benchmark {
405423 // An incremental build with some changes (realistic
406424 // incremental case).
407425 let scenario_str = format ! ( "IncrPatched{}" , i) ;
408- self . mk_cargo_process ( toolchain, cwd, profile, backend)
426+ self . mk_cargo_process ( toolchain, cwd, profile, backend, target )
409427 . incremental ( true )
410428 . processor (
411429 processor,
0 commit comments