File size: 1,274 Bytes
f730521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""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()