julia> function test()
m=0.0
@time for i=1:1000000
r= rand()-.05
m=max(m,abs(r))
end; m
end
test (generic function with 1 method)
julia> test()
elapsed time: 0.004459659 seconds (0 bytes allocated)
0.9499997082184952
julia> begin
m=0.0
@time for i=1:1000000
r= rand()-.05
m=max(m,abs(r))
end; m
end
elapsed time: 0.040078291 seconds (32002568 bytes allocated)
0.9499986056323748
Are you sure?
On Thursday, January 15, 2015 at 3:14:36 PM UTC-5, Michael Wojnowicz wrote:
>
> The variables are both of the same type, and wrapping the code inside a
> function does not solve the problem.
>