That is a great tip, thanks.
I am having similar issues. I had the program in a file and run it with
include("prog.jl") at the julia prompt. It used to take 12 seconds per
10000 loops. Now Putting it into a function and also changed some
variables to const, I got it down to 3 seconds per 10000 loops. Big
improvement, but not as big as 70 -> 1.5. Perhaps due to file IO in
some of the loops?
On 04/27/2014 02:07 PM, Elliot Saba wrote:
Hey there Freddy. The first thing you can do to speed up your code is
to throw it inside of a function. Simply replacing your first line
(which is "begin") with "function domytest()" speeds up your code
significantly. I get a runtime of about 1.5 seconds from running the
function versus ~70 seconds from running the original code.
I believe the reason behind this is because outside of a function, all
of these variables are treated as global variables, which cannot have
the same assumptions of type-stability that local variables can have,
which slows down computation significantly. See this page
<http://julia.readthedocs.org/en/latest/manual/performance-tips/> for
more info, and other performance tips.
-E