# "Textbook" use of pmap but strange execution times

**URL:** <https://discourse.julialang.org/t/textbook-use-of-pmap-but-strange-execution-times/26852>\
**Category:** Julia at Scale\
**Tags:** question\
**Created:** [July 26, 2019, 4:15pm UTC](https://discourse.julialang.org/t/textbook-use-of-pmap-but-strange-execution-times/26852 "2019-07-26T16:15:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgiugliano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgiugliano/32/5818_2.png) [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Post date:** [July 26, 2019, 4:15pm UTC](https://discourse.julialang.org/t/textbook-use-of-pmap-but-strange-execution-times/26852/1 "2019-07-26T16:15:28Z")

</div>

I have 28 cores and 56 threads and I call julia with “-p auto”.  
When starting from a (non-parallel) example,

`@time for x in [10;ones(Int, 10)]`  
` sleep(x/10); println(x)`  
`end`

its execution time (~2s) makes perfect sense.

However, the execution time of the following (equivalent?) parallelized code does not:

`@time res = pmap(x -> (sleep(x/10); println(x)), [10;ones(Int, 10)]);`

In fact, this (reproducibly) takes 7 repeated (identical) executions, before converging to ~1 (i.e. 3.2s, 1.8s, 1.8s, 1.8s, 1.8s, 1.8, 1.1, 1.1,…).

I know Julia compiles functions upon first use (i.e. the 3.2s), but… why should I wait **seven** repeated executions, before getting the intended parallelization?
