The Julia 1.0.0 documentation provides general tips.
It also suggests that instead of using the @time macro:
For more serious benchmarking, consider the BenchmarkTools.jl package which among other things evaluates the function multiple times in order to reduce noise.
How do they compare in use and is it worth the trouble to use something not in "base" Julia?
From a statistical point of view, @benchmark is much better than @time
TL;DR The BenchmarkTools
@benchmark
macro is a great micro-benchmark tool. Use the@time
macro with caution and don't take the first run seriously.This simple example illustrates use and differences:
This simple example illustrates how easy it is to use the
@benchmark
macro and the caution with which the@time
macro results should be taken.Yes, it is worth the trouble to use the
@benchmark
macro.