Base.@ccallable function julia_set_dB_gain(dB_gain::Cdouble)::Cvoid
isCalculationValid[]=false # Parameter Set, so invalidate current answer
inputRef[].dB_gain = dB_gain
return nothing
end
f(x) = ccall("extern julia_set_dB_gain", llvmcall, Cvoid, (Cdouble,), x)
using BenchmarkTools
julia> @benchmark f(1.0)
BenchmarkTools.Trial: 10000 samples with 998 evaluations.
Range (min … max): 16.092 ns … 230.391 ns ┊ GC (min … max): 0.00% … 83.13%
Time (median): 17.305 ns ┊ GC (median): 0.00%
Time (mean ± σ): 18.390 ns ± 6.985 ns ┊ GC (mean ± σ): 0.48% ± 2.21%
▂ ▆█▄▃▁▅ ▁▃▂▁▁ ▁ ▂
█▅▁▄▅▆███████▅▅▇▆▃▃▄▁▁▃▃▄▄▅▄▄▅▆█▇▇▆▅▅▄▄██████▇▆▅▄▅███▇▇▆▅▄▁▃ █
16.1 ns Histogram: log(frequency) by time 26.1 ns <
Memory estimate: 16 bytes, allocs estimate: 1.
That surprised me, but it seems the argument passing is indeed the culprit…