How can I profile a multithread program in Python?

前端 未结 7 634
囚心锁ツ
囚心锁ツ 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:56

    Check out mtprof from the Dask project:

    https://github.com/dask/mtprof

    It's a drop-in replacement for cProfile that, if your threads are launched in the usual way and complete before your main thread, will roll-up their stats into the same reporting stats. Worked like a charm for me.

提交回复
热议问题