开发者

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

开发者 https://www.devze.com 2023-01-17 12:32 出处:网络
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

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 k开发者_开发问答cachegrind.

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消