Sorry, I thought you were running those commands at the REPL, where "for i = 1:n; s += A[i]; end" is much slower than if you put that inside a function.
On Saturday, February 15, 2014 02:49:53 AM harven wrote: > Le samedi 15 février 2014 11:30:12 UTC+1, Tim Holy a écrit : > > You're running into the classic globals problem, see the performance tips > > section of the manual. > > I am sorry, I don't understand your remark. There are no global variables > in the code I posted previously. > Also, wrapping the code in a function does not get better performance. > Maybe I don't understand what is the classic globals problem? > > julia> > function test () ; > let biglist = [string(i) for i in 1:20000] , result = BigInt(1); > @time for x in biglist ; result = result * BigInt(x) ; end ; result > ; end > end > > julia> test (generic function with 1 method) > > julia> test() > elapsed time: 0.396508521 seconds (304614928 bytes allocated) > > > julia> test() > elapsed time: 0.393320767 seconds (304614928 bytes allocated)