Skip to content

Commit

Permalink
fix timestamps computations
Browse files Browse the repository at this point in the history
  • Loading branch information
AllentDan committed Nov 1, 2023
1 parent 4c1fde7 commit d2d2952
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions benchmark/profile_restful_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def infer(server_addr: str, session_id: int, req_queue: mp.Queue,
f'input_seqlen {input_seqlen}, output_seqlen {output_seqlen}')
timestamps = []
tokens = []
start = time.perf_counter()
timestamps.append(time.perf_counter())
for res, token in get_streaming_response(
prompt,
server_addr,
Expand All @@ -65,7 +65,7 @@ def infer(server_addr: str, session_id: int, req_queue: mp.Queue,
timestamps.append(time.perf_counter())
tokens.append(token)

first_token_latency = timestamps[1] - start
first_token_latency = timestamps[1] - timestamps[0]
token_latency = timestamps[-1] - timestamps[0]
token = tokens[-1] - tokens[0]
stats.append([first_token_latency, token, token_latency])
Expand Down
4 changes: 2 additions & 2 deletions benchmark/profile_serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def infer(chatbot, session_id: int, req_que: mp.Queue, res_que: mp.Queue):
[None, None, None]):
timestamps = []
tokens = []
start = time.perf_counter()
timestamps.append(time.perf_counter())
for status, res, token in chatbot.stream_infer(
session_id,
prompt,
Expand All @@ -27,7 +27,7 @@ def infer(chatbot, session_id: int, req_que: mp.Queue, res_que: mp.Queue):
timestamps.append(time.perf_counter())
tokens.append(token)

first_token_latency = np.round(timestamps[1] - start, 3)
first_token_latency = np.round(timestamps[1] - timestamps[0], 3)
token_latency = np.round(timestamps[-1] - timestamps[0], 3)
token = tokens[-1] - tokens[0]
stats.append([first_token_latency, token, token_latency])
Expand Down

0 comments on commit d2d2952

Please sign in to comment.