Skip to content

Commit 6688f8c

Browse files
committed
---
yaml --- r: 162222 b: refs/heads/auto c: 6f4c11b h: refs/heads/master v: v3
1 parent 0673c29 commit 6688f8c

File tree

4 files changed

+74
-12
lines changed

4 files changed

+74
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 33f34bdb4e67e670b6b6979c690c510eab00c135
13+
refs/heads/auto: 6f4c11be3b9706d1ba0e1b74b89de1478410a56f
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/compiletest/compiletest.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
286286
test_shard: config.test_shard.clone(),
287287
nocapture: false,
288288
color: test::AutoColor,
289+
show_boxplot: false,
290+
boxplot_width: 50,
291+
show_all_stats: false,
289292
}
290293
}
291294

branches/auto/src/libtest/lib.rs

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ pub struct TestOpts {
285285
pub logfile: Option<Path>,
286286
pub nocapture: bool,
287287
pub color: ColorConfig,
288+
pub show_boxplot: bool,
289+
pub boxplot_width: uint,
290+
pub show_all_stats: bool,
288291
}
289292

290293
impl TestOpts {
@@ -302,6 +305,9 @@ impl TestOpts {
302305
logfile: None,
303306
nocapture: false,
304307
color: AutoColor,
308+
show_boxplot: false,
309+
boxplot_width: 50,
310+
show_all_stats: false,
305311
}
306312
}
307313
}
@@ -332,7 +338,10 @@ fn optgroups() -> Vec<getopts::OptGroup> {
332338
getopts::optopt("", "color", "Configure coloring of output:
333339
auto = colorize if stdout is a tty and tests are run on serially (default);
334340
always = always colorize output;
335-
never = never colorize output;", "auto|always|never"))
341+
never = never colorize output;", "auto|always|never"),
342+
getopts::optflag("", "boxplot", "Display a boxplot of the benchmark statistics"),
343+
getopts::optopt("", "boxplot-width", "Set the boxplot width (default 50)", "WIDTH"),
344+
getopts::optflag("", "stats", "Display the benchmark min, max, and quartiles"))
336345
}
337346

338347
fn usage(binary: &str) {
@@ -423,6 +432,21 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
423432
v))),
424433
};
425434

435+
let show_boxplot = matches.opt_present("boxplot");
436+
let boxplot_width = match matches.opt_str("boxplot-width") {
437+
Some(width) => {
438+
match FromStr::from_str(width.as_slice()) {
439+
Some(width) => width,
440+
None => {
441+
return Some(Err(format!("argument for --boxplot-width must be a uint")));
442+
}
443+
}
444+
}
445+
None => 50,
446+
};
447+
448+
let show_all_stats = matches.opt_present("stats");
449+
426450
let test_opts = TestOpts {
427451
filter: filter,
428452
run_ignored: run_ignored,
@@ -435,6 +459,9 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
435459
logfile: logfile,
436460
nocapture: nocapture,
437461
color: color,
462+
show_boxplot: show_boxplot,
463+
boxplot_width: boxplot_width,
464+
show_all_stats: show_all_stats,
438465
};
439466

