From 03a195ad4dd8f8c4aea1014be54a7f6922b773ea Mon Sep 17 00:00:00 2001 From: MasterDuke17 Date: Tue, 19 Jul 2016 00:01:01 -0400 Subject: [PATCH] Compute some additional statistics about the runs --- benchable.pl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/benchable.pl b/benchable.pl index b2bf369..79215ba 100755 --- a/benchable.pl +++ b/benchable.pl @@ -27,10 +27,12 @@ package Benchable; use Cwd qw(cwd abs_path); use Encode qw(encode_utf8 decode_utf8); use File::Temp qw(tempfile tempdir); -use List::Util qw(min); +use List::Util qw(min max); use Chart::Gnuplot; +use Statistics::Basic qw(mean stddev); use constant LIMIT => 300; +use constant ITERATIONS => 5; my $name = 'benchable'; @@ -85,30 +87,39 @@ sub process_message { } elsif (not -e $self->BUILDS . "/$full_commit/bin/perl6") { $times{$short_commit} = 'No build for this commit'; } else { # actually run the code - for (1..5) { + for (1..ITERATIONS) { (undef, my $exit, my $time) = $self->get_output($self->BUILDS . "/$full_commit/bin/perl6", $filename); push @{$times{$short_commit}}, $exit == 0 ? sprintf('%.4f', $time) : "run failed, exit code = $exit"; } - $times{$short_commit} = min(@{$times{$short_commit}}); + my @times = @{$times{$short_commit}}; + $times{$short_commit} = {}; + $times{$short_commit}{'min'} = min(@times); + $times{$short_commit}{'max'} = max(@times); + $times{$short_commit}{'mean'} = mean(@times); + $times{$short_commit}{'stddev'} = stddev(@times); } } - if (scalar @commits >= 5) { + if (scalar @commits >= ITERATIONS) { my ($gfh, $gfilename) = tempfile(SUFFIX => '.svg', UNLINK => 1); + (my $title = $body) =~ s/"/\\"/g; my $chart = Chart::Gnuplot->new( - output => $gfilename, + output => 'graph.svg', encoding => 'utf8', title => { - text => encode_utf8($body =~ s/"/\\"/g), + text => encode_utf8($title), enhanced => 'off', }, # terminal => 'svg mousing', - xlabel => 'Commits', + xlabel => { + text => 'Commits\\nMean,Max,Stddev', + offset => '0,-1', + }, ylabel => 'Seconds', - xtics => { labels => [map { "'$commits[$_]' $_" } 0..$#commits], }, + xtics => { labels => [map { "\"$commits[$_]\\n" . join(',', @{$times{substr($commits[$_], 0, 7)}}{qw(mean max stddev)}) . "\" $_" } 0..$#commits], }, ); my $dataSet = Chart::Gnuplot::DataSet->new( - ydata => [map { $times{substr($_, 0, 7)} } @commits], + ydata => [map { $times{substr($_, 0, 7)}{'min'} } @commits], style => 'linespoints', ); $chart->plot2d($dataSet);