# When the function is parallaxed, the speed drops

**URL:** <https://discourse.julialang.org/t/when-the-function-is-parallaxed-the-speed-drops/8282>\
**Category:** Julia at Scale\
**Created:** [January 11, 2018, 4:32am UTC](https://discourse.julialang.org/t/when-the-function-is-parallaxed-the-speed-drops/8282 "2018-01-11T04:32:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![1112](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1112/32/9325_2.png) [@1112](https://discourse.julialang.org/u/1112)\
**Post date:** [January 11, 2018, 4:32am UTC](https://discourse.julialang.org/t/when-the-function-is-parallaxed-the-speed-drops/8282/1 "2018-01-11T04:32:35Z")

</div>

How can I speed this code up?

```julia
function scalar_mult(k::BigInt)
....
end

function twofor(n)
    @sync @parallel for i in 1000:n for j in 10:115

                 scalar_mult(BigInt(j * ^(10,3)+i))

                 end
                 end
end

n = 9999

#compile
twofor(1020)
#run 
twofor(n)
423.467542 seconds (1.07 G allocations: 57.729 GiB, 14.20% gc time)

```

Will be very long,  
although the scalar\_mult function without a loop executes for 0.004 s

Architecture: x86\_64  
CPU op-mode(s): 32-bit, 64-bit  
Byte Order: Little Endian  
CPU(s): 2

---

<div class="post-metadata">

**Author:** ![1112](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1112/32/9325_2.png) [@1112](https://discourse.julialang.org/u/1112)\
**Post date:** [January 11, 2018, 10:39am UTC](https://discourse.julialang.org/t/when-the-function-is-parallaxed-the-speed-drops/8282/2 "2018-01-11T10:39:36Z")

</div>

help me 🙏

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 11, 2018, 10:51am UTC](https://discourse.julialang.org/t/when-the-function-is-parallaxed-the-speed-drops/8282/3 "2018-01-11T10:51:40Z")

</div>

Providing a self-contained MWE would help (we don’t know what `scalar_mult` may be).

Also, please use standard indentation.
