Skip to content

Commit

Permalink
Fix percentile calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
tkuchiki committed Jul 26, 2022
1 parent 67f5378 commit 82f085d
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 82f085d

Please sign in to comment.