Put a function around the code and everything works as expected: function perf()
nsamples = 1000000; x = linspace(0, 5, nsamples); y = zeros(nsamples); noise = zeros(nsamples); a = rand(); a = cos(0.0); a = 1.5*2.5; a = 1.5+2.5; println("\nBrutal-force loops, 100 times:") for m = 1:100 morenoise = rand(); for n = 1:nsamples noise[n] = rand(); y[n] = cos(2*x[n]+5) + noise[n] + morenoise; end end end @time(perf()) *Brutal-force loops, 100 times:* * 2.964993 seconds (151.75 k allocations: 21.837 MB, 0.68% gc time)* On Monday, July 11, 2016 at 8:57:05 AM UTC+2, Zhong Pan wrote: > > Hi, > > For work I really desired a language for numerical / data processing > that's as easy and capable as Python but still fast running loops. That's > why I am very excited when I noticed Julia. First allow me to me say, > fabulous work! I really appreciate the effort of those who make open-source > software great for everyone. > > I did a simple & naive benchmark involving brutal-force loops with some > floating-point calculations on Windows (have to use Windows for work). I > measured execution time in Python, Julia, VC++, C#.NET, Java, and Matlab. > To my surprise, Julia is not only much slower than VC++ in this test, but > it's much slower than C#.NET, Java, and even Matlab. > > Please see details of the test in the attached PDF file. Could someone > help me out here - did I make an amateur mistake or miss something? Was > Julia slow because of Windows? Or was it just the loops that's slow (as > this "benchmark" really didn't test anything else)? I really want to make > Julia my go-to language in work, so any suggestion is appreciated. > > Cheers. > -Zhong > > >