mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 02:17:31 +00:00
* refactor(tooling): group remaining scripts by concrete domain owners * fix(tooling): preserve relocated launcher resource roots
22 lines
563 B
JavaScript
22 lines
563 B
JavaScript
export function summarize(values) {
|
|
const samples = values.map((value) => round(value)).sort((a, b) => a - b)
|
|
if (samples.length === 0) {
|
|
return { count: 0, median: 0, p95: 0, max: 0, samples }
|
|
}
|
|
return {
|
|
count: samples.length,
|
|
median: percentile(samples, 0.5),
|
|
p95: percentile(samples, 0.95),
|
|
max: samples.at(-1),
|
|
samples
|
|
}
|
|
}
|
|
|
|
function percentile(sorted, fraction) {
|
|
return sorted[Math.min(sorted.length - 1, Math.ceil(sorted.length * fraction) - 1)]
|
|
}
|
|
|
|
export function round(value) {
|
|
return Math.round(value * 100) / 100
|
|
}
|