python - _lsprof.c 针对 python 多线程的探查器行为

标签 python multithreading

这是一个关于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/

相关文章:

python - np.fft.ifft2 将图像完全变黑

python - 在 block 样式 yaml 文件 (ruamel.yaml) 中将来自 Python 的列表显示为流样式

python - python 3 中的可迭代对象和列表有什么区别?

python - 使用python misses服务浏览avahi服务

multithreading - 查找 subprocess.Popen python 的执行时间

Java 代理不会将任何内容发送回浏览器

Python SSL Socket 客户端认证

python - 是否可以在 wx.StaticText 上绑定(bind)点击事件?

multithreading - 使用线程复制主线程添加到字符串列表的文件

c - 二进制信号量保持并发