Using BenchmarkTools.jl
The solution, then, is to use the BenchmarkTools.jl package for statistically accurate benchmarking. Install the package via the Julia package manager, and thereafter it is simple to use. Instead of using @time, use the @benchmark macro. Unlike @time, however, this macro can only be used in front of function calls, rather than any expression. It will evaluate the parameters of the function separately, and then call the function multiple times to build up a sample of execution times.
The output will show the mean time taken to run the code, but with statistically accurate upper and lower bounds. These statistics are estimated by evaluating the expression multiple times, with the number of evaluations determined in ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access