# First post - what am I doing wrong - distributed benchmark show no improvement

**URL:** <https://discourse.julialang.org/t/first-post-what-am-i-doing-wrong-distributed-benchmark-show-no-improvement/68567>\
**Category:** New to Julia\
**Tags:** question, benchmark, distributed\
**Created:** [September 22, 2021, 4:48am UTC](https://discourse.julialang.org/t/first-post-what-am-i-doing-wrong-distributed-benchmark-show-no-improvement/68567 "2021-09-22T04:48:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Behemot](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@Behemot](https://discourse.julialang.org/u/Behemot)\
**Post date:** [September 22, 2021, 4:48am UTC](https://discourse.julialang.org/t/first-post-what-am-i-doing-wrong-distributed-benchmark-show-no-improvement/68567/1 "2021-09-22T04:48:55Z")

</div>

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
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

```

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [September 22, 2021, 4:55am UTC](https://discourse.julialang.org/t/first-post-what-am-i-doing-wrong-distributed-benchmark-show-no-improvement/68567/2 "2021-09-22T04:55:54Z")

</div>

Hello and welcome!

I think you fail to see any speedup here because the computation is too simple. There is an overhead associated with both threading and distributed computing, the latter typically higher than the former. Unless the computation performed in each of the loop iteration is large, the overhead of distributing the computation might make it slower overall.

For lower-overhead threading, you may have a look at [https://github.com/JuliaSIMD/Polyester.jl](https://github.com/JuliaSIMD/Polyester.jl)

---

<div class="post-metadata">

**Author:** ![Behemot](https://avatars.discourse-cdn.com/v4/letter/b/439d5e/32.png) [@Behemot](https://discourse.julialang.org/u/Behemot)\
**Post date:** [September 22, 2021, 5:08am UTC](https://discourse.julialang.org/t/first-post-what-am-i-doing-wrong-distributed-benchmark-show-no-improvement/68567/3 "2021-09-22T05:08:01Z")

</div>

Thank you - that (overhead) certainly makes sense. Thank you for the link!
