summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/beorn7/perks/histogram/histogram_test.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-11-22 11:05:54 -0800
committerHarrison Healey <harrisonmhealey@gmail.com>2016-11-22 14:05:54 -0500
commit7961599b2e41c71720a42b3bfde641f7529f05fe (patch)
tree3c039e1d3790a954ba65fe551c7b348331bce994 /vendor/github.com/beorn7/perks/histogram/histogram_test.go
parente033dcce8e57ed6b6684227adf9b29347e4718b3 (diff)
downloadchat-7961599b2e41c71720a42b3bfde641f7529f05fe.tar.gz
chat-7961599b2e41c71720a42b3bfde641f7529f05fe.tar.bz2
chat-7961599b2e41c71720a42b3bfde641f7529f05fe.zip
PLT-4357 adding performance monitoring (#4622)
* WIP * WIP * Adding metrics collection * updating vendor packages * Adding metrics to config * Adding admin console page for perf monitoring * Updating glide * switching to tylerb/graceful
Diffstat (limited to 'vendor/github.com/beorn7/perks/histogram/histogram_test.go')
-rw-r--r--vendor/github.com/beorn7/perks/histogram/histogram_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/vendor/github.com/beorn7/perks/histogram/histogram_test.go b/vendor/github.com/beorn7/perks/histogram/histogram_test.go
new file mode 100644
index 000000000..0575ebeee
--- /dev/null
+++ b/vendor/github.com/beorn7/perks/histogram/histogram_test.go
@@ -0,0 +1,38 @@
+package histogram
+
+import (
+ "math/rand"
+ "testing"
+)
+
+func TestHistogram(t *testing.T) {
+ const numPoints = 1e6
+ const maxBins = 3
+
+ h := New(maxBins)
+ for i := 0; i < numPoints; i++ {
+ f := rand.ExpFloat64()
+ h.Insert(f)
+ }
+
+ bins := h.Bins()
+ if g := len(bins); g > maxBins {
+ t.Fatalf("got %d bins, wanted <= %d", g, maxBins)
+ }
+
+ for _, b := range bins {
+ t.Logf("%+v", b)
+ }
+
+ if g := count(h.Bins()); g != numPoints {
+ t.Fatalf("binned %d points, wanted %d", g, numPoints)
+ }
+}
+
+func count(bins Bins) int {
+ binCounts := 0
+ for _, b := range bins {
+ binCounts += b.Count
+ }
+ return binCounts
+}