I am seeing performance a big difference between using FunctionWrappers
and native function call. Is this to be expected ?
Please see the MWE below:
using BenchmarkTools
using FunctionWrappers: FunctionWrapper
struct A{T}
x::T
end
get_power(a::A{T}, y::T,z::T) where {T} = a.x + y + z
const Fwarpper = FunctionWrapper{Float64,Tuple{A{Float64},Float64,Float64}}
const dict = Vector{Fwarpper}(1)
dict[1] = Fwarpper(get_power)
a = A(1.5)
@btime @inbounds get_power($a,5.6,7.87);
0.488 ns (0 allocations: 0 bytes)
@btime @inbounds dict[1]($a,5.6,7.87);
12.863 ns (0 allocations: 0 bytes)
This suggest that there is a ~25X overhead for this case ?
Is it normal to expect this overhead between explicitly calling a function and calling a function via FunctionWrappers
?
It seems like this [post] (Performance of functions returned from container) @yuyichao seemed to suggest there there is no overhead.
My Julia VersionInfo
Commit 68e911b (2017-05-18 02:31 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)
I might be doing this all wrong as I am using FunctionWrappers
for the first time.
thanks!