]> iEval git - gruntmaster-daemon.git/commitdiff
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 8e6cbf38d557ca3438a619f71d7bed9ae8981b11..2af9b5306a78229d334deaa819bd2b0fd30ece26 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 2ad6f9519f4b8d82b3d7a892b8360bf514f0707c..6d6bd8fd1fc8e8f1ce03a2866743fc632e4df222 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.032588 seconds and 4 git commands to generate.