Standard library / testing
testing.B.SetBytes()
Set bytes processed per operation for throughput reporting. Expected stdout: '8\nPASS\n'. Run as a _test.go file using the Go test harness.
Formal Syntax & Structure
go syntaxgo
func (b *B) SetBytes(n int64)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| n | int64 | Byte limit or numeric measurement, depending on the API. |
Working Example
Example Snippetgo
package main
import ( "fmt" "testing")
func TestReference(t *testing.T) { r := testing.Benchmark(func(b *testing.B) { b.SetBytes(8) for j := 0; j < b.N; j++ { } }) fmt.Println(r.Bytes)}