diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-12-17 10:30:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-17 10:30:34 (GMT) |
commit | 8db5b54463118e5eb60cb3582e3108623f01f5df (patch) | |
tree | bacd30bf9a8b946798ae30abf8c764d2c6f47d8d /Lib/random.py | |
parent | 2cf4c202ffeb30787c944365ba54013688b854c2 (diff) | |
download | cpython-8db5b54463118e5eb60cb3582e3108623f01f5df.zip cpython-8db5b54463118e5eb60cb3582e3108623f01f5df.tar.gz cpython-8db5b54463118e5eb60cb3582e3108623f01f5df.tar.bz2 |
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.
Diffstat (limited to 'Lib/random.py')
-rw-r--r-- | Lib/random.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/random.py b/Lib/random.py index 03c058a..9c2904c 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) |