Reputation: 143
Running a Julia file in REPL
julia> include("foo.jl")
julia> include("foo.jl")
gives different running time but it doesn't seem to be the case when I run it from the terminal
$ julia foo.jl
$ julia foo.jl
Is there a standard method for saving compiled files outside of Julia?
Upvotes: 1
Views: 585
Reputation: 12179
If you're re-running it to test changes to the underlying code, also consider using Revise.
Upvotes: 2
Reputation: 10984
There is a Julia package for running Julia as a daemon: https://github.com/dmolina/DaemonMode.jl which is worth checking out. Doesn't exactly answer the question about "how to save compiled Julia code" but it could probably improve the workflow you are after.
Upvotes: 0
Reputation: 136
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.
Upvotes: 4