@@ -54,15 +54,14 @@ use self::OutputLocation::*;
5454use stats:: Stats ;
5555use getopts:: { OptGroup , optflag, optopt} ;
5656use regex:: Regex ;
57- use serialize:: { json , Decodable , Encodable } ;
57+ use serialize:: Encodable ;
5858use term:: Terminal ;
5959use term:: color:: { Color , RED , YELLOW , GREEN , CYAN } ;
6060
6161use std:: any:: Any ;
6262use std:: cmp;
6363use std:: collections:: BTreeMap ;
6464use std:: fmt;
65- use std:: io:: fs:: PathExtensions ;
6665use std:: io:: stdio:: StdWriter ;
6766use std:: io:: { File , ChanReader , ChanWriter } ;
6867use std:: io;
@@ -438,9 +437,6 @@ struct ConsoleTestState<T> {
438437 log_out : Option < File > ,
439438 out : OutputLocation < T > ,
440439 use_color : bool ,
441- show_boxplot : bool ,
442- boxplot_width : uint ,
443- show_all_stats : bool ,
444440 total : uint ,
445441 passed : uint ,
446442 failed : uint ,
@@ -467,9 +463,6 @@ impl<T: Writer> ConsoleTestState<T> {
467463 out : out,
468464 log_out : log_out,
469465 use_color : use_color ( opts) ,
470- show_boxplot : false ,
471- boxplot_width : 50 ,
472- show_all_stats : false ,
473466 total : 0 u,
474467 passed : 0 u,
475468 failed : 0 u,
@@ -545,33 +538,13 @@ impl<T: Writer> ConsoleTestState<T> {
545538 TrIgnored => self . write_ignored ( ) ,
546539 TrMetrics ( ref mm) => {
547540 try!( self . write_metric ( ) ) ;
548- self . write_plain ( format ! ( ": {}" , fmt_metrics( mm ) ) . as_slice ( ) )
541+ self . write_plain ( format ! ( ": {}" , mm . fmt_metrics( ) ) . as_slice ( ) )
549542 }
550543 TrBench ( ref bs) => {
551544 try!( self . write_bench ( ) ) ;
552545
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 ( ) ) ) ;
575548
576549 Ok ( ( ) )
577550 }
@@ -588,7 +561,7 @@ impl<T: Writer> ConsoleTestState<T> {
588561 TrOk => "ok" . to_string( ) ,
589562 TrFailed => "failed" . to_string( ) ,
590563 TrIgnored => "ignored" . to_string( ) ,
591- TrMetrics ( ref mm) => fmt_metrics( mm ) ,
564+ TrMetrics ( ref mm) => mm . fmt_metrics( ) ,
592565 TrBench ( ref bs) => fmt_bench_samples( bs)
593566 } , test. name. as_slice( ) ) ;
594567 o. write ( s. as_bytes ( ) )
@@ -624,34 +597,14 @@ impl<T: Writer> ConsoleTestState<T> {
624597 Ok ( ( ) )
625598 }
626599
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 > {
630601 assert ! ( self . passed + self . failed + self . ignored + self . measured == self . total) ;
631602
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 {
650605 try!( self . write_failures ( ) ) ;
651606 }
652607
653- let success = ratchet_success && test_success;
654-
655608 try!( self . write_plain ( "\n test result: " ) ) ;
656609 if success {
657610 // There's no parallelism at this point so it's safe to use color
@@ -666,15 +619,6 @@ impl<T: Writer> ConsoleTestState<T> {
666619 }
667620}
668621
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-
678622pub fn fmt_bench_samples ( bs : & BenchSamples ) -> String {
679623 if bs. mb_s != 0 {
680624 format ! ( "{:>9} ns/iter (+/- {}) = {} MB/s" ,
@@ -745,7 +689,7 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn> ) -> io::IoR
745689 None => { }
746690 }
747691 try!( run_tests ( opts, tests, |x| callback ( & x, & mut st) ) ) ;
748- return st. write_run_finish ( & None , None ) ;
692+ return st. write_run_finish ( ) ;
749693}
750694
751695#[ test]
@@ -766,9 +710,6 @@ fn should_sort_failures_before_printing_them() {
766710 log_out : None ,
767711 out : Raw ( Vec :: new ( ) ) ,
768712 use_color : false ,
769- show_boxplot : false ,
770- boxplot_width : 0 ,
771- show_all_stats : false ,
772713 total : 0 u,
773714 passed : 0 u,
774715 failed : 0 u,
@@ -1010,30 +951,6 @@ impl MetricMap {
1010951 MetricMap ( BTreeMap :: new ( ) )
1011952 }
1012953
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-
1037954 /// Insert a named `value` (+/- `noise`) metric into the map. The value
1038955 /// must be non-negative. The `noise` indicates the uncertainty of the
1039956 /// metric, which doubles as the "noise range" of acceptable
@@ -1055,6 +972,15 @@ impl MetricMap {
1055972 let MetricMap ( ref mut map) = * self ;
1056973 map. insert ( name. to_string ( ) , m) ;
1057974 }
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+ }
1058984}
1059985
1060986
0 commit comments