Compute throughput and goodput for a serving trace.
Throughput counts every output token. Goodput counts only tokens from requests that met the latency SLA.
Inputs
requests: list of dicts, each with
'ttft_ms': time to first token (float)'itl_ms': list of inter-token latencies (may be empty)'output_tokens': token count to credit for this request (int)sla_ttft_ms: maximum allowed TTFTsla_itl_ms: maximum allowed ITL for every entry of 'itl_ms'wall_time_s: trace duration in seconds, strictly positiveA request is SLA-valid iff ttft_ms <= sla_ttft_ms and every ITL is <= sla_itl_ms. An empty 'itl_ms' only has to pass the TTFT check.
Return a dict
'throughput_tps': (sum of all output_tokens) / wall_time_s, rounded to 4 decimal places'goodput_tps': (sum of output_tokens over SLA-valid requests) / wall_time_s, rounded to 4 decimal places'n_ok': number of SLA-valid requests (int)'n_total': len(requests) (int)