>
> The is true, and that is also what I wanted to do. When using @elapsed, 
> should I then be worried about garbage collection affecting my times?


When making benchmarks you should worry about everything!, and make efforts 
to ensure that your synthetic results actually extrapolates to the code you 
optimize based on the benchmarks (or at least know that you might have 
uncertenty in your result). Garbage collection is a quite time consuming 
process that it is hard to predict when it will run. The worst situation is 
if the first algorithm allocates lots of memory, and the second algorithm 
gets penalized when it needs some memory and the GC finds out that it is 
time to collect.

The implementation for @elapsed is very simple 
<https://github.com/JuliaLang/julia/blob/45e5fa15c03571c3ffb1bead9c03fa3a7ac30f09/base/util.jl#L75-l81>,
 
so it will not exclude gc or any other overhead. Arguably ignoring it would 
be cheating.

# print nothing, return elapsed time 
macro elapsed(ex) 
    quote 
        local t0 = time_ns() 
        local val = $(esc(ex)) 
        (time_ns()-t0)/1e9 
    end 
end

@Simon Danish
A benchmarking suite as a package will be really great!

Reply via email to