# Function runs much slower from the Julia command prompt

**URL:** <https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305>\
**Category:** Performance\
**Created:** [August 30, 2018, 11:09am UTC](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305 "2018-08-30T11:09:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pythonuser](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@pythonuser](https://discourse.julialang.org/u/pythonuser)\
**Post date:** [August 30, 2018, 11:09am UTC](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305/1 "2018-08-30T11:09:29Z")

</div>

Ok, so I am a relatively new Julia user. I have a program which uses parallelism. When i run a test script to execute the function from the Juno editor, the function execution speed is good.  
However, when i run the same test script from the Julia prompt from Windows, the execution speed is orders of magnitude slower.  
This is my simple test code:

```julia
wIntercept = true
wInteract = true
crossValid = true
commonRun = true

Pl = 2
Pu = 1
Nparam=500

include("main.jl")
function main_variable(wIntercept, Interact, crossValid, CommonRan, Pl, Pu, Nparam)
    return main(wIntercept, Interact, crossValid, CommonRan, Pl, Pu, Nparam)
end

```

For reference, the function execution is completed in ~200 seconds from Juno. However, it takes around 7000 seconds from the prompt to finish.

---

<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:** [August 30, 2018, 12:15pm UTC](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305/2 "2018-08-30T12:15:28Z")

</div>

Without a self-contained minimum working example, it is very difficult to say what is going on.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [August 30, 2018, 1:28pm UTC](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305/3 "2018-08-30T13:28:02Z")

</div>

Juno runs your code with `-O3` and multithreaded by default, so maybe try that when running from the REPL.

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [August 30, 2018, 7:48pm UTC](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305/4 "2018-08-30T19:48:10Z")

</div>

What do you mean by _multithreaded by default_? Your code must use `@threads` for this to work, can you clarify on this, please?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [August 31, 2018, 7:54am UTC](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305/5 "2018-08-31T07:54:04Z")

</div>

What I meant is that Juno sets `ENV["JULIA_NUM_THREADS"]` to something sensible (number of cores, which isn’t necessarily the best heuristic but imho better than only ever using one thread) before starting Julia, which means that if you _can_ actually get a performance improvement from code using `Threads.@threads` internally.  
I have no idea if OP’s code is using threads, but it would explain the rather large performance difference.

---

<div class="post-metadata">

**Author:** ![pythonuser](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@pythonuser](https://discourse.julialang.org/u/pythonuser)\
**Post date:** [August 31, 2018, 12:06pm UTC](https://discourse.julialang.org/t/function-runs-much-slower-from-the-julia-command-prompt/14305/6 "2018-08-31T12:06:50Z")

</div>

Found the reason. I had turned off depreciation warnings in Juno sometime ago. I wasn’t running Julia repl with the depwarn no flag.
