changeset 123:90c002c960cb

Fixed CPU time display on UNIX Previously, the total CPU time spent by the testee on all test cases up to and including the current one was displayed.
author Oleg Oshmyan <chortos@inbox.lv>
date Sun, 24 Apr 2011 19:28:40 +0100
parents d6fd880207cb
children 19c42a3cd962
files unix.py
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/unix.py	Sun Apr 24 16:48:29 2011 +0100
+++ b/unix.py	Sun Apr 24 19:28:40 2011 +0100
@@ -210,15 +210,16 @@
 		if (case.maxwalltime and
 		    case.time_stopped - case.time_started > case.maxwalltime):
 			raise testcases.WallTimeLimitExceeded
-		if new_rusage and (case.maxcputime or not case.maxwalltime):
-			case.time_started = cpustart
-			case.time_stopped = new_rusage.ru_utime + new_rusage.ru_stime
-			case.time_limit_string = case.cpu_time_limit_string
-		if case.maxcputime and new_rusage:
-			oldtime = old_rusage.ru_utime + old_rusage.ru_stime
-			newtime = new_rusage.ru_utime + new_rusage.ru_stime
-			if newtime - oldtime - cpustart > case.maxcputime:
-				raise testcases.CPUTimeLimitExceeded
+		if new_rusage:
+			time_started = old_rusage.ru_utime + old_rusage.ru_stime + cpustart
+			time_stopped = new_rusage.ru_utime + new_rusage.ru_stime
+			if case.maxcputime or not case.maxwalltime:
+				case.time_started = time_started
+				case.time_stopped = time_stopped
+				case.time_limit_string = case.cpu_time_limit_string
+				if (case.maxcputime and
+				    time_stopped - time_started > case.maxcputime):
+					raise testcases.CPUTimeLimitExceeded
 		if case.maxmemory:
 			if sys.platform != 'darwin':
 				maxrss = case.maxmemory * 1024