(values, fraction)
| 6 | */ |
| 7 | |
| 8 | export function percentile(values, fraction) { |
| 9 | if (!values.length) { |
| 10 | return null; |
| 11 | } |
| 12 | let sorted = [...values].sort((a, b) => a - b); |
| 13 | let position = (sorted.length - 1) * fraction; |
| 14 | let low = Math.floor(position); |
| 15 | return sorted[low] + (sorted[Math.ceil(position)] - sorted[low]) * (position - low); |
| 16 | } |
| 17 | |
| 18 | // Estimates frames the main thread missed: an interval spanning n frame periods |
| 19 | // skipped n - 1 frames. The period is the trial's median interval, so it adapts to |
no test coverage detected