Python multiprocess profiling

后端 未结 2 1959
自闭症患者
自闭症患者 2020-12-05 12:47

I\'m struggling to figure out how to profile a simple multiprocess python script

import multiprocessing
import cProfile
import time
def worker(num):
    time.         


        
2条回答
  •  孤城傲影
    2020-12-05 13:24

    You're profiling the process startup, which is why you're only seeing what happens in p.start() as you say—and p.start() returns once the subprocess is kicked off. You need to profile inside the worker method, which will get called in the subprocesses.

提交回复
热议问题