I am relatively new in Julia, so maybe I am missing something trivial.
I created a file containing a function, using the Symbolics package
_, f = build_function(F, x)
write("function.jl", string(f))
myf = include("function.jl")
where F
is a symbolic polynomial vector-valued function, and x
is a symbolic vector.
When I try to call myf
for the first time, Julia takes a lot of time (up to 1h) to give a result. On the other hand, from the second call on, myf
only takes some nanoseconds. The same gigantic runtime is needed if I use precompile
. So, I think it is the compiler requiring a lot of time to compile myf
.
Do you have any clue why this happens? And, in case, how can I mitigate it?
PS: Below, you can find a bit of function.jl
, to give an idea of what is inside it
function (ËŤâ‚‹out, ËŤâ‚‹arg1)
begin
begin
@inbounds begin
ËŤâ‚‹out[1] = 1.0
[...]
ËŤâ‚‹out[48] = ËŤâ‚‹arg1[47]
ËŤâ‚‹out[49] = (+)(-0.7071067811865475, (*)(0.7071067811865475, (^)(ËŤâ‚‹arg1[1], 2)))
ËŤâ‚‹out[50] = (*)(ËŤâ‚‹arg1[1], ËŤâ‚‹arg1[2])
ËŤâ‚‹out[51] = (*)(ËŤâ‚‹arg1[1], ËŤâ‚‹arg1[3])
[...]
ËŤâ‚‹out[74308] = (*)((*)((*)(ËŤâ‚‹arg1[36], ËŤâ‚‹arg1[4]), ËŤâ‚‹arg1[47]), ËŤâ‚‹arg1[6])
ËŤâ‚‹out[74309] = (*)((*)((+)(-0.7071067811865475, (*)(0.7071067811865475, (^)(ËŤâ‚‹arg1[37], 2))), ËŤâ‚‹arg1[4]), ËŤâ‚‹arg1[6])
ËŤâ‚‹out[74310] = (*)((*)((*)(ËŤâ‚‹arg1[37], ËŤâ‚‹arg1[38]), ËŤâ‚‹arg1[4]), ËŤâ‚‹arg1[6])
[...]
nothing
end
end
end
end