New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CPU time measurements to Benchmark.ips output #9846
base: master
Are you sure you want to change the base?
Add CPU time measurements to Benchmark.ips output #9846
Conversation
I like the idea 👍 It's also worth considering that inserting additional time metrics at the proposed location disturbes the visual correlation between variance and the data it's based on (ips / real time). |
I also like this, but I think it should be enabled by passing an argument to the |
Love the table formatting. If you could just slightly change it to left align the data in the first column, then it also would support markdown rendering, making it easy to copy/paste into a github issue/PR. Example: Before:
pipeline | 4.32k |231.53µs | 40.31µs | 30.75µs | ± 0.98% | 21.6kB/op | fastest After:
If you wanted to keep the right alignment of the other columns:
|
FYI, the |
Apologies for the delay in response. Been a wild few weeks.
Whether it's useful in enough cases, I'm not sure. Anecdotally, I work primarily on distributed systems so I/O is a huge component of what I do, and for anything that deals with I/O (even to With that said, though, I think it makes sense to keep Can you expand on what you think is convoluted, though? I think we may have different interpretations of that word in mind.
I think it makes a lot of sense to put the distinction between Part of this comes from a concern about the ways our tools influence how we measure. If we ignore CPU time by default, I wonder if anyone will ever look at it.
Whoa, there's already a thing for this?? If we end up going this route, would it make sense to document that helper/move it out of the |
It should remain internal. There are shards more feature complete for others to use. But if you need to expand things for have better formatting or alignments feel free to change that helper. |
I mean that the number of data points per row in Additionally, the line length grows enormously. In your examples it's 98 characters. Table format it's a bit less because you can leave the units, but not by much. But with so much data, chances are that it might cause the line to wrap if the terminal is not wide enough. Broken lines are going to look terrible. That may be acceptable if you really need the additional data. But I assume most use cases don't. Bottom line, adding more measurements makes the output harder to read because it presents data most users likely didn't even ask for. |
Not quite, I only added 2 metrics. 🙂 In v0.35.1,
Your point about line length is important and it's something I didn't even think about, so I appreciate you pointing that out. In this example, the lines are 84 characters. We could probably shave off a few by using 3 significant digits instead of 2 decimal places (because 5 significant digits isn't exactly useful) and trim down a couple other places. Here's a mockup for that:
This comes in at 79 characters wide with an 8-character benchmark name. If we go with the table:
Surprisingly not much shorter. 😂 But it might be easier to read.
How many people asked for heap allocations in the output? Judging from the PR where it was added, it doesn't look like a lot. I'd be willing to bet most people who use it to tune their code regularly didn't even know getting the memory usage of a block could feasibly be done. I know I didn't, but now I use it all the time. 🙂 In the same way, I'm trying to give people something they need, rather than something they asked for. And I do think anyone trying to optimize any kind of code which performs I/O benefits from this, even if they don't realize it right now. |
I'm on board with adding only CPU time by default. Maybe we can find a way to more unambiguously communicate that ips and stddev relate to real time measurement. |
Wall-clock time is a fantastic approximation of scalability if the CPU is never yielded inside the block. Unfortunately, in measuring execution time for database queries, HTTP requests, or things like that, you need a lot of iterations over the block to understand how well it scales in terms of the application.
Benchmark.ips
gives us a really nice way to measure time spent per iteration without having to dial in the number of iterations ourselves, but we can't get CPU usage information from it.This PR adds that to the
Benchmark.ips
report:This will probably need a little more work (for example, I used the simple form of
humanize
instead of the block form as was used elsewhere, which may not be ideal), but I'm curious what people's thoughts are before putting more time into this. 🙂If folks are good with this, since we'd be outputting so much information here in a quasi-tabular format, would it make sense to make it an actual table?