Skip to content

Commit 16b0591

Browse files
Update benchmarks.yml
1 parent caccc3c commit 16b0591

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

.github/workflows/benchmarks.yml

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,39 +71,43 @@ jobs:
7171
timeout-minutes: 30
7272
shell: bash
7373
run: |
74+
source ../../../../../venv/bin/activate
7475
output=$(bash run.sh)
7576
echo "$output"
76-
77-
# Extract metrics using Python and regex
78-
python - << EOF
79-
import re
80-
import json
81-
82-
text = \"\"\"${output}\"\"\"
83-
84-
ttft_pattern = r"TTFT: ([\d.]+) ms ± ([\d.]+)%"
85-
e2e_latency_pattern = r"E2E Latency: ([\d.]+) ms ± ([\d.]+)%"
86-
tpot_pattern = r"TPOT: ([\d.]+) ms"
87-
88-
ttft_match = re.search(ttft_pattern, text)
89-
e2e_latency_match = re.search(e2e_latency_pattern, text)
90-
tpot_match = re.search(tpot_pattern, text)
91-
92-
metrics = {
93-
"TTFT": {"value": ttft_match.group(1) if ttft_match else None, "std_dev": ttft_match.group(2) if ttft_match else None},
94-
"E2E Latency": {"value": e2e_latency_match.group(1) if e2e_latency_match else None, "std_dev": e2e_latency_match.group(2) if e2e_latency_match else None},
95-
"TPOT": {"value": tpot_match.group(1) if tpot_match else None},
96-
}
97-
98-
with open("metrics.json", "w") as f:
99-
json.dump(metrics, f, indent=4)
100-
101-
print(f"::set-output name=metrics::{json.dumps(metrics)}")
102-
EOF
103-
104-
# Copy the metrics.json file to the results directory
105-
cp metrics.json xla/results/
10677
78+
# Extract metrics using Python and regex
79+
python - << EOF
80+
import re
81+
import json
82+
83+
text = \"\"\"${output}\"\"\"
84+
85+
ttft_pattern = r"TTFT: ([\d.]+) ms ± ([\d.]+)%"
86+
e2e_latency_pattern = r"E2E Latency: ([\d.]+) ms ± ([\d.]+)%"
87+
tpot_pattern = r"TPOT: ([\d.]+) ms"
88+
89+
ttft_match = re.search(ttft_pattern, text)
90+
e2e_latency_match = re.search(e2e_latency_pattern, text)
91+
tpot_match = re.search(tpot_pattern, text)
92+
93+
metrics = {
94+
"TTFT": {"value": ttft_match.group(1) if ttft_match else None, "std_dev": ttft_match.group(2) if ttft_match else None},
95+
"E2E Latency": {"value": e2e_latency_match.group(1) if e2e_latency_match else None, "std_dev": e2e_latency_match.group(2) if e2e_latency_match else None},
96+
"TPOT": {"value": tpot_match.group(1) if tpot_match else None},
97+
}
98+
99+
with open("metrics.json", "w") as f:
100+
json.dump(metrics, f, indent=4)
101+
102+
print(f"::set-output name=metrics::{json.dumps(metrics)}")
103+
EOF
104+
105+
# Upload metrics as an artifact (optional)
106+
# Create the results directory if it doesn't exist
107+
mkdir -p ../../../../../results
108+
109+
# Copy the metrics.json file to the results directory
110+
cp metrics.json ../../../../../results/
107111

108112
- name: Wait For Connection
109113
uses: google-ml-infra/actions/ci_connection@main

0 commit comments

Comments
 (0)