Skip to content

Commit

Permalink
Merge pull request #67 from tkuchiki/fix-percentile
Browse files Browse the repository at this point in the history
Fix percentile calculation
  • Loading branch information
tkuchiki committed Jul 26, 2022
2 parents 67f5378 + 82f085d commit 5ab7a93
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,17 @@ func (hs *HTTPStat) StddevResponseBodyBytes() float64 {
}

func percentRank(n int, pi int) int {
if pi == 0 {
switch pi {
case 0:
return 0
} else if pi == 100 {
case 100:
return n - 1
}

p := float64(pi) / 100.0
pos := int(float64(n+1) * p)
if pos < 0 {
pos = 0
if pos <= 0 {
return 0
}

return pos - 1
Expand Down

0 comments on commit 5ab7a93

Please sign in to comment.