Replace time.time() to time.perf_counter() for benchmarking. (#6178)

Signed-off-by: Lifu Huang <lifu.hlf@gmail.com>
This commit is contained in:
Lifu Huang
2025-05-11 14:32:49 -07:00
committed by GitHub
parent e9a47f4cb5
commit 6e2da51561
61 changed files with 158 additions and 158 deletions

View File

@@ -92,9 +92,9 @@ def popen_launch_router(
process = subprocess.Popen(command, stdout=None, stderr=None)
start_time = time.time()
start_time = time.perf_counter()
with requests.Session() as session:
while time.time() - start_time < timeout:
while time.perf_counter() - start_time < timeout:
try:
response = session.get(f"{base_url}/health")
if response.status_code == 200:
@@ -155,11 +155,11 @@ def terminate_and_wait(process, timeout=300):
return
process.terminate()
start_time = time.time()
start_time = time.perf_counter()
while process.poll() is None:
print(f"Terminating process {process.pid}")
if time.time() - start_time > timeout:
if time.perf_counter() - start_time > timeout:
raise TimeoutError(
f"Process {process.pid} failed to terminate within {timeout}s"
)