comparison unix.py @ 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 0b265fe9c81f
children 19c42a3cd962
comparison
equal deleted inserted replaced
122:d6fd880207cb 123:90c002c960cb
208 del bury_child.case 208 del bury_child.case
209 new_rusage = getrusage(RUSAGE_CHILDREN) 209 new_rusage = getrusage(RUSAGE_CHILDREN)
210 if (case.maxwalltime and 210 if (case.maxwalltime and
211 case.time_stopped - case.time_started > case.maxwalltime): 211 case.time_stopped - case.time_started > case.maxwalltime):
212 raise testcases.WallTimeLimitExceeded 212 raise testcases.WallTimeLimitExceeded
213 if new_rusage and (case.maxcputime or not case.maxwalltime): 213 if new_rusage:
214 case.time_started = cpustart 214 time_started = old_rusage.ru_utime + old_rusage.ru_stime + cpustart
215 case.time_stopped = new_rusage.ru_utime + new_rusage.ru_stime 215 time_stopped = new_rusage.ru_utime + new_rusage.ru_stime
216 case.time_limit_string = case.cpu_time_limit_string 216 if case.maxcputime or not case.maxwalltime:
217 if case.maxcputime and new_rusage: 217 case.time_started = time_started
218 oldtime = old_rusage.ru_utime + old_rusage.ru_stime 218 case.time_stopped = time_stopped
219 newtime = new_rusage.ru_utime + new_rusage.ru_stime 219 case.time_limit_string = case.cpu_time_limit_string
220 if newtime - oldtime - cpustart > case.maxcputime: 220 if (case.maxcputime and
221 raise testcases.CPUTimeLimitExceeded 221 time_stopped - time_started > case.maxcputime):
222 raise testcases.CPUTimeLimitExceeded
222 if case.maxmemory: 223 if case.maxmemory:
223 if sys.platform != 'darwin': 224 if sys.platform != 'darwin':
224 maxrss = case.maxmemory * 1024 225 maxrss = case.maxmemory * 1024
225 else: 226 else:
226 maxrss = case.maxmemory * 1048576 227 maxrss = case.maxmemory * 1048576