Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Speed difference when storing annonymous function in variable vs. function

$
0
0

@moustachio-belvedere wrote:

Apologies if I am making a mistake with my benchmarking here, but I am wondering why there is such a significant speed difference between using an annonymous function stored in a variable vs. stored in a function, as in the MWE below:

function new_anon()
    f(a) = a -> (a^(a-1))/a
end

test1 = new_anon()
test2(x) = new_anon()(x)

@btime test1(5) # 20.190 ns (0 allocations: 0 bytes)
@btime test2(5) # 0.001 ns (0 allocations: 0 bytes)

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images