mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +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
|
@ -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]')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue