##// END OF EJS Templates
tests: use time.time() for relative start and stop times...
Gregory Szorc -
r43991:ac140b85 default
parent child Browse files
Show More
@@ -2246,15 +2246,19 b' class TestResult(unittest._TextTestResul'
2246 # os.times module computes the user time and system time spent by
2246 # os.times module computes the user time and system time spent by
2247 # child's processes along with real elapsed time taken by a process.
2247 # child's processes along with real elapsed time taken by a process.
2248 # This module has one limitation. It can only work for Linux user
2248 # This module has one limitation. It can only work for Linux user
2249 # and not for Windows.
2249 # and not for Windows. Hence why we fall back to another function
2250 # for wall time calculations.
2250 test.started_times = os.times()
2251 test.started_times = os.times()
2252 # TODO use a monotonic clock once support for Python 2.7 is dropped.
2253 test.started_time = time.time()
2251 if self._firststarttime is None: # thread racy but irrelevant
2254 if self._firststarttime is None: # thread racy but irrelevant
2252 self._firststarttime = test.started_times[4]
2255 self._firststarttime = test.started_time
2253
2256
2254 def stopTest(self, test, interrupted=False):
2257 def stopTest(self, test, interrupted=False):
2255 super(TestResult, self).stopTest(test)
2258 super(TestResult, self).stopTest(test)
2256
2259
2257 test.stopped_times = os.times()
2260 test.stopped_times = os.times()
2261 stopped_time = time.time()
2258
2262
2259 starttime = test.started_times
2263 starttime = test.started_times
2260 endtime = test.stopped_times
2264 endtime = test.stopped_times
@@ -2264,9 +2268,9 b' class TestResult(unittest._TextTestResul'
2264 test.name,
2268 test.name,
2265 endtime[2] - starttime[2], # user space CPU time
2269 endtime[2] - starttime[2], # user space CPU time
2266 endtime[3] - starttime[3], # sys space CPU time
2270 endtime[3] - starttime[3], # sys space CPU time
2267 endtime[4] - starttime[4], # real time
2271 stopped_time - test.started_time, # real time
2268 starttime[4] - origin, # start date in run context
2272 test.started_time - origin, # start date in run context
2269 endtime[4] - origin, # end date in run context
2273 stopped_time - origin, # end date in run context
2270 )
2274 )
2271 )
2275 )
2272
2276
General Comments 0
You need to be logged in to leave comments. Login now