Standard library / testing

testing.B.Name()

Return the full name of the current benchmark or fuzz test, including hierarchy where applicable. Expected process exit: 0; output contains ['PASS', 'name BenchmarkReference']. Run as a _test.go file using the Go test harness.

Formal Syntax & Structure

go syntaxgo
func (c *B) Name() string

Return Value

string

Result of the operation described above.

Working Example

Example Snippetgo
package main
import (  "fmt"  "testing")
func BenchmarkReference(b *testing.B) { fmt.Println("name", b.Name()) }
Go Reference
testing.B.Name() — Go Syntax & Examples | ByteMind