diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-06-22 17:00:55 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-06-24 23:34:04 +0800 |
commit | 7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4 (patch) | |
tree | 9f770d2f59ca1a3053ebf7aa7921a122aa3bc388 /Godeps/_workspace/src/github.com/rcrowley/go-metrics/metrics_test.go | |
parent | 7f92e708c504e1c4a7382c68b5a4ed68db9c8deb (diff) | |
download | go-tangerine-7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4.tar go-tangerine-7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4.tar.gz go-tangerine-7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4.tar.bz2 go-tangerine-7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4.tar.lz go-tangerine-7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4.tar.xz go-tangerine-7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4.tar.zst go-tangerine-7bd71fa80071f86ca86ed7ef64ab51c88cabe7d4.zip |
godeps: pull in go-metrics
Diffstat (limited to 'Godeps/_workspace/src/github.com/rcrowley/go-metrics/metrics_test.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/rcrowley/go-metrics/metrics_test.go | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/rcrowley/go-metrics/metrics_test.go b/Godeps/_workspace/src/github.com/rcrowley/go-metrics/metrics_test.go new file mode 100644 index 000000000..083f9676f --- /dev/null +++ b/Godeps/_workspace/src/github.com/rcrowley/go-metrics/metrics_test.go @@ -0,0 +1,107 @@ +package metrics + +import ( + "io/ioutil" + "log" + "sync" + "testing" +) + +const FANOUT = 128 + +// Stop the compiler from complaining during debugging. +var ( + _ = ioutil.Discard + _ = log.LstdFlags +) + +func BenchmarkMetrics(b *testing.B) { + r := NewRegistry() + c := NewRegisteredCounter("counter", r) + g := NewRegisteredGauge("gauge", r) + gf := NewRegisteredGaugeFloat64("gaugefloat64", r) + h := NewRegisteredHistogram("histogram", r, NewUniformSample(100)) + m := NewRegisteredMeter("meter", r) + t := NewRegisteredTimer("timer", r) + RegisterDebugGCStats(r) + RegisterRuntimeMemStats(r) + b.ResetTimer() + ch := make(chan bool) + + wgD := &sync.WaitGroup{} + /* + wgD.Add(1) + go func() { + defer wgD.Done() + //log.Println("go CaptureDebugGCStats") + for { + select { + case <-ch: + //log.Println("done CaptureDebugGCStats") + return + default: + CaptureDebugGCStatsOnce(r) + } + } + }() + //*/ + + wgR := &sync.WaitGroup{} + //* + wgR.Add(1) + go func() { + defer wgR.Done() + //log.Println("go CaptureRuntimeMemStats") + for { + select { + case <-ch: + //log.Println("done CaptureRuntimeMemStats") + return + default: + CaptureRuntimeMemStatsOnce(r) + } + } + }() + //*/ + + wgW := &sync.WaitGroup{} + /* + wgW.Add(1) + go func() { + defer wgW.Done() + //log.Println("go Write") + for { + select { + case <-ch: + //log.Println("done Write") + return + default: + WriteOnce(r, ioutil.Discard) + } + } + }() + //*/ + + wg := &sync.WaitGroup{} + wg.Add(FANOUT) + for i := 0; i < FANOUT; i++ { + go func(i int) { + defer wg.Done() + //log.Println("go", i) + for i := 0; i < b.N; i++ { + c.Inc(1) + g.Update(int64(i)) + gf.Update(float64(i)) + h.Update(int64(i)) + m.Mark(1) + t.Update(1) + } + //log.Println("done", i) + }(i) + } + wg.Wait() + close(ch) + wgD.Wait() + wgR.Wait() + wgW.Wait() +} |