Benchmarking
testing package - testing - Go Packages
Package testing provides support for automated testing of Go packages.
CLI
go test -bench=. # execute benchmarks
go test -bench=. -benchmem # show memory allocationsExample Code
func BenchmarkRepeat(b *testing.B) {
for i := 0; i < b.N; i++ {
Repeat("a")
}
}