Overhead in running Julia from command-line

1.2k Views Asked by At

I recently discovered Julia and I have compiled it from source today and have been playing around with it since. I have this very simple script where I time the multiplication of two random matrices

julia_matmul.jl

N = 100
A = rand(N, N)
B = rand(N, N)
tic()
A*B
toc()

If I run this script twice from a Julia interactive session, then the second run is considerably faster than the first. However if I run the script twice from a terminal I only get the slowest result.

Here are my results:

$ julia julia_matmul.jl
elapsed time: 0.315129296 seconds
$ julia julia_matmul.jl
elapsed time: 0.307094268 seconds
$ julia -q
julia> include("julia_matmul.jl")
elapsed time: 0.306266193 seconds

julia> include("julia_matmul.jl")
elapsed time: 0.000700495 seconds

The overhead is about 0.3 seconds and although this is very small it can screw up the timings of short scripts. So my question is: where is this ~0.3 seconds overhead coming from and how can I get rid of it (especially when not using an interactive session)?

1

There are 1 best solutions below

0
On

Please see the [email protected] mailing list for questions like these. This one has been answered a few times (possibly also on StackOverflow), so check the archives first. It is also generally a much better way to get current, prompt answers to questions about Julia.

Yes, I just checked and it's the first related question:

Julia compiles the script everytime?