Overhead between calling a function and running the first line its code

There are several cases:

  1. You are doing interactive exploration. Solution: use an interactive environment (the REPL, a Jupyter notebook, vsCode, Pluto, …) in which you leave Julia running. (For larger-scale code development, do this in conjunction with Revise.jl by creating a package. See Best practise: organising code in Julia - #2 by stevengj)
  2. Your function main() is extremely fast, but you are calling it lots of times. Solution: write your loop in Julia — don’t write a shell script or something. (If you are doing benchmarking, use BenchmarkTools.jl.)
  3. Your function main() takes a long time (minutes, hours, …). Solution: use separate Julia runs if you want. The compile time will be irrelevant.
2 Likes