MCPcopy Create free account
hub / github.com/adobe/react-spectrum / percentile

Function percentile

perf/report.mjs:8–16  ·  view source on GitHub ↗
(values, fraction)

Source from the content-addressed store, hash-verified

6 */
7
8export 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

Callers 7

report.test.mjsFile · 0.90
missedFramesFunction · 0.85
metricsFunction · 0.85
medianFunction · 0.85
signedRankIntervalFunction · 0.85
byLeadFunction · 0.85
reportFunction · 0.85

Calls 1

sortMethod · 0.65

Tested by

no test coverage detected