Skip to content

Commit

Permalink
Initial attempt at adding graphing to benchable
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterDuke17 committed Jul 17, 2016
1 parent 57bd995 commit 6fd5760
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Perl6IRCBotable.pm
Expand Up @@ -34,7 +34,7 @@ use JSON::XS;
use Net::GitHub;
use Time::HiRes qw(time);

use constant RAKUDO => './rakudo';
use constant RAKUDO => abs_path('./rakudo');
use constant BUILDS => abs_path('./builds');
use constant CONFIG => abs_path('./config.json');
use constant SOURCE => 'https://github.com/perl6/bisectbot';
Expand Down Expand Up @@ -163,10 +163,11 @@ sub said {
return SOURCE if $body eq 'source';
return 'Sorry, it is too private here' if $message->{address} eq 'msg';

my $response = $self->process_message($message, $body);
if (length $response > 250) { # upload code somewhere if the output is way too long
my ($response, $additional_files) = $self->process_message($message, $body);
if (length $response > 250 or defined $additional_files) { # upload code somewhere if the output is way too long
$response = $self->upload({ 'query' => $body,
'result' => $response, });
'result' => $response,
%{$additional_files // {}}, });
} else {
$response =~ s/\n//g;
}
Expand Down
27 changes: 26 additions & 1 deletion benchable.pl
Expand Up @@ -25,7 +25,10 @@ package Benchable;
use parent 'Perl6IRCBotable';

use Cwd qw(cwd abs_path);
use File::Temp qw(tempfile tempdir);
use List::Util qw(min);
use Chart::Gnuplot;
use File::Basename;

use constant LIMIT => 300;

Expand All @@ -35,6 +38,7 @@ sub process_message {
my ($self, $message, $body) = @_;

my $msg_response = '';
my $graph = undef;

if ($body =~ /^ \s* (\S+) \s+ (.+) /xu) {
my ($config, $code) = ($1, $2);
Expand Down Expand Up @@ -89,12 +93,33 @@ sub process_message {
}
}

if (scalar @commits >= 5) {
my ($gfh, $gfilename) = tempfile(SUFFIX => '.svg', UNLINK => 1);
my $chart = Chart::Gnuplot->new(
output => $gfilename,
terminal => 'svg mousing',
xlabel => 'Commits',
ylabel => 'Seconds',
xtics => { labels => [map { "'$commits[$_]' $_" } 0..$#commits], },
);
my $dataSet = Chart::Gnuplot::DataSet->new(
ydata => [map { $times{substr($_, 0, 7)} } @commits],
style => 'linespoints',
);
$chart->plot2d($dataSet);

$graph->{basename($gfilename)} = do {
local $/;
<$gfh>;
};
}

$msg_response .= '|' . join("\n|", map { $_ = substr($_, 0, 7); "«$_»:$times{$_}" } @commits);
} else {
return help();
}

return $msg_response;
return ($msg_response, $graph);
}

sub help {
Expand Down

0 comments on commit 6fd5760

Please sign in to comment.