Live data from Hacker News

Show HN: Hyperfine – a command-line benchmarking tool

github.com

11–20 of 26 posts

Re: Show HN: Hyperfine – a command-line benchmarking tool

#11
post #6

Most -- nearly all -- benchmarking tools like this work from a normality assumption, i.e. assume that results follow the normal distribution, or is close to it. Some do this on blind faith, others argue from the CLT that "with infinite samples, the mean is normally distributed, so surely it must be also with finite number of samples, at least a little?" In fact, performance numbers (latencies) often follow a heavy-ta…

Thank you for the feedback. I agree with most of your points.

> Most -- nearly all -- benchmarking tools like this work from a normality assumption

I don't think that hyperfine makes any assumption about normality. Sure, we do report sample mean and sample standard deviation by default, but we also report sample minimum and the maximum. You can also easily export all the benchmark results and inspect in more detail with the supplied Python scripts.

> In fact, performance numbers (latencies) often follow a heavy-tailed distribution

So when is this really the case? In my understanding, if I am measuring the runtime of a deterministic program with the same input, the runtime should only be influenced by external factors that are out of my control (other programs being scheduled, caching effects, hardware-specific influences, ..). These are exactly the things that I want to "average out" by running the benchmark multiple times.

> What's worse is when these tools start to remove "outliers".

Hyperfine never removes outliers. What we do is to try and detect outliers. We do this by computing robust statistical estimates that specifically DO NOT assume a normal distribution (see https://github.com/sharkdp/hyperfine/blob/master/src/hyperfi... for details).

We perform this outlier detection to warn users about potentially interfering processes or caching effects.

Take a look at these results, for example: https://i.imgur.com/XRvE6Ys.png

I benchmarked a file-searching program. The underlying distribution, while probably not normal, seems to be "well behaved" and I think that the sample mean and the sample standard deviation could be quantities with a reasonably predictive power.

What you do NOT see in the histogram is a single outlier at 1.15 seconds, far outside the plot to the right. This was the first benchmark run where the disk caches were still cold. In such a case, hyperfine warns the user:

Warning: The first benchmarking run for this command was significantly slower than the rest (1.152 s). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.

In conclusion, I am not quite sure how your critisism applies to hyperfine, but I'd be happy to get further feedback.

Re: Show HN: Hyperfine – a command-line benchmarking tool

#12
post #2

I have submitted "hyperfine" 1.5 years ago when it just came out. Since then, the program has gained functionality (statistical outlier detection, result export, parametrized benchmarks) and maturity. Old discussion: https://news.ycombinator.com/item?id=16193225 Looking forward to your feedback!

Since you cite bench as an inspiration, have you ever thought about including the nice graphical HTML page with graphs that bench outputs? In a similar vein what are your thoughts on directly depending on and using criterion (the Rust port)?

Thank you for the feedback.

No, we never thought about HTML output. However, there are multiple other export options and we also ship Python scripts that can be used to plot the benchmark results. The script is not very large, so far, but we are happy to add new scripts if the need for one should arise. What kind of diagrams would you like to see?

Also, I have never thought about using criterion.rs. My feeling was that it is suited for benchmarks with thousands of iterations, while we typically only have tens of iterations in hyperfine (as we typically benchmark programs with execution times > 10 ms). Do you have anything specific criterion feature in mind that we could benefit from?

Re: Show HN: Hyperfine – a command-line benchmarking tool

#13
post #12

Earlier quoted context omitted.

Since you cite bench as an inspiration, have you ever thought about including the nice graphical HTML page with graphs that bench outputs? In a similar vein what are your thoughts on directly depending on and using criterion (the Rust port)?

Thank you for the feedback. No, we never thought about HTML output. However, there are multiple other export options and we also ship Python scripts that can be used to plot the benchmark results. The script is not very large, so far, but we are happy to add new scripts if the need for one should arise. What kind of diagrams would you like to see? Also, I have never thought about using criterion.rs. My feeling was th…

Ah those were earnest questions, not feature requests in disguise :), especially the second question. I haven't so far had any need for either of those things while using hyperfine (although admittedly I've only used hyperfine for about 3 small projects).

