I was playing around with this and can someone explain me this: Just by removing the type annotation I get 4x faster execution. In the meantime the @code_warntype
code remains the same:
function f2(y)
loop(x) = x > 0 ? 1 + loop(x-1) : 0
loop(y)
end
In my machine f(100)
runs in 14μs and f2(100)
in 3μs.
julia> @btime f2(100)
3.066 μs (2 allocations: 32 bytes)
What surprises me is that even @code_llvm
code looks the same. Is there any way to understand what is going on here ?