# Help in making the code faster and/or reducing allocations?

**URL:** <https://discourse.julialang.org/t/help-in-making-the-code-faster-and-or-reducing-allocations/36299>\
**Category:** General Usage\
**Created:** [March 21, 2020, 2:28pm UTC](https://discourse.julialang.org/t/help-in-making-the-code-faster-and-or-reducing-allocations/36299 "2020-03-21T14:28:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bashonubuntu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)\
**Post date:** [March 21, 2020, 2:28pm UTC](https://discourse.julialang.org/t/help-in-making-the-code-faster-and-or-reducing-allocations/36299/1 "2020-03-21T14:28:23Z")

</div>

Thank you for the replies! I have realized this won’t be productive due to the length of the code so I’m closing this. I believe I can’t delete the thread myself but have flagged it so that it can be deleted sometime in the future.

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [March 21, 2020, 5:27pm UTC](https://discourse.julialang.org/t/help-in-making-the-code-faster-and-or-reducing-allocations/36299/2 "2020-03-21T17:27:38Z")

</div>

Could one make a more minimial MWE? This is rather long.

One suggestion would be to run the profiler, find the few lines where all the time is spent and then just show those lines. Would that be helpful to those who try to reply?

For example, it’s hard to say whether you actually need `parameters` to be mutable due to the length of the example.

One detail: did you mean the type declarations to be, for example, `F :: Float64`? I’m asking because `Float64` is a concrete type (no subtypes).

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [March 21, 2020, 7:22pm UTC](https://discourse.julialang.org/t/help-in-making-the-code-faster-and-or-reducing-allocations/36299/4 "2020-03-21T19:22:08Z")

</div>

Your code is very hard to read. Could you at least point out what the hot spots are?

One thing that’s confusing is that you appear to use broadcasting everywhere, even when operating on scalars. That makes the code even harder to comprehend.

Maybe some more comments would help too.