440467
Some(Ok(test_opts))
@@ -485,6 +512,9 @@ struct ConsoleTestState<T> {
485512
log_out: Option<File>,
486513
out: OutputLocation<T>,
487514
use_color: bool,
515+
show_boxplot: bool,
516+
boxplot_width: uint,
517+
show_all_stats: bool,
488518
total: uint,
489519
passed: uint,
490520
failed: uint,
@@ -511,6 +541,9 @@ impl<T: Writer> ConsoleTestState<T> {
511541
out: out,
512542
log_out: log_out,
513543
use_color: use_color(opts),
544+
show_boxplot: opts.show_boxplot,
545+
boxplot_width: opts.boxplot_width,
546+
show_all_stats: opts.show_all_stats,
514547
total: 0u,
515548
passed: 0u,
516549
failed: 0u,
@@ -606,8 +639,31 @@ impl<T: Writer> ConsoleTestState<T> {
606639
}
607640
TrBench(ref bs) => {
608641
try!(self.write_bench());
609-
self.write_plain(format!(": {}",
610-
fmt_bench_samples(bs)).as_slice())
642+
643+
if self.show_boxplot {
644+
let mut wr = Vec::new();
645+
646+
try!(stats::write_boxplot(&mut wr, &bs.ns_iter_summ, self.boxplot_width));
647+
648+
let s = String::from_utf8(wr).unwrap();
649+
650+
try!(self.write_plain(format!(": {}", s).as_slice()));
651+
}
652+
653+
if self.show_all_stats {
654+
let mut wr = Vec::new();
655+
656+
try!(stats::write_5_number_summary(&mut wr, &bs.ns_iter_summ));
657+
658+
let s = String::from_utf8(wr).unwrap();
659+
660+
try!(self.write_plain(format!(": {}", s).as_slice()));
661+
} else {
662+
try!(self.write_plain(format!(": {}",
663+
fmt_bench_samples(bs)).as_slice()));
664+
}
665+
666+
Ok(())
611667
}
612668
});
613669
self.write_plain("\n")
@@ -680,14 +736,14 @@ impl<T: Writer> ConsoleTestState<T> {
680736
}
681737
Improvement(pct) => {
682738
improved += 1;
683-
try!(self.write_plain(format!(": {}", *k).as_slice()));
739+
try!(self.write_plain(format!(": {} ", *k).as_slice()));
684740
try!(self.write_improved());
685741
try!(self.write_plain(format!(" by {:.2}%\n",
686742
pct as f64).as_slice()));
687743
}
688744
Regression(pct) => {
689745
regressed += 1;
690-
try!(self.write_plain(format!(": {}", *k).as_slice()));
746+
try!(self.write_plain(format!(": {} ", *k).as_slice()));
691747
try!(self.write_regressed());
692748
try!(self.write_plain(format!(" by {:.2}%\n",
693749
pct as f64).as_slice()));
@@ -859,6 +915,9 @@ fn should_sort_failures_before_printing_them() {
859915
log_out: None,
860916
out: Raw(Vec::new()),
861917
use_color: false,
918+
show_boxplot: false,
919+
boxplot_width: 0,
920+
show_all_stats: false,
862921
total: 0u,
863922
passed: 0u,
864923
failed: 0u,

branches/auto/src/libtest/stats.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
331331
}
332332

333333
/// Render writes the min, max and quartiles of the provided `Summary` to the provided `Writer`.
334-
pub fn write_5_number_summary<T: Float + Show>(w: &mut io::Writer,
335-
s: &Summary<T>) -> io::IoResult<()> {
334+
pub fn write_5_number_summary<W: Writer, T: Float + Show>(w: &mut W,
335+
s: &Summary<T>) -> io::IoResult<()> {
336336
let (q1,q2,q3) = s.quartiles;
337337
write!(w, "(min={}, q1={}, med={}, q3={}, max={})",
338338
s.min,
@@ -353,8 +353,8 @@ pub fn write_5_number_summary<T: Float + Show>(w: &mut io::Writer,
353353
/// ```{.ignore}
354354
/// 10 | [--****#******----------] | 40
355355
/// ```
356-
pub fn write_boxplot<T: Float + Show + FromPrimitive>(
357-
w: &mut io::Writer,
356+
pub fn write_boxplot<W: Writer, T: Float + Show + FromPrimitive>(
357+
w: &mut W,
358358
s: &Summary<T>,
359359
width_hint: uint)
360360
-> io::IoResult<()> {
@@ -473,7 +473,7 @@ mod tests {
473473
let summ2 = Summary::new(samples);
474474

475475
let mut w = io::stdout();
476-
let w = &mut w as &mut io::Writer;
476+
let w = &mut w;
477477
(write!(w, "\n")).unwrap();
478478
write_5_number_summary(w, &summ2).unwrap();
479479
(write!(w, "\n")).unwrap();
@@ -1028,7 +1028,7 @@ mod tests {
10281028
fn test_boxplot_nonpositive() {
10291029
fn t(s: &Summary<f64>, expected: String) {
10301030
let mut m = Vec::new();
1031-
write_boxplot(&mut m as &mut io::Writer, s, 30).unwrap();
1031+
write_boxplot(&mut m, s, 30).unwrap();
10321032
let out = String::from_utf8(m).unwrap();
10331033
assert_eq!(out, expected);
10341034
}

0 commit comments

Comments
 (0)