How can I profile a multithread program in Python?

前端 未结 7 633
囚心锁ツ
囚心锁ツ 2020-11-30 04:12

I\'m developing an inherently multithreaded module in Python, and I\'d like to find out where it\'s spending its time. cProfile only seems to profile the main thread. Is the

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-30 04:53

    Instead of running one cProfile, you could run separate cProfile instance in each thread, then combine the stats. Stats.add() does this automatically.

提交回复
热议问题