N
Nikolaus Rath
Hello,
I am trying to profile a Python program that primarily calls a C
extension. From within the C extension, a callback Python function is
then called concurrently in several threads.
When I tried to profile this application with
import c_extension
def callback_fn(args):
# Do all sorts of complicated, time consuming stuff
pass
def main():
c_extension.call_me_back(callback_fn, some_random_args)
cProfile.run('main', 'profile.dat')
I only got results for main(), but no information at all about
callback_fn.
What is the proper way to profile such an application?
I already thought about this:
import c_extension
def callback_fn(args):
# Do all sorts of complicated, time consuming stuff
pass
def callback_wrapper(args):
def doit():
callback_fn(args)
cProfile.run('doit', 'profile.dat')
c_extension.call_me_back(callback_wrapper, some_random_args)
but that probably overwrites the profiling information whenever
callback_wrapper is called, instead of accumulating them over several
calls (with different arguments).
Best,
-Nikolaus
I am trying to profile a Python program that primarily calls a C
extension. From within the C extension, a callback Python function is
then called concurrently in several threads.
When I tried to profile this application with
import c_extension
def callback_fn(args):
# Do all sorts of complicated, time consuming stuff
pass
def main():
c_extension.call_me_back(callback_fn, some_random_args)
cProfile.run('main', 'profile.dat')
I only got results for main(), but no information at all about
callback_fn.
What is the proper way to profile such an application?
I already thought about this:
import c_extension
def callback_fn(args):
# Do all sorts of complicated, time consuming stuff
pass
def callback_wrapper(args):
def doit():
callback_fn(args)
cProfile.run('doit', 'profile.dat')
c_extension.call_me_back(callback_wrapper, some_random_args)
but that probably overwrites the profiling information whenever
callback_wrapper is called, instead of accumulating them over several
calls (with different arguments).
Best,
-Nikolaus