# What is the correct procedure to calculate ONLY the execution time of code not its embedded compilation time?

**URL:** https://discourse.julialang.org/t/what-is-the-correct-procedure-to-calculate-only-the-execution-time-of-code-not-its-embedded-compilation-time/75678
**Category:** General Usage
**Tags:** question, benchmarktools
**Created:** [February 2, 2022, 6:30pm UTC](https://discourse.julialang.org/t/what-is-the-correct-procedure-to-calculate-only-the-execution-time-of-code-not-its-embedded-compilation-time/75678 "2022-02-02T18:30:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)
#### Post date: [February 2, 2022, 6:30pm UTC](https://discourse.julialang.org/t/what-is-the-correct-procedure-to-calculate-only-the-execution-time-of-code-not-its-embedded-compilation-time/75678/1 "2022-02-02T18:30:17Z")

</div>

As far as I know that, using `@time` calculates the total time (compilation and execution). However, if I only need to calculate the execution time, what is the correct way to do that?

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [February 2, 2022, 6:41pm UTC](https://discourse.julialang.org/t/what-is-the-correct-procedure-to-calculate-only-the-execution-time-of-code-not-its-embedded-compilation-time/75678/2 "2022-02-02T18:41:04Z")

</div>

Call the function with the same arguments before in the same session.

---

<div class="post-metadata">

### Author: ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)
#### Post date: [February 2, 2022, 6:48pm UTC](https://discourse.julialang.org/t/what-is-the-correct-procedure-to-calculate-only-the-execution-time-of-code-not-its-embedded-compilation-time/75678/3 "2022-02-02T18:48:15Z")

</div>

Thanks for your reply. So, there is no command in Julia instead?

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [February 2, 2022, 6:49pm UTC](https://discourse.julialang.org/t/what-is-the-correct-procedure-to-calculate-only-the-execution-time-of-code-not-its-embedded-compilation-time/75678/4 "2022-02-02T18:49:40Z")

</div>

`using BenchmarkTools; @btime`?

---

<div class="post-metadata">

### Author: ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)
#### Post date: [February 2, 2022, 8:55pm UTC](https://discourse.julialang.org/t/what-is-the-correct-procedure-to-calculate-only-the-execution-time-of-code-not-its-embedded-compilation-time/75678/5 "2022-02-02T20:55:27Z")

</div>

The official reference is [this section of Performance tips in the manual](https://docs.julialang.org/en/v1/manual/performance-tips/#Measure-performance-with-%5B@time%5D(@ref)-and-pay-attention-to-memory-allocation) for the record, although the information there has been presented here already.
