problem with process time calculation
i'm writing a code to calculate cpu time consumed by a process. i've put the calculations inside a while loop which executes till cpu usage reaches a required value.
i'm using /proc/[pid]/stat (utime and stime field) to find process time. now since the while loop runs infinitely the usage reaches 100% quickly and i'm not able to verify the values. is there a way to make it gradual increase? also if i use sleep() in the loop the the process cpu times in /proc/[pid]/stat become zero please help!!! thanks |
There is a utility "time".
Quote:
Markus |
What is this "process" ?
Are you aware of time ? Code:
time ls -al |
if i use time command in my loop will it give real time cpu usage, since i need to check if a particular cpu% is reached.
or will it give the percentage only at the end. thanks |
All times are GMT -5. The time now is 07:00 AM. |