Conditionally suppress output of @time

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

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:

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.

@conditional_time (log_level > k) my_function(my_args...)
1 Like

@debug might be what you want.