# Delay in processing

**URL:** <https://discourse.julialang.org/t/delay-in-processing/46853>\
**Category:** General Usage\
**Created:** [September 18, 2020, 3:24pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853 "2020-09-18T15:24:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjmoses](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rjmoses](https://discourse.julialang.org/u/rjmoses)\
**Post date:** [September 18, 2020, 3:24pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853/1 "2020-09-18T15:24:37Z")

</div>

I have a routine that has about a 3 second delay in it for some reason. Essentially, the code goes:

1. Do some initialization stuff, create three arrays of 1920 elements each (two Char, 1 structure) and initialize them to blanks and 0’s.
2. while true  
display some data,  
read some input  
if input is quit, exit, otherwise process input  
end

There is a significant (about 3 seconds) between the completion of the last initialization step and the first step inside the while. I have run a lot a test to try to isolate where the delay is occurring but haven’t found anything yet.

I use the library functions, libNCurses.jl to access ncurses and readdlm.jl, but these don’t seem to be the issue.

Anybody have a suggestion as to what might be going on? Could it be JIT processing?

Thanks

---

<div class="post-metadata">

**Author:** ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Post date:** [September 18, 2020, 3:31pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853/2 "2020-09-18T15:31:09Z")

</div>

Please

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

Is this all done in global scope or in a/multiple functions?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [September 18, 2020, 3:33pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853/3 "2020-09-18T15:33:07Z")

</div>

Can you do something like:

```julia
using BenchmarkTools
@benchmark YOUR_INITIALIZATION_STEP()

```

and give us the output, in case you can’t provide a MWE (see above PSA).

---

<div class="post-metadata">

**Author:** ![rjmoses](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rjmoses](https://discourse.julialang.org/u/rjmoses)\
**Post date:** [September 18, 2020, 3:42pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853/4 "2020-09-18T15:42:29Z")

</div>

There are two main modules with multiple functions in each. Variables, for the most part a local, with the arrays, globalized. The two modules total about 2800 lines.

---

<div class="post-metadata">

**Author:** ![rjmoses](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rjmoses](https://discourse.julialang.org/u/rjmoses)\
**Post date:** [September 18, 2020, 3:45pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853/5 "2020-09-18T15:45:11Z")

</div>

Thanks, I will check out BenchmarkTools.

I have tried stripping out initialization function calls to make an MWE and cannot see an change.

---

<div class="post-metadata">

**Author:** ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Post date:** [September 18, 2020, 3:47pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853/6 "2020-09-18T15:47:42Z")

</div>

Maybe also take a look at [profiling](https://docs.julialang.org/en/v1/manual/profile/). Maybe that can reveal where the delay happens

---

<div class="post-metadata">

**Author:** ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Post date:** [September 18, 2020, 3:49pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853/7 "2020-09-18T15:49:09Z")

</div>

Could you maybe strip out some dummy op for the last iteration and the first while iteration?

---

<div class="post-metadata">

**Author:** ![rjmoses](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@rjmoses](https://discourse.julialang.org/u/rjmoses)\
**Post date:** [September 18, 2020, 4:55pm UTC](https://discourse.julialang.org/t/delay-in-processing/46853/8 "2020-09-18T16:55:41Z")

</div>

I put a logging function immediately before and after the while statement. The logging function uses a named pipe to route message to another function that, in turn, display them on a console log. The named pipe is opened at the beginning of the program.

I have embedded logging calls at each of the initialization functions and they all display their embedded call messages immediately.

I am checking out profiling at the moment to see if I can get a clue.
