From 8db5b54463118e5eb60cb3582e3108623f01f5df Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 17 Dec 2018 11:30:34 +0100 Subject: 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. --- Lib/random.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/random.py') diff --git a/Lib/random.py b/Lib/random.py index 03c058a39d6..9c2904cfd2f 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -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) -- cgit v1.2.3