duplex-v0 / tools /loadtest_report.py
Jr23xd23's picture
RightNow Duplex v0
f730521 verified
Raw History Blame Contribute Delete
1.27 kB
"""Per level of a load test: where the time goes (first token, first audio, generation speed).
python -m tools.loadtest_report eval/results/loadtest
"""
import json
import sys
from pathlib import Path
import numpy as np
def main():
for path in sorted(Path(sys.argv[1]).glob("level_*.json"), key=lambda p: int(p.stem.split("_")[1])):
d = json.loads(path.read_text())
turns = [t for t in d["turns"] if not t["error"] and t["ttfa_ms"] is not None]
if not turns:
print(path.stem, "no finished turns", d["summary"]["errors"][:2])
continue
col = lambda k: np.array([t[k] for t in turns if t[k] is not None], dtype=float)
s = d["summary"]
print(f"{path.stem:9s} turns {len(turns):2d}/{s['turns']:2d} | first token ms p50 {np.median(col('first_token_ms')):6.0f} max {col('first_token_ms').max():6.0f}"
f" | first audio ms p50 {np.median(col('ttfa_ms')):6.0f} max {col('ttfa_ms').max():6.0f}"
f" | generation/audio time p50 {np.median(col('real_time_factor')):.2f} max {col('real_time_factor').max():.2f}"
f" | underruns {int(col('underruns').sum())} | longest gap ms {col('max_gap_ms').max():.0f} | pass {s['pass']}")
if __name__ == "__main__":
main()