-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
go test -bench has printed system information like goos, goarch, and cpu as part of benchmark results for some time now:
Lines 265 to 272 in 59ab6f3
| fmt.Fprintf(b.w, "goos: %s\n", runtime.GOOS) | |
| fmt.Fprintf(b.w, "goarch: %s\n", runtime.GOARCH) | |
| if b.importPath != "" { | |
| fmt.Fprintf(b.w, "pkg: %s\n", b.importPath) | |
| } | |
| if cpu := sysinfo.CPU.Name(); cpu != "" { | |
| fmt.Fprintf(b.w, "cpu: %s\n", cpu) | |
| } |
As a companion to goarch and cpu, I think we should also include the value of Go environment variables like GOAMD64 - similar env vars include GOARM, GOMIPS64, etc. They are listed together in go help environment.
This matters just like cpu does: benchmark numbers will vary between CPUs, and some benchmarks might benefit significantly from GOAMD64=v3 compared to the default of GOAMD64=v1.
For the sake of reducing verbosity, we could only print these if they are set to a non-default value. GOAMD64=v1 wouldn't be printed, but GOAMD64=v3 would be.
Arguably there are lots of other factors that could contribute to higher or lower benchmark results, such as what kernel the sytem is running, which C toolchain was used to build cgo, what Go version is being used, etc. However, env vars like GOAMD64 feel much more in line with the goarch and cpu lines we already print, and they are a set of Go build options which directly affect performance.