I wouldn’t trust any benchmark that
a) is done in the global scope
b) uses @time on a fast function
c) produces 0 a second output (unless @code_native shows it’s a no-op)
Since these are all timing between 1 and a handful of machine instructions though, they should indeed be very fast. None of them allocate as written.
Great!
I should say that my sub-nanosecond times were also quite suspicious. I went back and fixed where the Refs were and the results make more sense now. The documentation discusses why this happens
Well, consider the call to “bar” which combine some of the operations you mention - and has reportedly zero allocation. But Tom mailed the issue: my measurements where wrong. Carefully using @btime I get results that make much better sense.