gpt4 book ai didi

python - 在 Windows 上测量每个线程的 CPU 时间

转载 作者:可可西里 更新时间:2023-11-01 10:29:54 26 4
gpt4 key购买 nike

我正在为 Windows 开发一个长时间运行的多线程 Python 应用程序,我希望进程知道它的每个线程所占用的 CPU 时间。我可以用 os.times() 得到整个过程的总时间但我需要知道每个线程的时间。

我知道有外部工具,例如 Sysinternals Process Explorer,但我的程序本身需要有这些信息。如果我在 Linux 上,我会查看 /proc 文件系统,as described here .如果我正在编写 C 代码,我会使用 GetThreadTimes 调用,as described here .

那么我如何使用 Python 在 Windows 上完成此操作?

最佳答案

win32process.GetThreadTimes

你想要 Python for Windows Extensions做毛茸茸的 window 事情。

关于python - 在 Windows 上测量每个线程的 CPU 时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2929661/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com