Re: [julia-users] Re: slow while loop

2014-03-28 Thread Stefan Karpinski
Both way of writing a while loop should be the same. If you're seeing a difference, something else is going on. I'm not able to reproduce this: function f1() j = k = 1 while k = 10^8 j += k 1 k += 1 end return j end function f2() j = k = 1 while true k = 10^8 || break

Re: [julia-users] Re: slow while loop

2014-03-28 Thread John Myles White
Yeah, that's true. I didn't read the IR carefully enough. Laszlo, are you on the latest Julia? I worry that it's hard to make comparisons if you're running an older version of Julia. -- John On Mar 28, 2014, at 8:18 AM, Stefan Karpinski ste...@karpinski.org wrote: Perhaps I should have said

Re: [julia-users] Re: slow while loop

2014-03-28 Thread Stefan Karpinski
Perhaps I should have said isomorphic – the only differences there are names. It's more obvious that the native code is the same – only the source line annotations are different at all. On Fri, Mar 28, 2014 at 11:16 AM, John Myles White johnmyleswh...@gmail.com wrote: On my system, the two

Re: [julia-users] Re: slow while loop

2014-03-28 Thread Stefan Karpinski
Either way, one thing is quite unfortunate about this code. The compilation process isn't able to figure out that 10^8 is a constant so it recomputes it on every loop iteration. We really need a way to annotate functions as being pure in the very specific sense that the compiler is free to

[julia-users] Re: slow while loop

2014-03-28 Thread Laszlo Hars
Thanks, John, for your replies. In my system your code gives reliable results, too, if we increase the loop limits to 10^9: julia mean(t1s ./ t2s) 11.924373323658703 This 12% makes a significant difference in my function of nested loops (could add up to a factor of 2 slow down). So, the

Re: [julia-users] Re: slow while loop

2014-03-28 Thread Laszlo Hars
Thank you guys. I couldn't imagine how many things could go wrong in a computation session, under Windows. I rebooted my PC, and now the benchmarks run 3 times faster (!), and I see no real differences in the cases, except in the global context. I agree that annotating pure functions could be

Re: [julia-users] Re: slow while loop

2014-03-28 Thread Ivar Nesje
You can use let scopes, but I'm not completely sure I understand how they work, but someone will correct me if this is wrong. let stat_var = [1:10] global f function f(a) return a*stat_var end end Ivar kl. 20:27:08 UTC+1 fredag 28. mars 2014 skrev Laszlo Hars følgende: