Standard library / testing
testing.PB.Next()
Claim the next parallel benchmark iteration; false means no more iterations for the worker. Expected stdout: 'true\nPASS\n'. Run as a _test.go file using the Go test harness.
Formal Syntax & Structure
go syntaxgo
func (pb *PB) Next() boolReturn Value
bool
Result of the operation described above.
Working Example
Example Snippetgo
package main
import ( "fmt" "sync/atomic" "testing")
func TestReference(t *testing.T) { r := testing.Benchmark(func(b *testing.B) { var n atomic.Int64 b.RunParallel(func(pb *testing.PB) { for pb.Next() { n.Add(1) } }) if n.Load() != int64(b.N) { b.Fatal("count") } }) fmt.Println(r.N > 0)}