mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-35513, unittest: TextTestRunner uses time.perf_counter() (GH-11180)
TextTestRunner of unittest.runner now uses time.perf_counter() rather than time.time() to measure the execution time of a test: time.time() can go backwards, whereas time.perf_counter() is monotonic. Similar change made in libregrtest, pprint and random.
This commit is contained in:
parent
2cf4c202ff
commit
8db5b54463
6 changed files with 19 additions and 15 deletions
|
@ -740,14 +740,14 @@ def _test_generator(n, func, args):
|
|||
sqsum = 0.0
|
||||
smallest = 1e10
|
||||
largest = -1e10
|
||||
t0 = time.time()
|
||||
t0 = time.perf_counter()
|
||||
for i in range(n):
|
||||
x = func(*args)
|
||||
total += x
|
||||
sqsum = sqsum + x*x
|
||||
smallest = min(x, smallest)
|
||||
largest = max(x, largest)
|
||||
t1 = time.time()
|
||||
t1 = time.perf_counter()
|
||||
print(round(t1-t0, 3), 'sec,', end=' ')
|
||||
avg = total/n
|
||||
stddev = _sqrt(sqsum/n - avg*avg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue