summaryrefslogtreecommitdiffstats
path: root/Lib/test/time_hashlib.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-12-17 10:30:34 (GMT)
committerGitHub <noreply@github.com>2018-12-17 10:30:34 (GMT)
commit8db5b54463118e5eb60cb3582e3108623f01f5df (patch)
treebacd30bf9a8b946798ae30abf8c764d2c6f47d8d /Lib/test/time_hashlib.py
parent2cf4c202ffeb30787c944365ba54013688b854c2 (diff)
downloadcpython-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/test/time_hashlib.py')
-rw-r--r--Lib/test/time_hashlib.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/time_hashlib.py b/Lib/test/time_hashlib.py
index 2585ecb..55ebac6 100644
--- a/Lib/test/time_hashlib.py
+++ b/Lib/test/time_hashlib.py
@@ -14,26 +14,26 @@ def test_scaled_msg(scale, name):
longStr = b'Z'*scale
localCF = creatorFunc
- start = time.time()
+ start = time.perf_counter()
for f in range(iterations):
x = localCF(longStr).digest()
- end = time.time()
+ end = time.perf_counter()
print(('%2.2f' % (end-start)), "seconds", iterations, "x", len(longStr), "bytes", name)
def test_create():
- start = time.time()
+ start = time.perf_counter()
for f in range(20000):
d = creatorFunc()
- end = time.time()
+ end = time.perf_counter()
print(('%2.2f' % (end-start)), "seconds", '[20000 creations]')
def test_zero():
- start = time.time()
+ start = time.perf_counter()
for f in range(20000):
x = creatorFunc().digest()
- end = time.time()
+ end = time.perf_counter()
print(('%2.2f' % (end-start)), "seconds", '[20000 "" digests]')