fix: JSONL parsing in run_batch, add results/ to gitignore

This commit is contained in:
Zhiyi Hong 2026-07-29 17:51:47 +08:00
parent c839230c0b
commit e53b2c7e4c

View File

@ -62,8 +62,8 @@ get_conc_for() {
local isl="$1" local isl="$1"
if (( isl <= 4096 )); then echo "1 2 4 8 16 32 64 128" if (( isl <= 4096 )); then echo "1 2 4 8 16 32 64 128"
elif (( isl <= 16384 )); then echo "1 2 4 8 16 32" elif (( isl <= 16384 )); then echo "1 2 4 8 16 32"
elif (( isl <= 65536 )); then echo "1 2 4 8 16" elif (( isl <= 65536 )); then echo "1 2 4 8"
else echo "1 2 4 8" else echo "1 2 4"
fi fi
} }
@ -107,11 +107,27 @@ run_one() {
log " FAIL isl=${isl} osl=${osl} c=${conc} rc=${rc}"; return 1 log " FAIL isl=${isl} osl=${osl} c=${conc} rc=${rc}"; return 1
fi fi
# Extract metrics # Extract metrics (JSONL: first line has aggregate summary)
local tps=$(python3 -c "import json;d=json.load(open('${out}'));print(round(d.get('tps',-1),1))" 2>/dev/null || echo "-1") local metrics=$(python3 -c "
local ttft=$(python3 -c "import json;d=json.load(open('${out}'));print(round(d.get('ttft_mean',-1),1))" 2>/dev/null || echo "-1") import json
local tpot=$(python3 -c "import json;d=json.load(open('${out}'));print(round(d.get('tpot_mean',-1),1))" 2>/dev/null || echo "-1") for line in open('${out}'):
local e2e=$(python3 -c "import json;d=json.load(open('${out}'));print(round(d.get('e2e_latency_mean',-1),1))" 2>/dev/null || echo "-1") line=line.strip()
if not line: continue
try:
d=json.loads(line)
tps=d.get('total_throughput',d.get('tps',-1))
ttft=d.get('mean_ttft_ms',d.get('ttft_mean',-1))
tpot=d.get('mean_tpot_ms',d.get('tpot_mean',-1))
e2e=d.get('mean_e2e_latency_ms',d.get('e2e_latency_mean',-1))
if tps!=-1 or ttft!=-1:
print(f'{round(tps,1)},{round(ttft,1)},{round(tpot,1)},{round(e2e,1)}')
break
except: pass
" 2>/dev/null || echo "-1,-1,-1,-1")
local tps=$(echo "$metrics" | cut -d, -f1)
local ttft=$(echo "$metrics" | cut -d, -f2)
local tpot=$(echo "$metrics" | cut -d, -f3)
local e2e=$(echo "$metrics" | cut -d, -f4)
echo "${isl},${osl},${conc},${tps},${ttft},${tpot},${e2e},${slo_ms},OK,${elapsed}" >> "$SUMMARY_FILE" echo "${isl},${osl},${conc},${tps},${ttft},${tpot},${e2e},${slo_ms},OK,${elapsed}" >> "$SUMMARY_FILE"