Basically I want to find out, on a given function call how much time was spent within a particular module, including subcalls to functions in other modules as well. Any suggestion on how to achieve such a thing?
For example:
# foo.py
import bar
@time(bar)
def foo():
...
bar.qux()
...
bar.foobar()
# bar.py
import foofoo
import barbar
def qux():
...
foofoo.foo()
...
def foobar():
...
barbar.bar()
...
Call to foo
in foo.py
should return the total time spent inside the bar
module(bar.py
), which in the above case should include time spent inside barbar
and foofoo
.