Compute user program executon time instead of full test running time
authorMarius Gavrilescu <marius@ieval.ro>
Thu, 11 Feb 2016 16:29:25 +0000 (16:29 +0000)
committerMarius Gavrilescu <marius@ieval.ro>
Thu, 11 Feb 2016 16:29:25 +0000 (16:29 +0000)
lib/Gruntmaster/Daemon.pm
lib/Gruntmaster/Daemon/Format.pm

index 8e6cbf3..2af9b53 100644 (file)
@@ -13,7 +13,6 @@ use File::Slurp qw/read_file/;
 use File::Temp qw/tempdir/;
 use JSON qw/decode_json encode_json/;
 use Sys::Hostname qw/hostname/;
-use Time::HiRes qw/time/;
 use Try::Tiny;
 use Log::Log4perl qw/get_logger/;
 
@@ -68,7 +67,6 @@ sub process{
                $judge = safe_can Judge => judge => $judge;
 
                for my $test (1 .. $testcnt) {
-                       my $start_time = time;
                        my $result;
                        unlink 'result';
                        try {
@@ -82,14 +80,17 @@ sub process{
                                }
                        };
 
+                       my $time = '?';
+                       $time = (read_file 'time-stop-prog') - (read_file 'time-start-prog') if -f 'time-stop-prog' && -f 'time-start-prog';
+                       unlink 'time-start-prog', 'time-stop-prog';
                        if (ref $result) {
                                my $result_text = $result->[1];
                                $result_text .= ': ' . read_file 'result' if -s 'result';
                                get_logger->trace("Test $test result is " . $result_text);
-                               push @full_results, {id => $test, result => $result->[0], result_text => $result_text, time => time - $start_time}
+                               push @full_results, {id => $test, result => $result->[0], result_text => $result_text, time => $time}
                        } else {
                                get_logger->trace("Test $test result is $result");
-                               push @full_results, {id => $test, result => 0, result_text => $result, time => time - $start_time}
+                               push @full_results, {id => $test, result => 0, result_text => $result, time => $time}
                        }
                        push @results, $result;
                        last if $meta->{judge} eq 'Absolute' && ref $result
index 2ad6f95..6d6bd8f 100644 (file)
@@ -14,6 +14,7 @@ use File::Slurp qw/read_file write_file/;
 use List::MoreUtils qw/natatime/;
 use Log::Log4perl qw/get_logger/;
 use String::ShellQuote qw/shell_quote/;
+use Time::HiRes qw/time/;
 use Try::Tiny;
 
 our $VERSION = '5999.000_005';
@@ -51,6 +52,7 @@ sub execlist_finish {
                kill KILL => $pid{$vm} if $kill;
                waitpid $pid{$vm}, 0;
        }
+       write_file "time-stop-$vm", time;
        return if $kill;
 
        my $er = "exec-result-$vm";
@@ -64,6 +66,7 @@ sub execlist_finish {
 
 sub execlist {
        my ($vm, @args) = @_;
+       write_file "time-start-$vm", time;
        my $er = "exec-result-$vm";
        if ($vm{$vm}) {
                my $cmd = ">$er " . shell_quote 'gruntmaster-exec', @args;
This page took 0.028115 seconds and 4 git commands to generate.