From 771d814be1d2a8ac11eb6478ab529918ac367027 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 19 Nov 2014 13:58:07 -0500 Subject: [PATCH] fix(lib): adapt to upstream changes See: japaric/simplot.rs#11 japaric/stats.rs#23 rust-lang/rust#18973 --- src/analysis/compare.rs | 8 +- src/analysis/mod.rs | 18 ++-- src/estimate.rs | 10 +- src/lib.rs | 16 +-- src/plot/both.rs | 41 ++++---- src/plot/mod.rs | 224 ++++++++++++++++++++-------------------- 6 files changed, 159 insertions(+), 158 deletions(-) diff --git a/src/analysis/compare.rs b/src/analysis/compare.rs index 78709d311..72ee6697b 100644 --- a/src/analysis/compare.rs +++ b/src/analysis/compare.rs @@ -1,13 +1,15 @@ -use stats::ttest::{TDistribution, TwoTailed}; +use stats::ttest::{TDistribution, Tails}; use stats::{Stats, mod}; use time; use Criterion; -use estimate::{Distributions, Estimate, Estimates, Mean, Median}; +use estimate::Statistic::{Mean, Median}; +use estimate::{Distributions, Estimate, Estimates}; use format; use fs; use plot; use report; +use self::ComparisonResult::{Improved, NonSignificant, Regressed}; // Common comparison procedure pub fn common( @@ -67,7 +69,7 @@ fn t_test(id: &str, times: &[f64], base_times: &[f64], criterion: &Criterion) -> let t_distribution = elapsed!( "Bootstrapping the T distribution", TDistribution::new(times, base_times, nresamples)); - let p_value = t_distribution.p_value(t_statistic, TwoTailed); + let p_value = t_distribution.p_value(t_statistic, Tails::Two); let different_mean = p_value < sl; println!(" > p = {}", p_value); diff --git a/src/analysis/mod.rs b/src/analysis/mod.rs index 350b3f3d8..118a0f158 100644 --- a/src/analysis/mod.rs +++ b/src/analysis/mod.rs @@ -10,12 +10,8 @@ use estimate::{ Distributions, Estimate, Estimates, - Mean, - Median, - MedianAbsDev, - StdDev, - mod, }; +use estimate::Statistic; use format; use fs; use plot; @@ -119,8 +115,8 @@ fn common(id: &str, routine: &mut R, criterion: &Criterion) { let (distribution, slope) = regression(id, pairs_f64, criterion); let (mut distributions, mut estimates) = estimates(times, criterion); - estimates.insert(estimate::Slope, slope); - distributions.insert(estimate::Slope, distribution); + estimates.insert(Statistic::Slope, slope); + distributions.insert(Statistic::Slope, distribution); if criterion.plotting.is_enabled() { elapsed!( @@ -235,7 +231,13 @@ fn estimates( vec![a, b, c, d] }; - let distributions: Distributions = [Mean, Median, MedianAbsDev, StdDev].iter().map(|&x| { + let statistics = [ + Statistic::Mean, + Statistic::Median, + Statistic::MedianAbsDev, + Statistic::StdDev, + ]; + let distributions: Distributions = statistics.iter().map(|&x| { x }).zip(distributions.into_iter()).collect(); let estimates = Estimate::new(&distributions, points[], cl); diff --git a/src/estimate.rs b/src/estimate.rs index 762ddf363..620433462 100644 --- a/src/estimate.rs +++ b/src/estimate.rs @@ -45,11 +45,11 @@ pub enum Statistic { impl Show for Statistic { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match *self { - Mean => f.pad("mean"), - Median => f.pad("median"), - MedianAbsDev => f.pad("MAD"), - Slope => f.pad("slope"), - StdDev => f.pad("SD"), + Statistic::Mean => f.pad("mean"), + Statistic::Median => f.pad("median"), + Statistic::MedianAbsDev => f.pad("MAD"), + Statistic::Slope => f.pad("slope"), + Statistic::StdDev => f.pad("SD"), } } } diff --git a/src/lib.rs b/src/lib.rs index af4945106..787463ded 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -89,7 +89,7 @@ enum Plotting { impl Plotting { fn is_enabled(&self) -> bool { match *self { - Enabled => true, + Plotting::Enabled => true, _ => false, } } @@ -111,11 +111,11 @@ impl Criterion { #[experimental] pub fn default() -> Criterion { let plotting = if simplot::version().is_ok() { - Enabled + Plotting::Enabled } else { println!("Gnuplot not found, disabling plotting"); - NotAvailable + Plotting::NotAvailable }; Criterion { @@ -255,8 +255,8 @@ impl Criterion { #[experimental] pub fn with_plots(&mut self) -> &mut Criterion { match self.plotting { - NotAvailable => {}, - _ => self.plotting = Enabled, + Plotting::NotAvailable => {}, + _ => self.plotting = Plotting::Enabled, } self @@ -266,8 +266,8 @@ impl Criterion { #[experimental] pub fn without_plots(&mut self) -> &mut Criterion { match self.plotting { - NotAvailable => {}, - _ => self.plotting = Disabled, + Plotting::NotAvailable => {}, + _ => self.plotting = Plotting::Disabled, } self @@ -276,7 +276,7 @@ impl Criterion { /// Checks if plotting is possible pub fn can_plot(&self) -> bool { match self.plotting { - NotAvailable => false, + Plotting::NotAvailable => false, _ => true, } } diff --git a/src/plot/both.rs b/src/plot/both.rs index 35d4ca837..ff92016d2 100644 --- a/src/plot/both.rs +++ b/src/plot/both.rs @@ -1,15 +1,14 @@ -use simplot::axis::{BottomX, LeftY, RightY}; -use simplot::curve::Lines; -use simplot::grid::Major; -use simplot::key::{Inside, Left, LeftJustified, Outside, Right, SampleText, Top}; -use simplot::{Figure, Solid}; +use simplot::curve::Style::{Lines}; +use simplot::key::{Horizontal, Justification, Order, Position, Vertical}; +use simplot::{Axis, Figure, Grid, LineType}; use stats::ConfidenceInterval; use std::iter::Repeat; use std::num::Float; use std::str; use test::stats::Stats; -use estimate::{Estimate, Estimates, Slope}; +use estimate::{Estimate, Estimates}; +use estimate::Statistic::Slope; use kde; use super::scale_time; use super::{DARK_BLUE, DARK_RED}; @@ -82,19 +81,19 @@ pub fn regression( output(path). size(PLOT_SIZE). title(id.to_string()). - axis(BottomX, |a| a. - grid(Major, |g| g. + axis(Axis::BottomX, |a| a. + grid(Grid::Major, |g| g. show()). // FIXME (unboxed closures) remove cloning label(x_label.to_string())). - axis(LeftY, |a| a. - grid(Major, |g| g. + axis(Axis::LeftY, |a| a. + grid(Grid::Major, |g| g. show()). label(format!("Total time ({}s)", prefix))). key(|k| k. - justification(LeftJustified). - order(SampleText). - position(Inside(Top, Left))). + justification(Justification::Left). + order(Order::SampleText). + position(Position::Inside(Vertical::Top, Horizontal::Left))). filled_curve([0., max_iters].iter(), [0., base_lb].iter(), [0., base_ub].iter(), |c| c. color(DARK_RED). opacity(0.25)). @@ -104,12 +103,12 @@ pub fn regression( curve(Lines, [0., max_iters].iter(), [0., base_point].iter(), |c| c. color(DARK_RED). label("Base sample"). - line_type(Solid). + line_type(LineType::Solid). linewidth(2.)). curve(Lines, [0., max_iters].iter(), [0., new_point].iter(), |c| c. color(DARK_BLUE). label("New sample"). - line_type(Solid). + line_type(LineType::Solid). linewidth(2.)). draw().unwrap(); @@ -137,16 +136,16 @@ pub fn pdfs(base: &[f64], new: &[f64], id: &str) { output(path). size(PLOT_SIZE). title(id.to_string()). - axis(BottomX, |a| a. + axis(Axis::BottomX, |a| a. label(format!("Average time ({}s)", prefix))). - axis(LeftY, |a| a. + axis(Axis::LeftY, |a| a. label("Density (a.u.)")). - axis(RightY, |a| a. + axis(Axis::RightY, |a| a. hide()). key(|k| k. - justification(LeftJustified). - order(SampleText). - position(Outside(Top, Right))). + justification(Justification::Left). + order(Order::SampleText). + position(Position::Outside(Vertical::Top, Horizontal::Right))). filled_curve(base_xs, base_ys, zeros, |c| c. color(DARK_RED). label("Base PDF"). diff --git a/src/plot/mod.rs b/src/plot/mod.rs index db52f5133..37bcbfd0f 100644 --- a/src/plot/mod.rs +++ b/src/plot/mod.rs @@ -1,10 +1,7 @@ -use simplot::axis::{BottomX, LeftY, Linear, Logarithmic, RightY}; -use simplot::color::{Black, Color, Rgb}; -use simplot::curve::{Lines, Points}; -use simplot::errorbar::{XErrorBar, YErrorBar}; -use simplot::grid::{Major, Minor}; -use simplot::key::{Inside, Left, LeftJustified, Outside, Right, SampleText, Top}; -use simplot::{BottomXRightY, Dash, Figure, FilledCircle, Plus, Solid}; +use simplot::curve::Style::{Lines, Points}; +use simplot::errorbar::Style::{XErrorBar, YErrorBar}; +use simplot::key::{Horizontal, Justification, Order, Position, Vertical}; +use simplot::{Axes, Axis, Color, Figure, Grid, LineType, PointType, Scale}; use stats::Stats; use stats::outliers::{Outliers, LowMild, LowSevere, HighMild, HighSevere}; use stats::regression::Slope; @@ -13,7 +10,8 @@ use std::iter::{Repeat, mod}; use std::num::Float; use std::str; -use estimate::{Distributions, Estimate, Estimates, Mean, Median, mod}; +use estimate::Statistic; +use estimate::{Distributions, Estimate, Estimates}; use fs; use kde; @@ -41,9 +39,9 @@ static PLOT_SIZE: (uint, uint) = (1280, 720); static LINEWIDTH: f64 = 2.; static POINT_SIZE: f64 = 0.75; -static DARK_BLUE: Color = Rgb(31, 120, 180); -static DARK_ORANGE: Color = Rgb(255, 127, 0); -static DARK_RED: Color = Rgb(227, 26, 28); +static DARK_BLUE: Color = Color::Rgb(31, 120, 180); +static DARK_ORANGE: Color = Color::Rgb(255, 127, 0); +static DARK_RED: Color = Color::Rgb(227, 26, 28); pub fn pdf(pairs: &[(f64, f64)], sample: &[f64], outliers: &Outliers, id: &str) { let path = Path::new(format!(".criterion/{}/new/pdf.svg", id)); @@ -93,54 +91,54 @@ pub fn pdf(pairs: &[(f64, f64)], sample: &[f64], outliers: &Outliers, id: & output(path). size(PLOT_SIZE). title(id.to_string()). - axis(BottomX, |a| a. + axis(Axis::BottomX, |a| a. label(format!("Average time ({}s)", prefix)). range(xs[].min(), xs[].max())). - axis(LeftY, |a| a. + axis(Axis::LeftY, |a| a. // FIXME (unboxed closures) Remove cloning label(y_label.to_string()). range(0., max_iters * y_scale)). - axis(RightY, |a| a. + axis(Axis::RightY, |a| a. label("Density (a.u.)")). key(|k| k. - justification(LeftJustified). - order(SampleText). - position(Outside(Top, Right))). + justification(Justification::Left). + order(Order::SampleText). + position(Position::Outside(Vertical::Top, Horizontal::Right))). filled_curve(xs.iter(), ys.iter(), zeros, |c| c. - axes(BottomXRightY). + axes(Axes::BottomXRightY). color(DARK_BLUE). label("PDF"). opacity(0.25)). curve(Points, normal.iter().map(|x| x.val1()), normal.iter().map(|x| x.val0()), |c| c. color(DARK_BLUE). label("\"Clean\" sample"). - point_type(FilledCircle). + point_type(PointType::FilledCircle). point_size(POINT_SIZE)). curve(Points, mild.iter().map(|x| x.val1()), mild.iter().map(|x| x.val0()), |c| c. color(DARK_ORANGE). label("Mild outliers"). - point_type(FilledCircle). + point_type(PointType::FilledCircle). point_size(POINT_SIZE)). curve(Points, severe.iter().map(|x| x.val1()), severe.iter().map(|x| x.val0()), |c| c. color(DARK_RED). label("Severe outliers"). - point_type(FilledCircle). + point_type(PointType::FilledCircle). point_size(POINT_SIZE)). curve(Lines, [lomt, lomt].iter(), vertical.iter(), |c| c. color(DARK_ORANGE). - line_type(Dash). + line_type(LineType::Dash). linewidth(LINEWIDTH)). curve(Lines, [himt, himt].iter(), vertical.iter(), |c| c. color(DARK_ORANGE). - line_type(Dash). + line_type(LineType::Dash). linewidth(LINEWIDTH)). curve(Lines, [lost, lost].iter(), vertical.iter(), |c| c. color(DARK_RED). - line_type(Dash). + line_type(LineType::Dash). linewidth(LINEWIDTH)). curve(Lines, [hist, hist].iter(), vertical.iter(), |c| c. color(DARK_RED). - line_type(Dash). + line_type(LineType::Dash). linewidth(LINEWIDTH)). draw().unwrap(); @@ -193,27 +191,27 @@ pub fn regression( size(PLOT_SIZE). title(id.to_string()). key(|k| k. - justification(LeftJustified). - order(SampleText). - position(Inside(Top, Left))). - axis(BottomX, |a| a. - grid(Major, |g| g. + justification(Justification::Left). + order(Order::SampleText). + position(Position::Inside(Vertical::Top, Horizontal::Left))). + axis(Axis::BottomX, |a| a. + grid(Grid::Major, |g| g. show()). // FIXME (unboxed closures) Remove cloning label(x_label.to_string())). - axis(LeftY, |a| a. - grid(Major, |g| g. + axis(Axis::LeftY, |a| a. + grid(Grid::Major, |g| g. show()). label(format!("Total time ({}s)", prefix))). curve(Points, iters.iter(), elapsed.iter(), |c| c. color(DARK_BLUE). label("Sample"). - point_type(FilledCircle). + point_type(PointType::FilledCircle). point_size(0.5)). curve(Lines, [0., max_iters].iter(), [0., point].iter(), |c| c. color(DARK_BLUE). label("Linear regression"). - line_type(Solid). + line_type(LineType::Solid). linewidth(LINEWIDTH)). filled_curve([0., max_iters].iter(), [0., lb].iter(), [0., ub].iter(), |c| c. color(DARK_BLUE). @@ -259,19 +257,19 @@ pub fn abs_distributions(distributions: &Distributions, estimates: &Estimates, i output(Path::new(format!(".criterion/{}/new/{}.svg", id, statistic))). size(PLOT_SIZE). title(format!("{}: {}", id, statistic)). - axis(BottomX, |a| a. + axis(Axis::BottomX, |a| a. label(format!("Average time ({}s)", prefix)). range(xs[].min(), xs[].max())). - axis(LeftY, |a| a. + axis(Axis::LeftY, |a| a. label("Density (a.u.)")). key(|k| k. - justification(LeftJustified). - order(SampleText). - position(Outside(Top, Right))). + justification(Justification::Left). + order(Order::SampleText). + position(Position::Outside(Vertical::Top, Horizontal::Right))). curve(Lines, xs.iter(), ys.iter(), |c| c. color(DARK_BLUE). label("Bootstrap distribution"). - line_type(Solid). + line_type(LineType::Solid). linewidth(LINEWIDTH)). filled_curve(xs.iter().skip(start).take(len), ys.iter().skip(start), zero, |c| c. color(DARK_BLUE). @@ -280,7 +278,7 @@ pub fn abs_distributions(distributions: &Distributions, estimates: &Estimates, i curve(Lines, [p, p].iter(), [0., y_p].iter(), |c| c. color(DARK_BLUE). label("Point estimate"). - line_type(Dash). + line_type(LineType::Dash). linewidth(LINEWIDTH)). draw().unwrap() }).collect::>(); @@ -304,12 +302,12 @@ pub fn rel_distributions( figure. font(FONT). size(PLOT_SIZE). - axis(LeftY, |a| a. + axis(Axis::LeftY, |a| a. label("Density (a.u.)")). key(|k| k. - justification(LeftJustified). - order(SampleText). - position(Outside(Top, Right))); + justification(Justification::Left). + order(Order::SampleText). + position(Position::Outside(Vertical::Top, Horizontal::Right))); let gnuplots = distributions.iter().map(|(&statistic, distribution)| { let path = Path::new(format!(".criterion/{}/change/{}.svg", id, statistic)); @@ -353,13 +351,13 @@ pub fn rel_distributions( figure.clone(). output(path). title(format!("{}: {}", id, statistic)). - axis(BottomX, |a| a. + axis(Axis::BottomX, |a| a. label("Relative change (%)"). range(x_min, x_max)). curve(Lines, xs.iter(), ys.iter(), |c| c. color(DARK_BLUE). label("Bootstrap distribution"). - line_type(Solid). + line_type(LineType::Solid). linewidth(LINEWIDTH)). filled_curve(xs.iter().skip(start).take(len), ys.iter().skip(start), zero, |c| c. color(DARK_BLUE). @@ -368,10 +366,10 @@ pub fn rel_distributions( curve(Lines, [p, p].iter(), [0., y_p].iter(), |c| c. color(DARK_BLUE). label("Point estimate"). - line_type(Dash). + line_type(LineType::Dash). linewidth(LINEWIDTH)). filled_curve([fc_start, fc_end].iter(), one, zero, |c| c. - axes(BottomXRightY). + axes(Axes::BottomXRightY). color(DARK_RED). label("Noise threshold"). opacity(0.1)). @@ -398,23 +396,23 @@ pub fn t_test(t: f64, distribution: &[f64], id: &str) { output(path). size(PLOT_SIZE). title(format!("{}: Welch t test", id)). - axis(BottomX, |a| a. + axis(Axis::BottomX, |a| a. label("t score")). - axis(LeftY, |a| a. + axis(Axis::LeftY, |a| a. label("Density")). key(|k| k. - justification(LeftJustified). - order(SampleText). - position(Outside(Top, Right))). + justification(Justification::Left). + order(Order::SampleText). + position(Position::Outside(Vertical::Top, Horizontal::Right))). filled_curve(xs.iter(), ys.iter(), zero, |c| c. color(DARK_BLUE). label("t distribution"). opacity(0.25)). curve(Lines, [t, t].iter(), [0u, 1].iter(), |c| c. - axes(BottomXRightY). + axes(Axes::BottomXRightY). color(DARK_BLUE). label("t statistic"). - line_type(Solid). + line_type(LineType::Solid). linewidth(LINEWIDTH)). draw().unwrap(); @@ -491,7 +489,7 @@ pub fn summarize(id: &str) { a.cmp(&b) }); - [Mean, Median, estimate::Slope].iter().map(|&statistic| { + [Statistic::Mean, Statistic::Median, Statistic::Slope].iter().map(|&statistic| { let points = benches.iter().map(|&(_, _, ref estimates, _)| { estimates[statistic].point_estimate }).collect::>(); @@ -512,7 +510,7 @@ pub fn summarize(id: &str) { // XXX Logscale triggering may need tweaking let xscale = if inputs.len() < 3 { - Linear + Scale::Linear } else { let inputs = inputs.iter().map(|&x| x as f64).collect::>(); let linear = diff(inputs[])[].std_dev(None); @@ -522,14 +520,14 @@ pub fn summarize(id: &str) { }; if linear < log { - Linear + Scale::Linear } else { - Logarithmic + Scale::Logarithmic } }; let yscale = if points.len() < 3 { - Linear + Scale::Linear } else { let linear = diff(points[])[].std_dev(None); let log = { @@ -538,9 +536,9 @@ pub fn summarize(id: &str) { }; if linear < log { - Linear + Scale::Linear } else { - Logarithmic + Scale::Logarithmic } }; @@ -551,36 +549,36 @@ pub fn summarize(id: &str) { output(dir.join(format!("summary/{}/{}s.svg", sample, statistic))). size(PLOT_SIZE). title(format!("{}", id)). - axis(BottomX, |a| a. - grid(Major, |g| g. + axis(Axis::BottomX, |a| a. + grid(Grid::Major, |g| g. show()). - grid(Minor, |g| match xscale { - Linear => g.hide(), - Logarithmic => g.show(), + grid(Grid::Minor, |g| match xscale { + Scale::Linear => g.hide(), + Scale::Logarithmic => g.show(), }). label("Input"). scale(xscale)). - axis(BottomX, |a| match xscale { - Linear => a, - Logarithmic => { + axis(Axis::BottomX, |a| match xscale { + Scale::Linear => a, + Scale::Logarithmic => { let start = inputs[0] as f64; let end = *inputs.last().unwrap() as f64; a.range(log_floor(start), log_ceil(end)) }, }). - axis(LeftY, |a| a. - grid(Major, |g| g. + axis(Axis::LeftY, |a| a. + grid(Grid::Major, |g| g. show()). - grid(Minor, |g| match xscale { - Linear => g.hide(), - Logarithmic => g.show(), + grid(Grid::Minor, |g| match xscale { + Scale::Linear => g.hide(), + Scale::Logarithmic => g.show(), }). label(format!("Average time ({}s)", prefix)). scale(yscale)). - axis(LeftY, |a| match yscale { - Linear => a, - Logarithmic => { + axis(Axis::LeftY, |a| match yscale { + Scale::Linear => a, + Scale::Logarithmic => { let start = lbs[].min(); let end = ubs[].max(); @@ -588,19 +586,19 @@ pub fn summarize(id: &str) { }, }). key(|k| k. - justification(LeftJustified). - order(SampleText). - position(Inside(Top, Left))). - error_bar(YErrorBar, inputs.iter(), points, lbs.iter(), ubs.iter(), |eb| eb. + justification(Justification::Left). + order(Order::SampleText). + position(Position::Inside(Vertical::Top, Horizontal::Left))). + error_bar(YErrorBar, inputs.iter(), points, lbs.iter(), ubs.iter(), |e| e. label(format!("{}", statistic)). linewidth(LINEWIDTH). point_size(POINT_SIZE). - point_type(FilledCircle)). + point_type(PointType::FilledCircle)). draw().unwrap() }).collect::>() } else { // NB median go last because we reuse the ordered set in the next step (summary) - [Mean, estimate::Slope, Median].iter().map(|&statistic| { + [Statistic::Mean, Statistic::Slope, Statistic::Median].iter().map(|&statistic| { benches.sort_by(|&(_, _, ref a, _), &(_, _, ref b, _)| { let a = a[statistic].point_estimate; let b = b[statistic].point_estimate; @@ -623,7 +621,7 @@ pub fn summarize(id: &str) { let ubs = ubs.iter().map(|&x| x * scale).collect::>(); let xscale = if points.len() < 3 { - Linear + Scale::Linear } else { let linear = diff(points[])[].std_dev(None); let log = { @@ -632,9 +630,9 @@ pub fn summarize(id: &str) { }; if linear < log { - Linear + Scale::Linear } else { - Logarithmic + Scale::Logarithmic } }; @@ -650,36 +648,36 @@ pub fn summarize(id: &str) { output(dir.join(format!("summary/{}/{}s.svg", sample, statistic))). size(PLOT_SIZE). title(format!("{}: Estimates of the {}s", id, statistic)). - axis(BottomX, |a| a. - grid(Major, |g| g. + axis(Axis::BottomX, |a| a. + grid(Grid::Major, |g| g. show()). - grid(Minor, |g| match xscale { - Linear => g.hide(), - Logarithmic => g.show(), + grid(Grid::Minor, |g| match xscale { + Scale::Linear => g.hide(), + Scale::Logarithmic => g.show(), }). label(format!("Average time ({}s)", prefix)). scale(xscale)). - axis(BottomX, |a| match xscale { - Linear => a, - Logarithmic => { + axis(Axis::BottomX, |a| match xscale { + Scale::Linear => a, + Scale::Logarithmic => { let start = lbs[].min(); let end = ubs[].max(); a.range(log_floor(start), log_ceil(end)) }, }). - axis(LeftY, |a| a. + axis(Axis::LeftY, |a| a. label("Input"). range(0., benches.len() as f64). tics(tics, benches.iter().map(|&(label, _, _, _)| label))). - axis(RightY, |a| a. + axis(Axis::RightY, |a| a. label("Relative time"). range(0., benches.len() as f64). tics(tics, rel.iter().map(|x| x.as_slice()))). error_bar(XErrorBar, points, y, lbs.iter(), ubs.iter(), |eb| eb. label("Confidence Interval"). linewidth(LINEWIDTH). - point_type(FilledCircle). + point_type(PointType::FilledCircle). point_size(POINT_SIZE)). draw().unwrap() }).collect::>().append_({ @@ -712,7 +710,7 @@ pub fn summarize(id: &str) { max *= scale; let xscale = if medians.len() < 3 { - Linear + Scale::Linear } else { let linear = diff(medians[])[].std_dev(None); let log = { @@ -721,9 +719,9 @@ pub fn summarize(id: &str) { }; if linear < log { - Linear + Scale::Linear } else { - Logarithmic + Scale::Logarithmic } }; @@ -734,29 +732,29 @@ pub fn summarize(id: &str) { output(dir.join(format!("summary/{}/violin_plot.svg", sample))). size(PLOT_SIZE). title(format!("{}: Violin plot", id)). - axis(BottomX, |a| a. - grid(Major, |g| g. + axis(Axis::BottomX, |a| a. + grid(Grid::Major, |g| g. show()). - grid(Minor, |g| match xscale { - Linear => g.hide(), - Logarithmic => g.show(), + grid(Grid::Minor, |g| match xscale { + Scale::Linear => g.hide(), + Scale::Logarithmic => g.show(), }). label(format!("Average time ({}s)", prefix)). scale(xscale)). - axis(BottomX, |a| match xscale { - Linear => a, - Logarithmic => { + axis(Axis::BottomX, |a| match xscale { + Scale::Linear => a, + Scale::Logarithmic => { a.range(log_floor(min), log_ceil(max)) }, }). - axis(LeftY, |a| a. + axis(Axis::LeftY, |a| a. label("Input"). range(0., benches.len() as f64). tics(tics, benches.iter().map(|&(label, _, _, _)| label))). curve(Points, medians.iter().map(|&median| median * scale), tics, |c| c. - color(Black). + color(Color::Black). label("Median"). - point_type(Plus). + point_type(PointType::Plus). point_size(2. * POINT_SIZE)); let mut is_first = true;