# TimerOutputs.jl

**URL:** https://discourse.julialang.org/t/timeroutputs-jl/36313
**Category:** New to Julia
**Created:** [March 21, 2020, 7:45pm UTC](https://discourse.julialang.org/t/timeroutputs-jl/36313 "2020-03-21T19:45:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [March 21, 2020, 7:45pm UTC](https://discourse.julialang.org/t/timeroutputs-jl/36313/1 "2020-03-21T19:45:43Z")

</div>

I am trying to time a piece of code. Here is a MWE:

```julia
using TimerOutputs

function x()
    @timeit to "Timing" a = 3 + 4
end

x()

```

I get the error: “to” is not defined. What is my error? Thanks.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/3/a3907695027f9abdce1191820e3eea48de9c04cd.png)

---

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [March 21, 2020, 7:50pm UTC](https://discourse.julialang.org/t/timeroutputs-jl/36313/2 "2020-03-21T19:50:11Z")

</div>

Solved the problem. I am missing the line:

```julia
const to = TimerOutput();

```

which many examples online did not show.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 22, 2020, 11:53am UTC](https://discourse.julialang.org/t/timeroutputs-jl/36313/3 "2020-03-22T11:53:25Z")

</div>

> [@erlebach](#):
>
> which many examples online did not show.

All examples in the docs do show it, however:

> **[GitHub - KristofferC/TimerOutputs.jl: Formatted output of timed sections in...](https://github.com/KristofferC/TimerOutputs.jl)**
>
> Formatted output of timed sections in Julia. Contribute to KristofferC/TimerOutputs.jl development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)
#### Post date: [March 22, 2020, 1:01pm UTC](https://discourse.julialang.org/t/timeroutputs-jl/36313/4 "2020-03-22T13:01:44Z")

</div>

My apologies. My mind obviously filtered it out. In any case, I got it working and love it.
