# Compilation-ignoring timer?

**URL:** https://discourse.julialang.org/t/compilation-ignoring-timer/93512
**Category:** Internals & Design
**Created:** [January 25, 2023, 3:01pm UTC](https://discourse.julialang.org/t/compilation-ignoring-timer/93512 "2023-01-25T15:01:18Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)
#### Post date: [January 25, 2023, 3:01pm UTC](https://discourse.julialang.org/t/compilation-ignoring-timer/93512/1 "2023-01-25T15:01:18Z")

</div>

Does Julia have, or would it be possible to add, a compilation-ignoring timer?

Use case: setting a time limit for running a function, as is common for optimizers. The first execution will be necessarily longer than the later executions due to compilation, but you may want to set a time limit that’s a lot shorter than that first execution.

A workaround is to ensure it is compiled prior to optimization, but that’s a bit annoying to remember to do each time.

A bit easier would be if packages that need to track time could do so in a way that tries to ignores compilation time. And for that, you’d need a timer that can be informed that Julia is currently compiling.

---

<div class="post-metadata">

### Author: ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)
#### Post date: [February 3, 2023, 12:25am UTC](https://discourse.julialang.org/t/compilation-ignoring-timer/93512/2 "2023-02-03T00:25:23Z")

</div>

I’m guessing this isn’t implemented because it wouldn’t be as useful as it seems: even if you don’t count the compilation time towards the measured time, the compilation would still interfere with the performance so the resulting timings wouldn’t be completely relevant.

EDIT: On the other hand, it’s weird that we have `@timev` which tells us how much of the total elapsed time was spent compiling, but `@timed` doesn’t give us that data.

---

<div class="post-metadata">

### Author: ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)
#### Post date: [February 3, 2023, 12:45am UTC](https://discourse.julialang.org/t/compilation-ignoring-timer/93512/3 "2023-02-03T00:45:50Z")

</div>

> [@BioTurboNick](#):
>
> Does Julia have, or would it be possible to add, a compilation-ignoring timer?

[GitHub - JuliaCI/BenchmarkTools.jl: A benchmarking framework for the Julia language](https://github.com/JuliaCI/BenchmarkTools.jl) is the defacto standard package for this.

---

<div class="post-metadata">

### Author: ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)
#### Post date: [February 3, 2023, 1:32am UTC](https://discourse.julialang.org/t/compilation-ignoring-timer/93512/4 "2023-02-03T01:32:35Z")

</div>

This package is for interactive benchmarking, which is not what I’m asking for. All it does to “ignore compilation” is to pre-run the method.

---

<div class="post-metadata">

### Author: ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)
#### Post date: [February 3, 2023, 1:37am UTC](https://discourse.julialang.org/t/compilation-ignoring-timer/93512/5 "2023-02-03T01:37:54Z")

</div>

To the first, I don’t think an imperfect adjustment is bad. If more could be done to account for other first-run delays, that would be great.
