Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python cProfile: how to filter out specific calls from the profiling data?

I've started profiling a script which has many sleep(n) statements. All in all, I get over 99% of the run time spent sleeping. Nevertheless, it occasionally runs into performance problems during the time that it does real work but the relevant, interesting profiling data becomes very difficult to identify when e.g. using kcachegrind.

Is there a way I can blacklist certain calls/functions from being profiled? Alternatively, how can I filter out such call with post-processing of the profiling data file?

I'm using the profilestats decorator ( http://pypi.python.org/pypi/profilestats ).

Thanks

like image 369
GJ. Avatar asked Sep 21 '10 15:09

GJ.


1 Answers

You need more than just excluding samples during sleep(). You need the remaining samples to tell you something useful. That would be stack sampling, on wall-clock time, summarizing percent at the line-of-code level. Zoom is a good tool for this kind of sampling, and I would hope it's not too hard to ignore samples that contain a particular function.

like image 167
Mike Dunlavey Avatar answered Sep 16 '22 23:09

Mike Dunlavey