Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/src/util/ttft-histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const LN_BASE = Math.log(TTFT_HISTOGRAM_BASE)
* Sub-millisecond and zero samples land in bucket 0 rather than at -Infinity.
*/
export function ttftBucketIndex(ttftMs: number): number {
const index = Math.floor(Math.log(Math.max(ttftMs, 1)) / LN_BASE)
const safeTtftMs = Number.isFinite(ttftMs) ? ttftMs : 0
const index = Math.floor(Math.log(Math.max(safeTtftMs, 1)) / LN_BASE)
return Math.min(TTFT_HISTOGRAM_BUCKET_COUNT - 1, Math.max(0, index))
}

Expand Down
Loading