Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
proposal: testing: custom benchmark labels #28398
Currently go benchmark output reports some labels:
These are added by
It would be great if the user could add custom labels relevant to the performance of their code. For example:
I have noticed that the
An option to
My concrete proposal is an additional function in the
// SetBenchmarkLabel records a value relevant to benchmark performance. This // will be included in benchmark output ahead of individual benchmark results. // Labels "goos", "goarch" and "pkg" are set by default. SetBenchmarkLabel(key, value string)
Not sure about naming, but hopefully this gives the idea.
I recently implmented Meow hash for Golang. This hash is designed to take advantage of hardware AES instructions, therefore the implementation dispatches to one of three backends based on CPUID flags at runtime (pure Go, AES-NI and VAES-256/512).
To provide useful context in the test/benchmark output, I have two test functions that exist
I would prefer to include these as "official" labels:
testing.SetBenchmarkLabel("backend", implementation) testing.SetBenchmarkLabel("hasaesni", cpu.HasAES) testing.SetBenchmarkLabel("hasavx", cpu.HasAVX) ...
Comparison: Google Benchmark
Note that Google benchmark also provides context with benchmark runs. For
It would be great it was also possible to add CPU/cache information in Go
Note that this output has been formalized in the following document:
In particular these "labels" are called "Configuration Lines".
Moreover, this document makes
The existing implementation (and prototype CL) print the labels inside a
// SetBenchmarkLabel records a value relevant to benchmark performance. This // will be included in benchmark output ahead of individual benchmark results. // Any SetBenchmarkLabel calls after the first benchmark is executed will be // ignored. Labels "goos", "goarch" and "pkg" are set by default. SetBenchmarkLabel(key, value string)
Did you have some other behavior in mind?
Yes it would be great to get @aclements input.
This seems easy enough, but I'd like to understand the use case you have in mind. Are you thinking about