# Conditionally suppress output of @time

**URL:** <https://discourse.julialang.org/t/conditionally-suppress-output-of-time/45851>\
**Category:** Performance\
**Tags:** question\
**Created:** [August 31, 2020, 5:47pm UTC](https://discourse.julialang.org/t/conditionally-suppress-output-of-time/45851 "2020-08-31T17:47:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [August 31, 2020, 5:47pm UTC](https://discourse.julialang.org/t/conditionally-suppress-output-of-time/45851/1 "2020-08-31T17:47:10Z")

</div>

Is there a parameterized version of @time where I can suppress output unless e.g. ‘`log_level > k`’ ?

I would like to make the performance of a sequence of function calls debuggable with minimal repetition of code

---

<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:** [August 31, 2020, 7:39pm UTC](https://discourse.julialang.org/t/conditionally-suppress-output-of-time/45851/2 "2020-08-31T19:39:11Z")

</div>

I am not sure. However, not that there is a `@timed` that outputs nothing but returns the values used to build the output message. You can create a function that takes a Bool, a function name, and the return from `@timed` to conditionally build and output a similar string. So you can call:

```julia
conditional_time(log_level > k, "my_function", @timed my_function(my_args...))

```

If you wanna reduce the repetition of code to a minimal you can use a macro to get the function name without repeating it.

```julia
@conditional_time (log_level > k) my_function(my_args...)

```

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [August 31, 2020, 7:39pm UTC](https://discourse.julialang.org/t/conditionally-suppress-output-of-time/45851/3 "2020-08-31T19:39:49Z")

</div>

`@debug` might be what you want.
