Quirks when benchmarking allocations of StaticArrays in anonymous functions

fanon is a (non-const) global variable:

julia> using StaticArrays, BenchmarkTools

julia> vec = [1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> svec = SA[1, 2, 3]
3-element SVector{3, Int64} with indices SOneTo(3):
 1
 2
 3

julia> const c_fanon = x-> 0
#5 (generic function with 1 method)

julia> @ballocations cfanon($vec)
0

julia> @ballocations cfanon($svec)
0
3 Likes