如何获得每个进程的准确CPU使用率以及进程空闲CPU时间 [英] How to get the accurate CPU Usage per process and process Idle CPU Time

查看:236
本文介绍了如何获得每个进程的准确CPU使用率以及进程空闲CPU时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力获取每个进程的准确CPU使用率以及进程空闲CPU时间. 我尝试了"top"命令proc/[pid]/stat文件夹,但仍然尝试自己的运气.

I'hv been struggling to get the accurate CPU Usage per process and process Idle CPU Time.. I tried " top " command proc/[pid]/stat folder but still trying my luck..

TOP命令为在fg(foreground)和bg(background)中运行的所有进程提供CPU使用率 但是我感觉不太准确..因为即使进程在后台运行,它也会显示%CPU 0.请帮助

TOP command gives CPU usage for all the processes running in fg(foreground) and bg(background) but it is not as accurate i feel.. because it shows %CPU 0, even if the process is running in the background.. Any other way? please help

推荐答案

我已经找到了一种自己做的方法. 我正在使用

I have found a way to do it myself.. I am using

  1. proc/[pid]/stat->用于每个进程的CPU使用情况第14和15个参数
  2. proc/stat->用于同时处理所有进程的CPU消耗

这篇关于如何获得每个进程的准确CPU使用率以及进程空闲CPU时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