(values: number[], percentage: number)
| 73 | }; |
| 74 | const samples = globalWindow.__chartKitScrubFrameSamples ?? []; |
| 75 | const getPercentile = (values: number[], percentage: number) => { |
| 76 | if (values.length === 0) { |
| 77 | return Number.NaN; |
| 78 | } |
| 79 | |
| 80 | const sorted = [...values].sort((a, b) => a - b); |
| 81 | const index = Math.min( |
| 82 | sorted.length - 1, |
| 83 | Math.floor((percentage / 100) * sorted.length) |
| 84 | ); |
| 85 | |
| 86 | return sorted[index] ?? Number.NaN; |
| 87 | }; |
| 88 | |
| 89 | globalWindow.__stopChartKitScrubBenchmark?.(); |
| 90 |