11use anyhow:: Result ;
22use anyhow:: bail;
33use clap:: Parser ;
4+ use exec_harness:: MeasurementMode ;
5+ use exec_harness:: analysis;
46use exec_harness:: uri;
57use exec_harness:: walltime;
8+ use log:: debug;
69
710#[ derive( Parser , Debug ) ]
811#[ command( name = "exec-harness" ) ]
@@ -15,6 +18,10 @@ struct Args {
1518 #[ arg( long) ]
1619 name : Option < String > ,
1720
21+ /// Set by the runner, should be coherent with the executor being used
22+ #[ arg( short, long, global = true , env = "CODSPEED_RUNNER_MODE" , hide = true ) ]
23+ measurement_mode : Option < MeasurementMode > ,
24+
1825 #[ command( flatten) ]
1926 execution_args : walltime:: WalltimeExecutionArgs ,
2027
@@ -29,6 +36,8 @@ fn main() -> Result<()> {
2936 . format_timestamp ( None )
3037 . init ( ) ;
3138
39+ debug ! ( "Starting exec-harness with pid {}" , std:: process:: id( ) ) ;
40+
3241 let args = Args :: parse ( ) ;
3342
3443 if args. command . is_empty ( ) {
@@ -37,10 +46,19 @@ fn main() -> Result<()> {
3746
3847 let bench_name_and_uri = uri:: generate_name_and_uri ( & args. name , & args. command ) ;
3948
40- // Build execution options from CLI args
41- let execution_options: walltime:: ExecutionOptions = args. execution_args . try_into ( ) ?;
49+ match args. measurement_mode {
50+ Some ( MeasurementMode :: Walltime ) | None => {
51+ let execution_options: walltime:: ExecutionOptions = args. execution_args . try_into ( ) ?;
4252
43- walltime:: perform ( bench_name_and_uri, args. command , & execution_options) ?;
53+ walltime:: perform ( bench_name_and_uri, args. command , & execution_options) ?;
54+ }
55+ Some ( MeasurementMode :: Memory ) => {
56+ analysis:: perform ( bench_name_and_uri, args. command ) ?;
57+ }
58+ Some ( MeasurementMode :: Simulation ) => {
59+ bail ! ( "Simulation measurement mode is not yet supported by exec-harness" ) ;
60+ }
61+ }
4462
4563 Ok ( ( ) )
4664}
0 commit comments