Skip to content Skip to sidebar Skip to footer

How Can I "hook Into" Python From C++ When It Executes A Function? My Goal Is To Profile

I'm implementing a profiler in an application and I'm a little flummoxed about how to implement Python profiling such that the results can be displayed in my existing tool. The app

Solution 1:

Well not sure what your goal is, but I'd personally not start from zero but use the existing modules for profiling. The cprofile module was written in C and should be easily extensible if the documentation is to be believed: http://docs.python.org/release/3.2/library/profile.html#extensions-deriving-better-profilers

Solution 2:

The usual technique for profiling already-existing functions that we use in Lua a lot is to overwrite the function with your own version that will start timing, call the original function, and stop timing, returning the value that the original function returned.

Post a Comment for "How Can I "hook Into" Python From C++ When It Executes A Function? My Goal Is To Profile"