MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / percentile

Function percentile

tests/loadtest/tools/queue_benchmark.go:612–628  ·  view source on GitHub ↗
(values []float64, pct float64)

Source from the content-addressed store, hash-verified

610}
611
612func percentile(values []float64, pct float64) float64 {
613 if len(values) == 0 {
614 return 0
615 }
616 if len(values) == 1 {
617 return values[0]
618 }
619
620 position := (pct / 100) * float64(len(values)-1)
621 lower := int(math.Floor(position))
622 upper := int(math.Ceil(position))
623 if lower == upper {
624 return values[lower]
625 }
626 weight := position - float64(lower)
627 return values[lower] + (values[upper]-values[lower])*weight
628}
629
630func rate(failures, total int) float64 {
631 if total <= 0 {

Callers 1

trendStatsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected