-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5560aeb
commit b44ab4e
Showing
4 changed files
with
91 additions
and
32 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions
11
src/c++/perf_analyzer/docs/examples/calculate_avg_first_token_latency.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import json | ||
|
||
f = open("profile_export.json") | ||
Check warning Code scanning / CodeQL File is not always closed Warning documentation
File is opened but is not closed.
|
||
|
||
# example json demonstrating format: | ||
# https://github.com/triton-inference-server/client/blob/main/src/c%2B%2B/perf_analyzer/docs/examples/decoupled_output_file.json | ||
requests = json.load(f)["experiments"][0]["requests"] | ||
latencies = [r["response_timestamps"][0] - r["timestamp"] for r in requests] | ||
avg_latency_s = sum(latencies) / len(latencies) / 1000000000 | ||
|
||
print("Average first-token latency: " + str(avg_latency_s) + " s") |
16 changes: 16 additions & 0 deletions
16
src/c++/perf_analyzer/docs/examples/calculate_avg_token_to_token_latency.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import json | ||
|
||
f = open("profile_export.json") | ||
Check warning Code scanning / CodeQL File is not always closed Warning documentation
File is opened but is not closed.
|
||
|
||
# example json demonstrating format: | ||
# https://github.com/triton-inference-server/client/blob/main/src/c%2B%2B/perf_analyzer/docs/examples/decoupled_output_file.json | ||
requests = json.load(f)["experiments"][0]["requests"] | ||
latencies = [] | ||
for request in requests: | ||
prev_response = request["response_timestamps"][0] | ||
for response in request["response_timestamps"][1:]: | ||
latencies.append(response - prev_response) | ||
prev_response = response | ||
avg_latency_s = sum(latencies) / len(latencies) / 1000000000 | ||
|
||
print("Average token-to-token latency: " + str(avg_latency_s) + " s") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters