对于c 如何获得一个进程及其子进程从开始到结束 它的最大CPU% MEM%使用率
|
再多说些:
用最普通的fopen, fread读取:
/proc/stat
可以获得整个系统使用的CPU切片数
/proc/ /stat
一个进程从某一时刻的CPU切片数 utime + stime, MEM%使用数量 (vsize)
utime %lu
The number of jiffies that this process has been scheduled in user mode.
stime %lu
The number of jiffies that this process has been scheduled in kernel mode.
vsize %lu
Virtual memory size in bytes.
rss %ld
Resident Set Size: number of pages the process has in real memory, minus 3 for adminis-
trative purposes. This is just the pages which count towards text, data, or stack
space. This does not include pages which have not been demand-loaded in, or which are
swapped out.
最后通过这些基本参数,自己用公式计算你想要的比值即可。