github.com/loov/hrtime@v1.0.3/hrtesting/doc.go (about) 1 // Package hrtesting implements wrappers for testing.B that allow to output 2 // more detailed information in standard go benchmarks. 3 // 4 // Since, it is mainly built for convenience it needs to call `b.StartTimer` and other benchmark 5 // timer functions. As a result, manually calling them can cause unintended measurement results. 6 // 7 // Since such benchmarking will have an overhead, it will increase single measurement results. 8 // To disable that measurement temporarily "-tags nohrtime". 9 // 10 // To use this package write your benchmark as: 11 // 12 // func BenchmarkHello(b *testing.B) { 13 // bench := hrtesting.NewBenchmark(b) 14 // defer bench.Report() 15 // 16 // for bench.Next() { 17 // fmt.Sprintf("hello") 18 // } 19 // } 20 // 21 // Only statements in the `for bench.Next() {` loop will be measured. 22 // 23 // To use time stamp counters, which are not supported on all platforms: 24 // 25 // func BenchmarkHello(b *testing.B) { 26 // bench := hrtesting.NewBenchmarkTSC(b) 27 // defer bench.Report() 28 // 29 // for bench.Next() { 30 // fmt.Sprintf("hello") 31 // } 32 // } 33 // 34 package hrtesting