File tree 4 files changed +28
-1
lines changed
4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ impl<'a> Scheduler<'a> {
42
42
. options
43
43
. reference_command
44
44
. as_ref ( )
45
- . map ( |cmd| Command :: new ( None , cmd) ) ;
45
+ . map ( |cmd| Command :: new ( self . options . reference_name . as_deref ( ) , cmd) ) ;
46
46
47
47
executor. calibrate ( ) ?;
48
48
Original file line number Diff line number Diff line change @@ -96,6 +96,14 @@ fn build_command() -> Command {
96
96
If this is unset, results are compared with the fastest command as reference."
97
97
)
98
98
)
99
+ . arg (
100
+ Arg :: new ( "reference-name" )
101
+ . long ( "reference-name" )
102
+ . action ( ArgAction :: Set )
103
+ . value_name ( "CMD" )
104
+ . help ( "Give a meaningful name to the reference command." )
105
+ . requires ( "reference" )
106
+ )
99
107
. arg (
100
108
Arg :: new ( "prepare" )
101
109
. long ( "prepare" )
Original file line number Diff line number Diff line change @@ -208,6 +208,9 @@ pub struct Options {
208
208
// Command to use as a reference for relative speed comparison
209
209
pub reference_command : Option < String > ,
210
210
211
+ // Name of the reference command
212
+ pub reference_name : Option < String > ,
213
+
211
214
/// Command(s) to run before each timing run
212
215
pub preparation_command : Option < Vec < String > > ,
213
216
@@ -250,6 +253,7 @@ impl Default for Options {
250
253
min_benchmarking_time : 3.0 ,
251
254
command_failure_action : CmdFailureAction :: RaiseError ,
252
255
reference_command : None ,
256
+ reference_name : None ,
253
257
preparation_command : None ,
254
258
conclusion_command : None ,
255
259
setup_command : None ,
@@ -310,6 +314,9 @@ impl Options {
310
314
options. setup_command = matches. get_one :: < String > ( "setup" ) . map ( String :: from) ;
311
315
312
316
options. reference_command = matches. get_one :: < String > ( "reference" ) . map ( String :: from) ;
317
+ options. reference_name = matches
318
+ . get_one :: < String > ( "reference-name" )
319
+ . map ( String :: from) ;
313
320
314
321
options. preparation_command = matches
315
322
. get_many :: < String > ( "prepare" )
Original file line number Diff line number Diff line change @@ -499,6 +499,18 @@ fn shows_benchmark_comparison_relative_to_reference() {
499
499
) ;
500
500
}
501
501
502
+ #[ test]
503
+ fn shows_reference_name ( ) {
504
+ hyperfine_debug ( )
505
+ . arg ( "--reference=sleep 2.0" )
506
+ . arg ( "--reference-name=refabc123" )
507
+ . arg ( "sleep 1.0" )
508
+ . arg ( "sleep 3.0" )
509
+ . assert ( )
510
+ . success ( )
511
+ . stdout ( predicate:: str:: contains ( "Benchmark 1: refabc123" ) ) ;
512
+ }
513
+
502
514
#[ test]
503
515
fn performs_all_benchmarks_in_parameter_scan ( ) {
504
516
hyperfine_debug ( )
You can’t perform that action at this time.
0 commit comments