Standard library / testing
testing.B
Benchmark handle; Go 1.23 uses b.N iterations. Obtain the handle from the test harness. Expected stdout: 'true\nPASS\n'. Run as a _test.go file using the Go test harness.
Formal Syntax & Structure
go syntaxgo
type B struct { N int
}Working Example
Example Snippetgo
package main
import ( "fmt" "testing")
func TestReference(t *testing.T) { r := testing.Benchmark(func(b *testing.B) { for j := 0; j < b.N; j++ { } }) fmt.Println(r.N > 0)}