How can I use TimerOutputs.jl to time a function and its internal function calls in a package?

From the doc of the TimerOutputs.jl, it is not clear how to use it for timing a function and its internal function calls in my developing packages. Normally, I will create a new environment outside of my package and write a script, such as

using TimerOutputs
using MyPackage

const to = TimerOutput()
@timeit to "myfunc" MyPackage.myfunc()

However, this code can only report the time cost by myfunc. I also want to time all internal function calls inside myfunc. How can I do that? Shall I pass to as an argument for myfunc. Even worse, this approach will also introduce an extra dependency of TimerOutputs to MyPackage. Is there any less obtrusive way to do so?

Haven’t tried it myself, but looking at the linked docs it looks like you’d need to expand the macro on the nested calls to time them.

If it weren’t for the nested macros, this sounds like stacking the package in an environment with TimerOutputs or working in separate environment adding TimerOutputs and MyPackage. But maybe you’ll need to do this in a “test” subdirectory with TimerOutputs as a specific dependency.