(u: CacheUsage | null)
| 28 | * Compute integer hit rate (0–100) or null if denominator is zero / input null. |
| 29 | */ |
| 30 | export function computeHitRate(u: CacheUsage | null): number | null { |
| 31 | if (!u) return null |
| 32 | const denom = |
| 33 | u.input_tokens + u.cache_creation_input_tokens + u.cache_read_input_tokens |
| 34 | if (denom === 0) return null |
| 35 | return Math.round((u.cache_read_input_tokens / denom) * 100) |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Stable string that uniquely identifies a usage snapshot. |
no outgoing calls
no test coverage detected