Skip to content

Commit

Permalink
Merge pull request #6 from tkuchiki/fix-percentile
Browse files Browse the repository at this point in the history
Fix percentile calculation
  • Loading branch information
tkuchiki authored Jul 26, 2022
2 parents 96df080 + a9a6e32 commit ffb7e56
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion stats/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func NewPrinter(w io.Writer, val, format string, percentiles []int, printOptions
p.keywords = helper.SplitCSV(val)
for _, key := range p.keywords {
p.headers = append(p.headers, p.headersMap[key])
if key == "all" {
if key == string(allMode) {
p.keywords = keywords(percentiles, outputKeywords[allMode])
p.headers = defaultHeaders(percentiles, outputKeywords[allMode])
p.all = true
Expand Down
4 changes: 2 additions & 2 deletions stats/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ func percentRank(n int, pi int) int {

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 ffb7e56

Please sign in to comment.