Permalink
Browse files

examples: add a basic histogram example

  • Loading branch information...
1 parent cdcf001 commit 38f2520e3261857495cd9f5d1a01251267b6a734 @suyash suyash committed Aug 12, 2016
Showing with 37 additions and 0 deletions.
  1. +37 −0 examples/basic_histogram/main.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+ "fmt"
+ "math/rand"
+ "time"
+
+ "github.com/performancecopilot/speed"
+)
+
+func main() {
+ max := int64(100)
+
+ c, err := speed.NewPCPClient("histogram_test")
+ if err != nil {
+ panic(err)
+ }
+
+ m, err := speed.NewPCPHistogram("hist", 0, max, "a sample histogram")
+ if err != nil {
+ panic(err)
+ }
+
+ c.MustRegister(m)
+
+ c.MustStart()
+ defer c.MustStop()
+
+ for i := 0; i < 60; i++ {
+ v := rand.Int63n(max)
+
+ fmt.Println("recording", v)
+ m.MustRecord(v)
+
+ time.Sleep(time.Second)
+ }
+}

0 comments on commit 38f2520

Please sign in to comment.