You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using BenchmarkTools
struct S
end
(s::S)() =1let
s =S()
# @btime $s()@times()
end
From which I get output 0.000000 seconds. No surprise here since the function should not have any allocations. But things change if I add @btime before @time like so:
I suspect this is due to the compiler not optimising the code as well in the second case, e.g. replace @time with @timed and you will see less allocations (@time calls @timed internally). Given wrapping the code in a function makes the allocation disappear I'm not sure how to look at the compiled code and verify.
Also posted in discource
Minimal example:
From which I get output
0.000000 seconds
. No surprise here since the function should not have any allocations. But things change if I add@btime
before@time
like so:From which I get output
So
@time
depends on previous seemingly unrelated calls.I tried
@allocated
and it correctly prints out 0:If the code is in a function, then
@time
output is correct, as pointed out in discourse. But personally I think this is still a bug.Julia is installed via juliaup.
The text was updated successfully, but these errors were encountered: