Dear all,
I am trying to implement some variable tracking types in a package colled DiffCheckNumbers.jl.
The main issue I’m facing now is the slowdown that is generated by the compilation of the constructors.
struct DiffCheck{T<:ReComp, S, N} <: Number
value::T
der::StaticTuple{T,S,N} # maybe not the fastest structure
function DiffCheck{T, S}(x::T, der::StaticTuple{T,S,N}) where {T<:ReComp, S, N}
return new{T,S,N}(x, der)
end
end
I would like to ran, at runtime, with a decent speed, the following code:
w = Array{DiffCheck{Float64, A, 1} where A,1}[DiffCheck(1.0, Symbol("x",i)) for i in 1:1000]
I would like to precompile the Constructors; so the first idea is to add, in the same file as the Constructors, inside a precompiled module
for i in 1:1000
a = Symbol("x",i)
DiffCheck{Float64, (a, )}(1.0, StaticTuple{Float64, (a, ), 1}(1.0, ))
end
But timing I do not see any performance gain. is there a specific way to precompile constructors (in case, using precompile())?
And parametric methods?
Thank you all