@@ -54,15 +54,14 @@ use self::OutputLocation::*;
54
54
use stats:: Stats ;
55
55
use getopts:: { OptGroup , optflag, optopt} ;
56
56
use regex:: Regex ;
57
- use serialize:: { json , Decodable , Encodable } ;
57
+ use serialize:: Encodable ;
58
58
use term:: Terminal ;
59
59
use term:: color:: { Color , RED , YELLOW , GREEN , CYAN } ;
60
60
61
61
use std:: any:: Any ;
62
62
use std:: cmp;
63
63
use std:: collections:: BTreeMap ;
64
64
use std:: fmt;
65
- use std:: io:: fs:: PathExtensions ;
66
65
use std:: io:: stdio:: StdWriter ;
67
66
use std:: io:: { File , ChanReader , ChanWriter } ;
68
67
use std:: io;
@@ -438,9 +437,6 @@ struct ConsoleTestState<T> {
438
437
log_out : Option < File > ,
439
438
out : OutputLocation < T > ,
440
439
use_color : bool ,
441
- show_boxplot : bool ,
442
- boxplot_width : uint ,
443
- show_all_stats : bool ,
444
440
total : uint ,
445
441
passed : uint ,
446
442
failed : uint ,
@@ -467,9 +463,6 @@ impl<T: Writer> ConsoleTestState<T> {
467
463
out : out,
468
464
log_out : log_out,
469
465
use_color : use_color ( opts) ,
470
- show_boxplot : false ,
471
- boxplot_width : 50 ,
472
- show_all_stats : false ,
473
466
total : 0 u,
474
467
passed : 0 u,
475
468
failed : 0 u,
@@ -545,33 +538,13 @@ impl<T: Writer> ConsoleTestState<T> {
545
538
TrIgnored => self . write_ignored ( ) ,
546
539
TrMetrics ( ref mm) => {
547
540
try!( self . write_metric ( ) ) ;
548
- self . write_plain ( format ! ( ": {}" , fmt_metrics( mm ) ) . as_slice ( ) )
541
+ self . write_plain ( format ! ( ": {}" , mm . fmt_metrics( ) ) . as_slice ( ) )
549
542
}
550
543
TrBench ( ref bs) => {
551
544
try!( self . write_bench ( ) ) ;
552
545
553
- if self . show_boxplot {
554
- let mut wr = Vec :: new ( ) ;
555
-
556
- try!( stats:: write_boxplot ( & mut wr, & bs. ns_iter_summ , self . boxplot_width ) ) ;
557
-
558
- let s = String :: from_utf8 ( wr) . unwrap ( ) ;
559
-
560
- try!( self . write_plain ( format ! ( ": {}" , s) . as_slice ( ) ) ) ;
561
- }
562
-
563
- if self . show_all_stats {
564
- let mut wr = Vec :: new ( ) ;
565
-
566
- try!( stats:: write_5_number_summary ( & mut wr, & bs. ns_iter_summ ) ) ;
567
-
568
- let s = String :: from_utf8 ( wr) . unwrap ( ) ;
569
-
570
- try!( self . write_plain ( format ! ( ": {}" , s) . as_slice ( ) ) ) ;
571
- } else {
572
- try!( self . write_plain ( format ! ( ": {}" ,
573
- fmt_bench_samples( bs) ) . as_slice ( ) ) ) ;
574
- }
546
+ try!( self . write_plain ( format ! ( ": {}" ,
547
+ fmt_bench_samples( bs) ) . as_slice ( ) ) ) ;
575
548
576
549
Ok ( ( ) )
577
550
}
@@ -588,7 +561,7 @@ impl<T: Writer> ConsoleTestState<T> {
588
561
TrOk => "ok" . to_string( ) ,
589
562
TrFailed => "failed" . to_string( ) ,
590
563
TrIgnored => "ignored" . to_string( ) ,
591
- TrMetrics ( ref mm) => fmt_metrics( mm ) ,
564
+ TrMetrics ( ref mm) => mm . fmt_metrics( ) ,
592
565
TrBench ( ref bs) => fmt_bench_samples( bs)
593
566
} , test. name. as_slice( ) ) ;
594
567
o. write ( s. as_bytes ( ) )
@@ -624,34 +597,14 @@ impl<T: Writer> ConsoleTestState<T> {
624
597
Ok ( ( ) )
625
598
}
626
599
627
- pub fn write_run_finish ( & mut self ,
628
- ratchet_metrics : & Option < Path > ,
629
- ratchet_pct : Option < f64 > ) -> io:: IoResult < bool > {
600
+ pub fn write_run_finish ( & mut self ) -> io:: IoResult < bool > {
630
601
assert ! ( self . passed + self . failed + self . ignored + self . measured == self . total) ;
631
602
632
- let ratchet_success = match * ratchet_metrics {
633
- None => true ,
634
- Some ( ref pth) => {
635
- try!( self . write_plain ( format ! ( "\n using metrics ratchet: {:?}\n " ,
636
- pth. display( ) ) . as_slice ( ) ) ) ;
637
- match ratchet_pct {
638
- None => ( ) ,
639
- Some ( pct) =>
640
- try!( self . write_plain ( format ! ( "with noise-tolerance \
641
- forced to: {}%\n ",
642
- pct) . as_slice ( ) ) )
643
- }
644
- true
645
- }
646
- } ;
647
-
648
- let test_success = self . failed == 0 u;
649
- if !test_success {
603
+ let success = self . failed == 0 u;
604
+ if !success {
650
605
try!( self . write_failures ( ) ) ;
651
606
}
652
607
653
- let success = ratchet_success && test_success;
654
-
655
608
try!( self . write_plain ( "\n test result: " ) ) ;
656
609
if success {
657
610
// There's no parallelism at this point so it's safe to use color
@@ -666,15 +619,6 @@ impl<T: Writer> ConsoleTestState<T> {
666
619
}
667
620
}
668
621
669
- pub fn fmt_metrics ( mm : & MetricMap ) -> String {
670
- let MetricMap ( ref mm) = * mm;
671
- let v : Vec < String > = mm. iter ( )
672
- . map ( |( k, v) | format ! ( "{}: {} (+/- {})" , * k,
673
- v. value as f64 , v. noise as f64 ) )
674
- . collect ( ) ;
675
- v. connect ( ", " )
676
- }
677
-
678
622
pub fn fmt_bench_samples ( bs : & BenchSamples ) -> String {
679
623
if bs. mb_s != 0 {
680
624
format ! ( "{:>9} ns/iter (+/- {}) = {} MB/s" ,
@@ -745,7 +689,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn> ) -> io::IoR
745
689
None => { }
746
690
}
747
691
try!( run_tests ( opts, tests, |x| callback ( & x, & mut st) ) ) ;
748
- return st. write_run_finish ( & None , None ) ;
692
+ return st. write_run_finish ( ) ;
749
693
}
750
694
751
695
#[ test]
@@ -766,9 +710,6 @@ fn should_sort_failures_before_printing_them() {
766
710
log_out : None ,
767
711
out : Raw ( Vec :: new ( ) ) ,
768
712
use_color : false ,
769
- show_boxplot : false ,
770
- boxplot_width : 0 ,
771
- show_all_stats : false ,
772
713
total : 0 u,
773
714
passed : 0 u,
774
715
failed : 0 u,
@@ -1010,30 +951,6 @@ impl MetricMap {
1010
951
MetricMap ( BTreeMap :: new ( ) )
1011
952
}
1012
953
1013
- /// Load MetricDiff from a file.
1014
- ///
1015
- /// # Panics
1016
- ///
1017
- /// This function will panic if the path does not exist or the path does not
1018
- /// contain a valid metric map.
1019
- pub fn load ( p : & Path ) -> MetricMap {
1020
- assert ! ( p. exists( ) ) ;
1021
- let mut f = File :: open ( p) . unwrap ( ) ;
1022
- let value = json:: from_reader ( & mut f as & mut io:: Reader ) . unwrap ( ) ;
1023
- let mut decoder = json:: Decoder :: new ( value) ;
1024
- MetricMap ( match Decodable :: decode ( & mut decoder) {
1025
- Ok ( t) => t,
1026
- Err ( e) => panic ! ( "failure decoding JSON: {:?}" , e)
1027
- } )
1028
- }
1029
-
1030
- /// Write MetricDiff to a file.
1031
- pub fn save ( & self , p : & Path ) -> io:: IoResult < ( ) > {
1032
- let mut file = try!( File :: create ( p) ) ;
1033
- let MetricMap ( ref map) = * self ;
1034
- write ! ( & mut file, "{}" , json:: as_json( map) )
1035
- }
1036
-
1037
954
/// Insert a named `value` (+/- `noise`) metric into the map. The value
1038
955
/// must be non-negative. The `noise` indicates the uncertainty of the
1039
956
/// metric, which doubles as the "noise range" of acceptable
@@ -1055,6 +972,15 @@ impl MetricMap {
1055
972
let MetricMap ( ref mut map) = * self ;
1056
973
map. insert ( name. to_string ( ) , m) ;
1057
974
}
975
+
976
+ pub fn fmt_metrics ( & self ) -> String {
977
+ let MetricMap ( ref mm) = * self ;
978
+ let v : Vec < String > = mm. iter ( )
979
+ . map ( |( k, v) | format ! ( "{}: {} (+/- {})" , * k,
980
+ v. value as f64 , v. noise as f64 ) )
981
+ . collect ( ) ;
982
+ v. connect ( ", " )
983
+ }
1058
984
}
1059
985
1060
986
0 commit comments