From 34cc90c9aa31c1cad1fcef0684e940407426ad1d Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Thu, 11 Feb 2016 16:29:25 +0000 Subject: [PATCH] Compute user program executon time instead of full test running time --- lib/Gruntmaster/Daemon.pm | 9 +++++---- lib/Gruntmaster/Daemon/Format.pm | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Gruntmaster/Daemon.pm b/lib/Gruntmaster/Daemon.pm index 8e6cbf3..2af9b53 100644 --- a/lib/Gruntmaster/Daemon.pm +++ b/lib/Gruntmaster/Daemon.pm @@ -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 diff --git a/lib/Gruntmaster/Daemon/Format.pm b/lib/Gruntmaster/Daemon/Format.pm index 2ad6f95..6d6bd8f 100644 --- a/lib/Gruntmaster/Daemon/Format.pm +++ b/lib/Gruntmaster/Daemon/Format.pm @@ -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; -- 2.39.2