# Recursive inner functions a thousand times slower?

**URL:** <https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604>\
**Category:** Performance\
**Created:** [August 11, 2022, 4:43am UTC](https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604 "2022-08-11T04:43:21Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [August 19, 2022, 7:21am UTC](https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604/7 "2022-08-19T07:21:42Z")

</div>

[Another thread](https://discourse.julialang.org/t/extra-allocation-with-t-datatype/85930/19) made me remember this and consider if `@btime` is the problem here, but unlike that example, `@time`ing a loop actually corroborates the 3-4x difference in `@btime`, not the matching `@code_native`/`@code_llvm`:

```julia
julia> @time for i in 1:10_000
        f(i÷i*100) # prevent constant hoisting
       end
  0.181906 seconds (20.00 k allocations: 312.500 KiB)

julia> @time for i in 1:10_000
        f2(i÷i*100) # prevent constant hoisting
       end
  0.056144 seconds (20.00 k allocations: 312.500 KiB)

julia> 0.181906/0.056144
3.239990025648333

```

---

_[View the full topic](https://discourse.julialang.org/t/recursive-inner-functions-a-thousand-times-slower/85604)._
