Standard library / testing
testing.BenchmarkResult
Holds benchmark iteration count, elapsed time, allocations, bytes processed and custom metrics. Expected stdout: '2 4\nPASS\n'. Run as a _test.go file using the Go test harness.
Formal Syntax & Structure
go syntaxgo
type BenchmarkResult struct { N int T time.Duration Bytes int64 MemAllocs uint64 MemBytes uint64
Extra map[string]float64}Working Example
Example Snippetgo
package main
import ( "fmt" "testing" "time")
func TestReference(t *testing.T) { r := testing.BenchmarkResult{N: 2, T: 10 * time.Nanosecond, Bytes: 4} fmt.Println(r.N, r.Bytes)}