Skip to content

Commit b13d6ef

Browse files
committed
test: rename --error-bar to --boxplot, add --boxplot-width=...
1 parent 07c12c7 commit b13d6ef

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

src/libtest/lib.rs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ pub struct TestOpts {
286286
pub logfile: Option<Path>,
287287
pub nocapture: bool,
288288
pub color: ColorConfig,
289-
pub show_error_bar: bool,
289+
pub show_boxplot: bool,
290+
pub boxplot_width: uint,
290291
pub show_all_stats: bool,
291292
}
292293

@@ -305,7 +306,8 @@ impl TestOpts {
305306
logfile: None,
306307
nocapture: false,
307308
color: AutoColor,
308-
show_error_bar: false,
309+
show_boxplot: false,
310+
boxplot_width: 50,
309311
show_all_stats: false,
310312
}
311313
}
@@ -338,7 +340,8 @@ fn optgroups() -> Vec<getopts::OptGroup> {
338340
auto = colorize if stdout is a tty and tests are run on serially (default);
339341
always = always colorize output;
340342
never = never colorize output;", "auto|always|never"),
341-
getopts::optflag("", "error-bar", "Display error bars for the benchmarks"),
343+
getopts::optflag("", "boxplot", "Display a boxplot of the benchmark statistics"),
344+
getopts::optopt("", "boxplot-width", "Set the boxplot width (default 50)", "WIDTH"),
342345
getopts::optflag("", "stats", "Display the benchmark min, max, and quartiles"))
343346
}
344347

@@ -430,7 +433,19 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
430433
v))),
431434
};
432435

433-
let show_error_bar = matches.opt_present("error-bar");
436+
let show_boxplot = matches.opt_present("boxplot");
437+
let boxplot_width = match matches.opt_str("boxplot-width") {
438+
Some(width) => {
439+
match FromStr::from_str(width.as_slice()) {
440+
Some(width) => width,
441+
None => {
442+
return Some(Err(format!("argument for --boxplot-width must be a uint")));
443+
}
444+
}
445+
}
446+
None => 50,
447+
};
448+
434449
let show_all_stats = matches.opt_present("stats");
435450

436451
let test_opts = TestOpts {
@@ -445,7 +460,8 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
445460
logfile: logfile,
446461
nocapture: nocapture,
447462
color: color,
448-
show_error_bar: show_error_bar,
463+
show_boxplot: show_boxplot,
464+
boxplot_width: boxplot_width,
449465
show_all_stats: show_all_stats,
450466
};
451467

@@ -497,7 +513,8 @@ struct ConsoleTestState<T> {
497513
log_out: Option<File>,
498514
out: OutputLocation<T>,
499515
use_color: bool,
500-
show_error_bar: bool,
516+
show_boxplot: bool,
517+
boxplot_width: uint,
501518
show_all_stats: bool,
502519
total: uint,
503520
passed: uint,
@@ -525,7 +542,8 @@ impl<T: Writer> ConsoleTestState<T> {
525542
out: out,
526543
log_out: log_out,
527544
use_color: use_color(opts),
528-
show_error_bar: opts.show_error_bar,
545+
show_boxplot: opts.show_boxplot,
546+
boxplot_width: opts.boxplot_width,
529547
show_all_stats: opts.show_all_stats,
530548
total: 0u,
531549
passed: 0u,
@@ -623,10 +641,10 @@ impl<T: Writer> ConsoleTestState<T> {
623641
TrBench(ref bs) => {
624642
try!(self.write_bench());
625643

626-
if self.show_error_bar {
644+
if self.show_boxplot {
627645
let mut wr = Vec::new();
628646

629-
try!(stats::write_boxplot(&mut wr, &bs.ns_iter_summ, 50));
647+
try!(stats::write_boxplot(&mut wr, &bs.ns_iter_summ, self.boxplot_width));
630648

631649
let s = String::from_utf8(wr).unwrap();
632650

0 commit comments

Comments
 (0)