rog*_*rog 60 python multithreading profiling
我正在使用Python开发一个固有的多线程模块,我想知道它在哪里花费时间.cProfile似乎只是描述主线程.有没有办法分析计算中涉及的所有线程?
var*_*tec 19
cProfile您可以cProfile在每个线程中运行单独的实例,然后组合统计信息,而不是运行一个.Stats.add()自动执行此操作.
如果您可以做一些额外的工作,可以编写自己的实现类的概要分析类profile(self, frame, event, arg)。每当调用函数时都会调用该方法,您可以相当容易地设置一个结构以从中收集统计信息。
然后,您可以threading.setprofile用来在每个线程上注册该功能。调用该函数时,您可以threading.currentThread()用来查看它正在运行。更多信息(和现成的配方)在这里:
http://code.activestate.com/recipes/465831/
http://docs.python.org/library/threading.html#threading.setprofile
| 归档时间: |
|
| 查看次数: |
18901 次 |
| 最近记录: |