What can be the difference, that makes @time and @btime time different time in these scenarios?
a, b = 6, 7 foo(a, b) = begin for i = 1:2 a, b=a + 6, b + 7+i end end @time foo(a,b) @time foo(a,b) @btime $foo($a,$b)
0.008822 seconds (17.17 k allocations: 1.149 MiB, 99.61% compilation time) 0.000004 seconds (1 allocation: 32 bytes) 1.555 ns (0 allocations: 0 bytes)
I know there is an allocation for the tuple return a,b… but why doesn’t
@btime shows it? Or is it elliminated in some optimisation process?
I used @btime in one of my project that showed I eliminated one allocation this way in a speed intensive unit and not sure if it is just a mistake of the timing or there are still allocations?
Thank you for the answer!