The tools described in this chapter, particularly the @time macro, are useful for identifying and investigating bottlenecks in our program. However, they are not very accurate in terms of a fine-grained analysis of fast programs. If you want to, for example, compare two functions that take a few milliseconds to run, the amount of error and variability in the measurement will easily swamp the running time of this function.
Statistically accurate benchmarking
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...