@@ -286,6 +286,8 @@ pub struct TestOpts {
286
286
pub logfile : Option < Path > ,
287
287
pub nocapture : bool ,
288
288
pub color : ColorConfig ,
289
+ pub show_error_bar : bool ,
290
+ pub show_all_stats : bool ,
289
291
}
290
292
291
293
impl TestOpts {
@@ -303,6 +305,8 @@ impl TestOpts {
303
305
logfile : None ,
304
306
nocapture : false ,
305
307
color : AutoColor ,
308
+ show_error_bar : false ,
309
+ show_all_stats : false ,
306
310
}
307
311
}
308
312
}
@@ -333,7 +337,9 @@ fn optgroups() -> Vec<getopts::OptGroup> {
333
337
getopts:: optopt( "" , "color" , "Configure coloring of output:
334
338
auto = colorize if stdout is a tty and tests are run on serially (default);
335
339
always = always colorize output;
336
- never = never colorize output;" , "auto|always|never" ) )
340
+ never = never colorize output;" , "auto|always|never" ) ,
341
+ getopts:: optflag( "" , "error-bar" , "Display error bars for the benchmarks" ) ,
342
+ getopts:: optflag( "" , "stats" , "Display the benchmark min, max, and quartiles" ) )
337
343
}
338
344
339
345
fn usage ( binary : & str ) {
@@ -424,6 +430,9 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
424
430
v) ) ) ,
425
431
} ;
426
432
433
+ let show_error_bar = matches. opt_present ( "error-bar" ) ;
434
+ let show_all_stats = matches. opt_present ( "stats" ) ;
435
+
427
436
let test_opts = TestOpts {
428
437
filter : filter,
429
438
run_ignored : run_ignored,
@@ -436,6 +445,8 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
436
445
logfile : logfile,
437
446
nocapture : nocapture,
438
447
color : color,
448
+ show_error_bar : show_error_bar,
449
+ show_all_stats : show_all_stats,
439
450
} ;
440
451
441
452
Some ( Ok ( test_opts) )
@@ -486,6 +497,8 @@ struct ConsoleTestState<T> {
486
497
log_out : Option < File > ,
487
498
out : OutputLocation < T > ,
488
499
use_color : bool ,
500
+ show_error_bar : bool ,
501
+ show_all_stats : bool ,
489
502
total : uint ,
490
503
passed : uint ,
491
504
failed : uint ,
@@ -512,6 +525,8 @@ impl<T: Writer> ConsoleTestState<T> {
512
525
out : out,
513
526
log_out : log_out,
514
527
use_color : use_color ( opts) ,
528
+ show_error_bar : opts. show_error_bar ,
529
+ show_all_stats : opts. show_all_stats ,
515
530
total : 0 u,
516
531
passed : 0 u,
517
532
failed : 0 u,
@@ -607,8 +622,31 @@ impl<T: Writer> ConsoleTestState<T> {
607
622
}
608
623
TrBench ( ref bs) => {
609
624
try!( self . write_bench ( ) ) ;
610
- self . write_plain ( format ! ( ": {}" ,
611
- fmt_bench_samples( bs) ) . as_slice ( ) )
625
+
626
+ if self . show_error_bar {
627
+ let mut wr = Vec :: new ( ) ;
628
+
629
+ try!( stats:: write_boxplot ( & mut wr, & bs. ns_iter_summ , 50 ) ) ;
630
+
631
+ let s = String :: from_utf8 ( wr) . unwrap ( ) ;
632
+
633
+ try!( self . write_plain ( format ! ( ": {}" , s) . as_slice ( ) ) ) ;
634
+ }
635
+
636
+ if self . show_all_stats {
637
+ let mut wr = Vec :: new ( ) ;
638
+
639
+ try!( stats:: write_5_number_summary ( & mut wr, & bs. ns_iter_summ ) ) ;
640
+
641
+ let s = String :: from_utf8 ( wr) . unwrap ( ) ;
642
+
643
+ try!( self . write_plain ( format ! ( ": {}" , s) . as_slice ( ) ) ) ;
644
+ } else {
645
+ try!( self . write_plain ( format ! ( ": {}" ,
646
+ fmt_bench_samples( bs) ) . as_slice ( ) ) ) ;
647
+ }
648
+
649
+ Ok ( ( ) )
612
650
}
613
651
} ) ;
614
652
self . write_plain ( "\n " )
0 commit comments