Earlier quoted context omitted.
It spawns a new process each time right? I would think that would but a cap on how accurate it can get. For my purposes I use it all the time though, quick and easy sanity-check.
The issue is it runs a kajillion tests to try and be “statistical”. But there’s no good way to say “just run it for 5 seconds and give me the best answer you can”. It’s very much designed for nanosecond to low microsecond benchmarks. Trying to fight this is trying to smash a square peg through a round hole.
Hyperfine: A command-line benchmarking tool
11–20 of 56 posts
Re: Hyperfine: A command-line benchmarking tool
#12Hyperfine is a great tool but when I was using it at Deno to benchmark startup time there was a lot of weirdness around the operating system apparently caching inodes of executables. If you are looking at shaving sub 20ms numbers, be aware you may need to pull tricks on macos especially to get real numbers.
I've found pretty good results with the System Trace template in xcode instruments. You can also stack instruments, for example combining the file inspector with a virtual memory inspector. I've run into some memory corruption with it sometimes, though, so be wary of that. Emerge tools has an alternative for iOS at least, maybe one day they'll port it to mac.
Re: Hyperfine: A command-line benchmarking tool
#13---
Re: Hyperfine: A command-line benchmarking tool
#14I've also had a good experience using the 'perf'[^1] tools for when I don't want to install 'hyperfine'. Shameless plug for a small blog post about it as I don't think it is that well known: https://usrme.xyz/tils/perf-is-more-robust-for-repeated-timi... . --- [^1]: https://www.mankier.com/1/perf
Re: Hyperfine: A command-line benchmarking tool
#15https://abuisman.com/posts/developer-tools/quick-page-benchm...
As mentioned here in the thread, when you want to go into the single ms optimisations it is not the best approach since there is a lot of overhead especially the way I demonstrate here, but it works very well for some sanity checks.
Re: Hyperfine: A command-line benchmarking tool
#16Hyperfine is a great tool but when I was using it at Deno to benchmark startup time there was a lot of weirdness around the operating system apparently caching inodes of executables. If you are looking at shaving sub 20ms numbers, be aware you may need to pull tricks on macos especially to get real numbers.
Re: Hyperfine: A command-line benchmarking tool
#17Earlier quoted context omitted.
It spawns a new shell for each run and subtracts the average shell startup time from final results. Too much noise
The shell can be disabled, leaving just fork+exec
Re: Hyperfine: A command-line benchmarking tool
#18Hyperfine is hyper frustrating because it only works with really really fine microsecond level benchmarks. Once you get into the millisecond range it’s worthless.
But for everything in the right range (milliseconds, seconds, minutes or above), hyperfine is well suited.
Re: Hyperfine: A command-line benchmarking tool
#19Earlier quoted context omitted.
It spawns a new process each time right? I would think that would but a cap on how accurate it can get. For my purposes I use it all the time though, quick and easy sanity-check.
The issue is it runs a kajillion tests to try and be “statistical”. But there’s no good way to say “just run it for 5 seconds and give me the best answer you can”. It’s very much designed for nanosecond to low microsecond benchmarks. Trying to fight this is trying to smash a square peg through a round hole.
If you see any reason for putting “statistical” in quotes, please let us know. hyperfine does not run a lot of tests, but it does try to find outliers in your measurements. This is really valuable in some cases. For example: we can detect when the first run of your program takes much longer than the rest of the runs. We can then show you a warning to let you know that you probably want to either use some warmup runs, or a "--prepare" command to clean (OS) caches if you want a cold-cache benchmark.
> But there’s no good way to say “just run it for 5 seconds and give me the best answer you can”.
What is the "best answer you can"?
> It’s very much designed for nanosecond to low microsecond benchmarks.
Absolutely not. With hyperfine, you can not measure execution times in the "low microsecond" range, let alone nanosecond range. See also my other comment.
Re: Hyperfine: A command-line benchmarking tool
#20Earlier quoted context omitted.
The shell can be disabled, leaving just fork+exec
Yes. If you don't make use of shell builtins/syntax, you can use hyperfine's `--shell=none`/`-N` option to disable the intermediate shell.