I ask purely as a comparison to some of the design choices bench made for personal edification.

That being said, one of the hypothetical advantages of using criterion is that you get to piggy-back on its visualizations and statistical analyses, which are quite useful for showing friends and coworkers. I'm not sure of the specifics of how you're doing outlier detection, but Criterion's method is quite nice and I find the choice of linear regression for linearly increasing iterations to be an interesting sanity check.

Criterion can work for lower iterations as well (although tens is definitely getting into the lower bound).

Re: Show HN: Hyperfine – a command-line benchmarking tool

#14
post #6

Most -- nearly all -- benchmarking tools like this work from a normality assumption, i.e. assume that results follow the normal distribution, or is close to it. Some do this on blind faith, others argue from the CLT that "with infinite samples, the mean is normally distributed, so surely it must be also with finite number of samples, at least a little?" In fact, performance numbers (latencies) often follow a heavy-ta…

> Report the maximum value. In benchmarks, assuming you run the same workload each time, you often want the minimum value. Anything else just tells you how much system overhead you encountered. (Complete agreement that applying statistics without knowing anything about the distribution can mislead.)

[This article](https://tratt.net/laurie/blog/entries/minimum_times_tend_to_...) explaib why using the minimum time may not be a so great idea.

Re: Show HN: Hyperfine – a command-line benchmarking tool

#15
post #6

Most -- nearly all -- benchmarking tools like this work from a normality assumption, i.e. assume that results follow the normal distribution, or is close to it. Some do this on blind faith, others argue from the CLT that "with infinite samples, the mean is normally distributed, so surely it must be also with finite number of samples, at least a little?" In fact, performance numbers (latencies) often follow a heavy-ta…

I agree that the maximum is useful, but in a situation where you're optimizing code on a machine where there is external interference from other processes, the minimum can be more relevant.

This is when the code you write is deterministic and the interference is not. The minimum is closer to what you would get without interference.

Just don't effect the time to represent typical results. (And why would you expect that if you're running benchmarks on your development machine?)

Re: Show HN: Hyperfine – a command-line benchmarking tool

#17
post #14

Earlier quoted context omitted.

> Report the maximum value. In benchmarks, assuming you run the same workload each time, you often want the minimum value. Anything else just tells you how much system overhead you encountered. (Complete agreement that applying statistics without knowing anything about the distribution can mislead.)

[This article]( https://tratt.net/laurie/blog/entries/minimum_times_tend_to_... ) explaib why using the minimum time may not be a so great idea.

Just looking at the chart, your article makes a case that minimum is much better than maximum, and in fact if you report one number, the minimum is the best number to report (in that particular example).

If we go into details - sure, 1 number is not ideal, but neither is the confidence interval, because people will assume normal distribution for them. If you report 2 numbers, perhaps instead of confidence interval (which falsely implies normal distribution) it's better to report the mode and the median.

Re: Show HN: Hyperfine – a command-line benchmarking tool

#19

hyperfine is really nice! FWIW I wrote a rough first version of a tool that runs a hyperfine benchmark over all commits in a repo and plots the results in order to see which commits cause performance changes: https://github.com/dandavison/chronologer

Very cool! I'd love to reference this in the hyperfine README

Re: Show HN: Hyperfine – a command-line benchmarking tool

#20
post #10
post #6

Most -- nearly all -- benchmarking tools like this work from a normality assumption, i.e. assume that results follow the normal distribution, or is close to it. Some do this on blind faith, others argue from the CLT that "with infinite samples, the mean is normally distributed, so surely it must be also with finite number of samples, at least a little?" In fact, performance numbers (latencies) often follow a heavy-ta…

If your distribution is heavy-tailed, then in order to find the mean (or any other measure of "location") you typically need to pay _less_ attention to outliers, not _more_. So, e.g.: for a normal distribution, with very narrow tails -- probabilities like exp(-x^2) -- your sample mean is the maximum-likelihood estimator. For a double-exponential (Laplace) distribution, whose tails are like exp(-|x|) and therefore muc…

This reads like a circular argument to me. I'm saying that the MLE is not a very useful measure of location for fat tailed distributions, since extreme values contribute so much to the expectation.
Post reply on HN