Howdy - this is my first foray into Julia so I started with Gary Feierbach “Learning Julia 1.0” O’Reilly video. I am on Julia 1.5 (installed a while ago but never started). And on Win10 machine.
After first lecture I wanted to time some code and it seems that Distributed does not seem to work - what am I doing wrong? Code is below:
julia> using Distributed
julia> function head_count_parallel(count)
heads = @distributed (+) for i=1:count
Int(floor(rand()+0.5))
end
return heads
end
head_count_parallel (generic function with 1 method)
julia> function head_count(count)
heads = 0
for i=1:count
heads += Int(floor(rand()+0.5))
end
return heads
end
head_count (generic function with 1 method)
julia> using BenchmarkTools
julia> @btime head_count(200000000)
826.122 ms (0 allocations: 0 bytes)
100015574
julia> @btime head_count_parallel(200000000)
831.377 ms (29 allocations: 1.84 KiB)
99991249