Re: [julia-users] Why for loop slower than the vectorized operation?

2016-09-24 Thread Weicheng Zhu
OK, I see. Thank you very much! On Saturday, September 24, 2016 at 11:11:41 AM UTC-5, Spencer Russell wrote: > > Take a look at the performance tips in the manual: > http://docs.julialang.org/en/release-0.5/manual/performance-tips/ > > One of the main things is to avoid accessing global variables,

Re: [julia-users] Why for loop slower than the vectorized operation?

2016-09-24 Thread Weicheng Zhu
OK, I see. Thank you very much! On Saturday, September 24, 2016 at 11:11:41 AM UTC-5, Spencer Russell wrote: > > Take a look at the performance tips in the manual: > http://docs.julialang.org/en/release-0.5/manual/performance-tips/ > > One of the main things is to avoid accessing global variables,

Re: [julia-users] Why for loop slower than the vectorized operation?

2016-09-24 Thread Spencer Russell
Take a look at the performance tips in the manual: http://docs.julialang.org/en/release-0.5/manual/performance-tips/ One of the main things is to avoid accessing global variables, and everything declared at the top-level in the

[julia-users] Why for loop slower than the vectorized operation?

2016-09-24 Thread Weicheng Zhu
Hi there, Could anybody tell me what's wrong with my for loop code below and how to improve it? I was surprised to see it performs worse than the vectorized operation. Thank you! ## Calculate the maximum number in vector x that is less or equal to 0.5 > ## Method 1 > x=rand(1) > @time maximu