Skip to content

Commit

Permalink
Enable percentile output format (#38)
Browse files Browse the repository at this point in the history
* [wip] Wip on enabling output textual percentile distribution

* [add] Added example for printing of the percentile output format

* [add] printing +Inf within Inverted Percentile in the same format as the Java implementation
  • Loading branch information
filipecosta90 authored Oct 6, 2020
1 parent 311d303 commit aada4ab
Show file tree
Hide file tree
Showing 4 changed files with 660 additions and 0 deletions.
35 changes: 35 additions & 0 deletions example_hdr_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package hdrhistogram_test

import (
"github.com/HdrHistogram/hdrhistogram-go"
"os"
)

// The following example details the creation of an histogram used to track
// and analyze the counts of observed integer values between 0 us and 30000000 us ( 30 secs )
// and the printing of the percentile output format
func ExampleHistogram_PercentilesPrint() {
lH := hdrhistogram.New(1, 30000000, 3)
input := []int64{
459876, 669187, 711612, 816326, 931423, 1033197, 1131895, 2477317,
3964974, 12718782,
}

for _, sample := range input {
lH.RecordValue(sample)
}

lH.PercentilesPrint(os.Stdout, 1, 1.0)
// Output:
// Value Percentile TotalCount 1/(1-Percentile)
//
// 460031.000 0.000000 1 1.00
// 931839.000 0.500000 5 2.00
// 2478079.000 0.750000 8 4.00
// 3966975.000 0.875000 9 8.00
// 12722175.000 0.937500 10 16.00
// 12722175.000 1.000000 10 inf
// #[Mean = 2491481.600, StdDeviation = 3557920.109]
// #[Max = 12722175.000, Total count = 10]
// #[Buckets = 15, SubBuckets = 2048]
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/HdrHistogram/hdrhistogram-go
go 1.14

require (
github.com/golangci/golangci-lint v1.31.0 // indirect
github.com/google/go-cmp v0.5.2
github.com/stretchr/testify v1.6.1
)
Loading

0 comments on commit aada4ab

Please sign in to comment.