-
-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Description
Hello,
First thanks for the package, it came very handy in code that I needed. However, I noticed this performance hit that I couldn't understant:
using FunctionWrappers
fwrap=FunctionWrappers.FunctionWrapper{Float64,Tuple{Float64,Float64}}
Fvec=fwrap[(i,j)->0.5;(i,j)->i-i+0.5]
using BenchmarkTools
function foo1(r1,r2,Fvec)
Fvec[1].(r1,r2)
end
function foo2(r1,r2,Fvec)
Fvec[2].(r1,r2)
end
r1,r2=rand(10),rand(1,11)
@btime foo1($r1,r2,$Fvec)
@btime foo2($r1,$r2,$Fvec)
2.813 μs (221 allocations: 4.42 KiB)
671.712 ns (1 allocation: 1008 bytes)
As you can see the two functions are the same, the second one is made to look as if it is a function of its inputs and the performance is very different.
Is this a bug, or am I missing something?
Cheers!
Metadata
Metadata
Assignees
Labels
No labels