File: histogram_timing_test.go

package info (click to toggle)
golang-github-valyala-histogram 1.1.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 88 kB
  • sloc: makefile: 2
file content (25 lines) | stat: -rw-r--r-- 356 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package histogram

import (
	"sync"
	"testing"
)

func BenchmarkFastUpdate(b *testing.B) {
	b.ReportAllocs()
	b.SetBytes(1)
	b.RunParallel(func(pb *testing.PB) {
		f := NewFast()
		var v float64
		for pb.Next() {
			f.Update(v)
			v += 1.5
		}
		SinkLock.Lock()
		Sink += f.Quantile(0.5)
		SinkLock.Unlock()
	})
}

var Sink float64
var SinkLock sync.Mutex