Skip to content

v0.5.0: Add `@timeit_debug` and friends for zero-overhead timings (#50)

Compare
Choose a tag to compare
@KristofferC KristofferC released this 05 Mar 22:39
· 69 commits to master since this release
* Add `@timeit_debug` and friends for zero-overhead timings

`@timeit_debug` is meant to be used to instrument your package with
zero-overhead; it is initially disabled, until it is turned on on a
`Module` basis by calling `TimerOutputs.enable_debug_timings(<module>)`,
which will trigger recompilation of all `@timeit_debug`-containing
methods within that `Module`.

Example usage:
```
using TimerOutputs
to = TimerOutput()

function foo()
   global to
   @timeit_debug to "sleepytime" println("hello")
   display(to)
   return nothing
end

@info "With debug timings disabled:"
TimerOutputs.disable_debug_timings(Main)
foo()

@info "With debug timings enabled:"
TimerOutputs.enable_debug_timings(Main)
foo()
```

* Fix `@timeit_debug` with function-style invocation

We need to put the conditional inside of the macro-generated function.
To do this, we work it into `timer_expr()`.

* Don't recompile unless we have to.

Not strictly necessary, but useful when interactively testing things
out, and you just run `enable_debug_timings(NNlib)` every time out of
force of habit.