I think If you include the entire script you effectively re-define the function which needs to be compiled again (although not the functions that are called from other packages, see this thread). If you want accurate timings, @btime
is good, in this case it probably is sufficient to simply call the function two times in the script and only time the second call.
If the compilation time actually matters, you probably should change your workflow by using Revise.jl. For instance, you can have a script that contains the function definitions and another one which runs the calculation and includes the former as includet("FunctionDefinitions.jl")
(Or, perhaps even better, make a package, which is actually not difficult in julia).
Revise will make sure that your function definitions stay up to date while only recompiling when it is necessary.