| 610 | } |
| 611 | |
| 612 | func 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 | |
| 630 | func rate(failures, total int) float64 { |
| 631 | if total <= 0 { |