# Function control flow

**URL:** <https://discourse.julialang.org/t/function-control-flow/39837>\
**Category:** Performance\
**Tags:** question, performance\
**Created:** [May 20, 2020, 2:46pm UTC](https://discourse.julialang.org/t/function-control-flow/39837 "2020-05-20T14:46:12Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [May 31, 2020, 2:30pm UTC](https://discourse.julialang.org/t/function-control-flow/39837/21 "2020-05-31T14:30:14Z")

</div>

> [@Joao\_Barata](#):
>
> What do you think?

```julia
julia> @btime wage1($pp)
  0.017 ns (0 allocations: 0 bytes)
1.912

julia> @btime wage2($pr)
  0.017 ns (0 allocations: 0 bytes)
1.912

julia> @btime wage3(.956)
  0.017 ns (0 allocations: 0 bytes)
1.912

```

That the compiler defeated the benchmark.

---

<div class="post-metadata">

**Author:** ![Joao\_Barata](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joao_barata/32/10082_2.png) [@Joao\_Barata](https://discourse.julialang.org/u/Joao_Barata)\
**Post date:** [May 31, 2020, 2:37pm UTC](https://discourse.julialang.org/t/function-control-flow/39837/22 "2020-05-31T14:37:54Z")

</div>

Sorry, I’m a noob here. What does ‘compiler defeated the benchmark’ mean? What is the purpose of using ‘$’? Thanks

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [May 31, 2020, 2:59pm UTC](https://discourse.julialang.org/t/function-control-flow/39837/23 "2020-05-31T14:59:11Z")

</div>

> [@Joao\_Barata](#):
>
> Sorry, I’m a noob here. What does ‘compiler defeated the benchmark’ mean?

I recommend reading the [QuickStart](https://github.com/JuliaCI/BenchmarkTools.jl#quick-start) of BenchmarkTools.jl. It answers both questions.

If you use the `Ref` trick to get around it, `wage3` slows down as much as the others:

```julia
julia> @btime wage1($(Ref(pp))[])
  1.267 ns (0 allocations: 0 bytes)
1.912

julia> @btime wage2($(Ref(pr))[])
  1.269 ns (0 allocations: 0 bytes)
1.912

julia> @btime wage3($(Ref(.956))[])
  1.268 ns (0 allocations: 0 bytes)
1.912

```

[Previous page](https://discourse.julialang.org/t/function-control-flow/39837.md?page=1)
