# \`@time\` output is a tiny bit noisy

**URL:** https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113
**Category:** General Usage
**Created:** [January 17, 2023, 9:07pm UTC](https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113 "2023-01-17T21:07:25Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 17, 2023, 9:07pm UTC](https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113/1 "2023-01-17T21:07:25Z")

</div>

Quick question, is there a mini-package that defines something like the following:

```julia
using Printf

macro time′(ex)
    # prime time
    # (saner name, e.g: htime, for 'human' time)
    quote
        t0 = time()
        $(esc(ex))
        Δt = time() - t0
        @printf("%.2G seconds\n", Δt)
    end
end

```

Most of the times that I use `@time` I don’t have to know about memory allocations or more than 2 significant digits of time duration.

I wager I’m not alone?  
Given that, I wondered if it would be an idea to add something like this to Base. An anti-`@timev` (time verbose)  
Has there been previous discussion on this that I’ve missed?

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 17, 2023, 9:15pm UTC](https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113/2 "2023-01-17T21:15:58Z")

</div>

To explain a bit further: quick-n-dirty analyses I write often consist of multiple steps, and I print feedback between these steps on what is happening and how long the last step took

Goals are to know: is it computing, or is it hanging / did it crash? At what step are we know? How long did that take?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [January 17, 2023, 9:16pm UTC](https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113/3 "2023-01-17T21:16:29Z")

</div>

> **[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.

> **[GitHub - JuliaCI/BenchmarkTools.jl: A benchmarking framework for the Julia...](https://github.com/JuliaCI/BenchmarkTools.jl)**
>
> A benchmarking framework for the Julia language. Contribute to JuliaCI/BenchmarkTools.jl development by creating an account on GitHub.

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [January 17, 2023, 9:18pm UTC](https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113/4 "2023-01-17T21:18:55Z")

</div>

Thanks! `@btime` is just as noisy, and possible repeats work, right?  
I’d seen `TimerOutputs.jl` but it looked a bit overkill for quick scripts; but I’ll give it a try, it might be exactly what I need

Edit: No, my impression was right. It doesn’t seem to give live feedback during the running of the expression, and takes more code than `@time`  
Looks like a great package but not what I was looking for

* * *

I’ve gotten a lot of mileage out of [GitHub - timholy/ProgressMeter.jl: Progress meter for long-running computations](https://github.com/timholy/ProgressMeter.jl) though for similar use cases

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [January 17, 2023, 10:08pm UTC](https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113/5 "2023-01-17T22:08:22Z")

</div>

```julia
julia> @timed(sin(1.0)).time
7.0e-8

```

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [January 17, 2023, 10:12pm UTC](https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113/6 "2023-01-17T22:12:52Z")

</div>

Doesn’t `@ellapsed` does that (except for the units)?

---

<div class="post-metadata">

### Author: ![StevenWhitaker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevenwhitaker/32/9749_2.png) [@StevenWhitaker](https://discourse.julialang.org/u/StevenWhitaker)
#### Post date: [January 19, 2023, 12:03am UTC](https://discourse.julialang.org/t/time-output-is-a-tiny-bit-noisy/93113/7 "2023-01-19T00:03:00Z")

</div>

`@elapsed` doesn’t print any output, though, which seems to be the point of the question. The nice thing about `@time` is that it times, prints the timing information, and doesn’t change the returned value (i.e., `@time 1 + 1` will return `2`, whereas `@elapsed 1 + 1` will return the duration of the operation), all with minimal typing.
