Repository navigation
Conversation
This commit adds a new print option `--format=benchstat` In a contrast to a default side-by-side table, this new mode instead prints one compact table per metric, in the style of Go's [benchstat](https://pkg.go.dev/golang.org/x/perf/cmd/benchstat). Assisted-By: Antigravity
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
LebedevRI
left a comment
There was a problem hiding this comment.
I can't tell what those tests are testing.
What is the actual behaviour if:
- there are no repetitions in the input
- there are only aggregates in the input
- input contains repetitions and their aggregates
| def test_format_with_suffix(self): | ||
| self.assertEqual(format_with_suffix(None), "N/A") | ||
| self.assertEqual(format_with_suffix(0), "0.00") | ||
| self.assertEqual(format_with_suffix(12), "12.00") | ||
| self.assertEqual(format_with_suffix(999.9), "999.90") | ||
| self.assertEqual(format_with_suffix(1000), "1.00K") | ||
| self.assertEqual(format_with_suffix(8256525), "8.26M") | ||
| self.assertEqual(format_with_suffix(4868373980), "4.87G") | ||
| self.assertEqual(format_with_suffix(1234567890123), "1.23T") | ||
|
|
||
| def test_format_time_s(self): | ||
| self.assertEqual(format_time_s(None), "N/A") | ||
| self.assertEqual(format_time_s(0.0), "0.00ns") | ||
| self.assertEqual(format_time_s(4.25e-8), "42.50ns") | ||
| self.assertEqual(format_time_s(1.5e-4), "150.0us") | ||
| self.assertEqual(format_time_s(0.1147), "114.7ms") | ||
| self.assertEqual(format_time_s(3.071), "3.07s") | ||
| # Rounding up to a boundary moves on to the next unit / precision. | ||
| self.assertEqual(format_time_s(9.99996e-7), "1.00us") | ||
| self.assertEqual(format_time_s(0.99996), "1.00s") | ||
| self.assertEqual(format_time_s(9.9999e-5), "100.0us") |
There was a problem hiding this comment.
Is the number of decimal digits enforced by benchstat format?
I think the existing formatting elsewhere in the repo is a mistake,
and we should consistently use engineering format,
i.e. deduce the suffix as usual, and then always print exactly 4 digits.
This commit adds a new print option
--format=benchstatIn contrast to a default side-by-side table,
this new mode instead prints one compact table per metric,
in the style of Go's benchstat.
This PR closes #2397
Assisted-By: Antigravity