这是一个关于Python原生c文件_lsprof的问题。 如果 f 的执行被另一个线程中断,_lsprof.profile() 探查器如何计算多线程程序中函数 f 所花费的总时间?
例如:
def f():
linef1
第2行
线f3
def g():
线路1
行2
在执行时,f 和 g 不在同一个线程中:
linef1
第2行
线路1
linef3
行2
那么 f 的总运行时间将被视为执行操作所需的时间量:
linef1
第2行
线f3
或者是有效延迟时间:
linef1
第2行
线路1
线f3
在 _lsprof.profile() 的结果中?
最佳答案
引自documentation for setprofile :
The function is thread-specific, but there is no way for the profiler to know about context switches between threads, so it does not make sense to use this in the presence of multiple threads.
关于python - _lsprof.c 针对 python 多线程的探查器行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/443082/