How to write a custom tracer/profiler?
anthony.hw.kong at gmail.com
Tue Jul 15 04:48:20 CEST 2008
Just wanna look for some suggestions on how to appoarch this
I have some code ("main logic") which has a dependency on a library.
Let's call it DS. ("data source").
The main logic will issue a number of calls to the DS in order to get
the data it needs and then carry out some calculations.
I want to have a non-intrusive way to find out all the DS data
requested by the main logic.
One thing to note, the DS is a big, messy bit of code. So putting
logger everywhere within DS and main logic is not a reliably,
I have thought about using somehting like aspect. But seems to me
there is no mature, widely-used aspect lib out there.
Another idea is: let's roll a custom tracer/profiler. Whenever any
method/attributes in the DS package are called, the return values will
I have taken a quick look at profile.py in python 2.4, It seems sys
module will pass a frames to the profile class. Can I access the
return value of a function via these frame objects?
More information about the Python-list