[Tutor] trace / profile function calls with inputs
Richard Cziva
r.cziva.1 at research.gla.ac.uk
Sat Feb 8 17:36:13 CET 2014
Hi All,
I am trying to print out every function that is being called while my
Python program is running (own functions and library calls too). I can
not modify the Python programs I am trying to profile.
Let me give an example. A program contains a function like this:
def foo(x):
y = math.cos(x)
z = 1 + 1
time.sleep(y+1)
return x * 50
And it calls the function:
print foo(100)
I would like to retrieve an execution trace that shows me each function
called with the value or hash of its arguments. According to the
example, I am looking for a technique to extract something similar:
foo(100)
math.cos(100)
time.sleep(0.87)
Things I have tried with only partial success:
- trace module
- profile module / cProfile
Could you suggest me a way of doing this?
Thanks,
Richard
More information about the Tutor
mailing list