Normally Julia compiles functions the first time they're used within a given Julia instance, so each time you call julia foo.jl
from the command line it will need to re-compile whatever code is called in foo.jl
.
If you want to store a compiled version of foo.jl
, you can use the PackageCompiler
package (https://github.com/JuliaLang/PackageCompiler.jl) which will replace your original Julia binary (where the code in foo.jl
has not been compiled) with a new one where foo.jl
has been compiled.
Note that you probably don't want to do this if you're actively developing foo.jl
as it takes some time to make each new Julia sysimage. If that's the case, you can just create a small script that loads all the packages and calls the same functions you want to call. Once that sysimage is compiled you should be able to import the same packages and use the same functions with no additional compilation time.