# Help fo working with Iters

**URL:** <https://discourse.julialang.org/t/help-fo-working-with-iters/29727>\
**Category:** New to Julia\
**Created:** [October 10, 2019, 1:19pm UTC](https://discourse.julialang.org/t/help-fo-working-with-iters/29727 "2019-10-10T13:19:00Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [October 11, 2019, 1:09pm UTC](https://discourse.julialang.org/t/help-fo-working-with-iters/29727/21 "2019-10-11T13:09:08Z")

</div>

Those are both slower than the for loop by quite a bit, and the second one is much slower than the first.

```julia
julia> @btime initial_trend_for_loop(series, 12)
  24.727 ns (1 allocation: 16 bytes)
-0.7847222222222222

julia> @btime initial_trend_tkf1(series, 12)
  96.970 ns (5 allocations: 416 bytes)
-0.7847222222222222

julia> @btime initial_trend_tkf2(series, 12)
  778.307 ns (13 allocations: 480 bytes)
-0.7847222222222222

```

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [October 11, 2019, 11:44pm UTC](https://discourse.julialang.org/t/help-fo-working-with-iters/29727/22 "2019-10-11T23:44:24Z")

</div>

Ah, so it seems that `mapreduce` for multiple arrays is not as optimized as I hoped:

[https://github.com/JuliaLang/julia/blob/a68237f9c9805d492fc2d483bf63b8ecba647e8f/base/reducedim.jl#L307-L308](https://github.com/JuliaLang/julia/blob/a68237f9c9805d492fc2d483bf63b8ecba647e8f/base/reducedim.jl#L307-L308)

Fusing it would need something like [https://github.com/JuliaLang/julia/pull/31020](https://github.com/JuliaLang/julia/pull/31020)

[Previous page](https://discourse.julialang.org/t/help-fo-working-with-iters/29727.md?page=1)
