Skip to content

Commit 28a95aa

Browse files
committed
Use time.perf_counter to measure clock time durations
1 parent b780afb commit 28a95aa

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tests/integration/test_model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ async def add_manual_machine_ssh(event_loop, is_root=False):
457457

458458
def wait_for_network(container, timeout=30):
459459
"""Wait for eth0 to have an ipv4 address."""
460-
starttime = time.time()
461-
while time.time() < starttime + timeout:
460+
starttime = time.perf_counter()
461+
while time.perf_counter() < starttime + timeout:
462462
time.sleep(1)
463463
if 'eth0' in container.state().network:
464464
addresses = container.state().network['eth0']['addresses']
@@ -835,9 +835,9 @@ async def test_wait_for_idle_with_exact_units_scale_down(event_loop):
835835
await app.destroy_units(*two_units_to_remove)
836836

837837
# assert that the following wait is not returning instantaneously
838-
start_time = time.time()
838+
start_time = time.perf_counter()
839839
await model.wait_for_idle(timeout=5 * 60, wait_for_exact_units=1)
840-
end_time = time.time()
840+
end_time = time.perf_counter()
841841
# checking if waited more than 10ms
842842
assert (end_time - start_time) > 0.001
843843

@@ -864,9 +864,9 @@ async def test_wait_for_idle_with_exact_units_scale_down_zero(event_loop):
864864
await app.destroy_units(*units_to_remove)
865865

866866
# assert that the following wait is not returning instantaneously
867-
start_time = time.time()
867+
start_time = time.perf_counter()
868868
await model.wait_for_idle(timeout=5 * 60, wait_for_exact_units=0)
869-
end_time = time.time()
869+
end_time = time.perf_counter()
870870
# checking if waited more than 10ms
871871
assert (end_time - start_time) > 0.001
872872

0 commit comments

Comments
 (0)