I have a module consisting out of several files. In one file I define two
immutables and a union:
immutable GlobalRBF
eval::Function
end
immutable CompactRBF
eval::Function
end
const global RBF = Union(GlobalRBF, CompactRBF)
and I define several immutable objects of which one is:
const global rbf_cp2 = CompactRBF(x -> (1.0 - x)^4*(4.0*x + 1.0))
In another file I have a function in which the above univariate scalar
function is evaluated like this:
function myFunc(rbf::RBF)
# Some stuff
nested_for_loop
rbf.eval(r[i, j])
end
# Some stuff
end
If I then run my code and use @time to measure the performance I get the
following result:
elapsed time: 0.002800011 seconds (934720 bytes allocated)
However if I define the immutable object slightly differently like this:
f(x) = (1.0 - x)^4*(4.0*x + 1.0)
const global rbf_cp2 = CompactRBF(f)
then with @time I measure:
elapsed time: 0.001887599 seconds (606912 bytes allocated)
So, I would like to know what the big difference is between the two
implementations of the object that would cause such a difference in
performance?