Use monotonic clock for interval measurement (#6211)

Signed-off-by: Lifu Huang <lifu.hlf@gmail.com>
This commit is contained in:
Lifu Huang
2025-05-17 16:49:18 -07:00
committed by GitHub
parent 2716830802
commit 3cf1473a09
21 changed files with 72 additions and 72 deletions

View File

@@ -89,9 +89,9 @@ def start_server(args, timeout=60):
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:
# Check the /docs endpoint which FastAPI provides by default
response = session.get(

View File

@@ -150,7 +150,7 @@ def video_stream_request_test(client, video_path):
def image_speed_test(client):
print("----------------------Image Speed Test----------------------")
start_time = time.time()
start_time = time.perf_counter()
request = client.chat.completions.create(
model="default",
messages=[
@@ -173,7 +173,7 @@ def image_speed_test(client):
temperature=0,
max_tokens=1024,
)
end_time = time.time()
end_time = time.perf_counter()
response = request.choices[0].message.content
print(response)
print("-" * 30)
@@ -184,14 +184,14 @@ def video_speed_test(client, video_path):
print("------------------------Video Speed Test------------------------")
messages = prepare_video_messages(video_path)
start_time = time.time()
start_time = time.perf_counter()
video_request = client.chat.completions.create(
model="default",
messages=messages,
temperature=0,
max_tokens=1024,
)
end_time = time.time()
end_time = time.perf_counter()
video_response = video_request.choices[0].message.content
print(video_response)
print("-" * 30)