Skip to content

Commit

Permalink
Add a total run time limit in addition to the time limit for running …
Browse files Browse the repository at this point in the history
…each individual commit
  • Loading branch information
MasterDuke17 committed Jul 30, 2016
1 parent 4a6357a commit b19c8e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
14 changes: 12 additions & 2 deletions benchable.pl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ package Benchable;
use Statistics::Basic qw(mean stddev);
use Scalar::Util qw(looks_like_number);

use constant LIMIT => 300;
use constant LIMIT => 300;
use constant TOTAL_TIME => 60*3;
use constant ITERATIONS => 5;

my $name = 'benchable';

sub timeout {
return 200;
return 10;
}

sub benchmark_code {
Expand Down Expand Up @@ -66,6 +67,7 @@ sub benchmark_code {

sub process_message {
my ($self, $message, $body) = @_;
my $start_time = time();

my $msg_response = '';
my $graph = undef;
Expand Down Expand Up @@ -119,6 +121,10 @@ sub process_message {
} else { # actually run the code
$times{$short_commit} = $self->benchmark_code($full_commit, $filename);
}

if (time() - $start_time > TOTAL_TIME) {
return "«hit the total time limit of " . TOTAL_TIME . " seconds»";
}
}

# for these two config options, check if there are any large speed differences between two commits and if so,
Expand All @@ -129,6 +135,10 @@ sub process_message {
chdir $self->RAKUDO;

Z: for (my $x = 0; $x < scalar @commits - 1; $x++) {
if (time() - $start_time > TOTAL_TIME) {
return "«hit the total time limit of " . TOTAL_TIME . " seconds»";
}

next unless (exists $times{$commits[$x]} and exists $times{$commits[$x + 1]}); # the commits have to have been run at all
next if (exists $times{$commits[$x]}{'err'} or exists $times{$commits[$x + 1]}{'err'}); # and without error
if (abs($times{$commits[$x]}{'min'} - $times{$commits[$x + 1]}{'min'}) >= $times{$commits[$x]}{'min'}*0.1) {
Expand Down
11 changes: 9 additions & 2 deletions committable.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ package Committable;

use Cwd qw(cwd abs_path);
use IPC::Signal 'sig_name';
use Time::HiRes qw(time);

use constant LIMIT => 1000;
use constant LIMIT => 1000;
use constant TOTAL_TIME => 60*2;

my $name = 'committable';

sub timeout {
return 50;
return 10;
}

sub process_message {
my ($self, $message, $body) = @_;
my $start_time = time();

my $msg_response = '';

Expand Down Expand Up @@ -107,6 +110,10 @@ sub process_message {
} else {
push @{@result[$lookup{$out}]->{commits}}, $short_commit;
}

if (time() - $start_time > TOTAL_TIME) {
return "«hit the total time limit of " . TOTAL_TIME . " seconds»";
}
}

$msg_response .= '¦' . join("\n|", map { '«' . join(',', @{$_->{commits}}) . '»: ' . $_->{output} } @result);
Expand Down

0 comments on commit b19c8e2

Please sign in to comment.