# Anonymous function as argument cant be optimized

**URL:** <https://discourse.julialang.org/t/anonymous-function-as-argument-cant-be-optimized/11814>\
**Category:** General Usage\
**Tags:** performance\
**Created:** [June 20, 2018, 9:50am UTC](https://discourse.julialang.org/t/anonymous-function-as-argument-cant-be-optimized/11814 "2018-06-20T09:50:45Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [June 20, 2018, 9:57am UTC](https://discourse.julialang.org/t/anonymous-function-as-argument-cant-be-optimized/11814/2 "2018-06-20T09:57:06Z")

</div>

Don’t benchmark in global scope

```julia
julia> f1(l) = algorithm_direct(l, x->x, (x, y) -> x == y )
f1 (generic function with 1 method)

julia> @btime f1($Λ)
  4.164 ns (0 allocations: 0 bytes)

julia> f2(l) = algorithm(l, x->x, (x, y) -> x == y )
f2 (generic function with 1 method)

julia> @btime f2($Λ)
  3.863 ns (0 allocations: 0 bytes)

```

---

_[View the full topic](https://discourse.julialang.org/t/anonymous-function-as-argument-cant-be-optimized/11814)._
