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