зеркало из https://github.com/mozilla/glean.git
new method to handle waiting
This commit is contained in:
Родитель
cf8e5f91aa
Коммит
58c5a27a82
|
@ -162,13 +162,20 @@ def test_measure():
|
|||
)
|
||||
|
||||
with metric.measure():
|
||||
time.sleep(0.1)
|
||||
iteration_guard = 10**8 # this guard should be
|
||||
# about 100 times as long as the loop
|
||||
iterations = 0
|
||||
end_time = time.perf_counter() + 0.1
|
||||
while time.perf_counter() < end_time:
|
||||
if iterations > iteration_guard:
|
||||
raise Exception("Loop to accrue time exceeded guard")
|
||||
iterations += 1
|
||||
|
||||
snapshot = metric.test_get_value()
|
||||
# more than 0.1s = 100ms = 10^8 nanoseconds
|
||||
# less than 0.2s = 200ms = 2*10^8 nanoseconds
|
||||
assert 10**8 < snapshot.sum
|
||||
assert 2 * 10**8 > snapshot.sum
|
||||
assert snapshot.sum > 10**8, "Measured value below minimum time"
|
||||
assert snapshot.sum < 2 * 10**8, "Measured value above maximum time"
|
||||
|
||||
|
||||
def test_measure_exception():
|
||||
|
|
Загрузка…
Ссылка в новой задаче