Standard library / testing

testing.BenchmarkResult.AllocedBytesPerOp()

Compute allocated bytes per operation. Expected stdout: '12\nPASS\n'. Run as a _test.go file using the Go test harness.

Formal Syntax & Structure

go syntaxgo
func (r BenchmarkResult) AllocedBytesPerOp() int64

Return 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.AllocedBytesPerOp())}
Go Reference