(values, percentile)
| 25 | let cachedBaseline = null; |
| 26 | |
| 27 | function quantile(values, percentile) { |
| 28 | if (values.length === 0) { |
| 29 | return 0; |
| 30 | } |
| 31 | const sorted = [...values].sort((left, right) => left - right); |
| 32 | const index = Math.min(sorted.length - 1, Math.max(0, Math.floor((sorted.length - 1) * percentile))); |
| 33 | return sorted[index]; |
| 34 | } |
| 35 | |
| 36 | function summarizeSamples(samples) { |
| 37 | if (samples.length < 4) { |