# \`@btime 5+2\`

**URL:** <https://discourse.julialang.org/t/btime-5-2/13402>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 13, 2018, 8:23pm UTC](https://discourse.julialang.org/t/btime-5-2/13402 "2018-08-13T20:23:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [August 13, 2018, 8:23pm UTC](https://discourse.julialang.org/t/btime-5-2/13402/1 "2018-08-13T20:23:37Z")

</div>

`@btime 5+2` reports a 100x speed up in Julia 1.0 vs. Julia 0.6.4. This is too good to be true. Perhaps constant propagation is affecting the result.

Am I misusing `@btime` here? What would be the correct way to measure the time for integer addition?

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [August 13, 2018, 8:26pm UTC](https://discourse.julialang.org/t/btime-5-2/13402/2 "2018-08-13T20:26:09Z")

</div>

```julia
julia> @btime x + y setup = (x = rand(Int); y = rand(Int));
  1.448 ns (0 allocations: 0 bytes)

```

`@btime 5 + 2` just gets constant-folded.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [August 13, 2018, 8:50pm UTC](https://discourse.julialang.org/t/btime-5-2/13402/3 "2018-08-13T20:50:08Z")

</div>

Note that for something as cheap as this, there’s basically no way to benchmark it correctly. There are properties of the instructions that could be measured (not with `BenchmarkTools`) but none of those properties will give you the correct time a program will take to run if you just add them together.

The number you get from the “correct” `@btime` is all overhead. Assuming this is not an ancient processor, the add should be at least 5-20x faster than that.
