# How to improve performance in nested loops

**URL:** <https://discourse.julialang.org/t/how-to-improve-performance-in-nested-loops/70407>\
**Category:** Performance\
**Tags:** question, performance\
**Created:** [October 26, 2021, 2:14pm UTC](https://discourse.julialang.org/t/how-to-improve-performance-in-nested-loops/70407 "2021-10-26T14:14:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 26, 2021, 2:36pm UTC](https://discourse.julialang.org/t/how-to-improve-performance-in-nested-loops/70407/2 "2021-10-26T14:36:49Z")

</div>

> [@claudio20497](#):
>
> `sum(arr[i:i+5])`

use a view here: `sum(@view(arr[i:i+r]))`.

try to remove all allocations which are not completely on purpose.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-improve-performance-in-nested-loops/70407)._
