Standard library / testing
testing.BenchmarkResult.AllocsPerOp()
Compute allocation count per operation. Expected stdout: '3\nPASS\n'. Run as a _test.go file using the Go test harness.
Formal Syntax & Structure
go syntaxgo
func (r BenchmarkResult) AllocsPerOp() int64Return Value
int64
Result of the operation described above.
Working Example
Example Snippetgo
package main
import ( "fmt" "testing" "time")
func TestReference(t *testing.T) { r := testing.BenchmarkResult{N: 2, T: 10 * time.Nanosecond, MemBytes: 24, MemAllocs: 6} fmt.Println(r.AllocsPerOp())}