Benchmarking

testing package - testing - Go Packages
Package testing provides support for automated testing of Go packages.
https://pkg.go.dev/testing#hdr-Benchmarks

CLI

go test -bench=.            # execute benchmarks
go test -bench=. -benchmem  # show memory allocations

Example Code

func BenchmarkRepeat(b *testing.B) {
	for i := 0; i < b.N; i++ {
		Repeat("a")
	}
}