Linked Questions
24 questions linked to/from How do I get the total CPU usage of an application from /proc/pid/stat?
1 vote
2 answers
2k views
bash script for memory and cpu usage [duplicate]
I need to write script which returns file with information about cpu and memory usage of specified process through given time period. When I use ps -p pid I only get usage of one cpu core, and when I ...
104 votes
13 answers
184k views
How to calculate the CPU usage of a process by PID in Linux from C?
I want to programmatically [in C] calculate CPU usage % for a given process ID in Linux. How can we get the realtime CPU usage % for a given process? To make it further clear: I should be able to ...
58 votes
7 answers
101k views
How to get total cpu usage in Linux using C++
I am trying to get total cpu usage in %. First I should start by saying that "top" will simply not do, as there is a delay between cpu dumps, it requires 2 dumps and several seconds, which hangs my ...
13 votes
2 answers
18k views
Getting CPU and Memory usage of a docker container from within the dockerized application
I'm running a node.js application from within a docker container. I'm trying to retrieve system usage metrics of the container the node.js application is running inside of. Right now I'm using https://...
3 votes
2 answers
2k views
How to get HZ with ADB shell
How can I know HZ value of Android kernel through ADB shell? (without any coding) I checked How to check HZ in the terminal?, but this is not work with Android ADB shell. Any suggestion?
2 votes
4 answers
3k views
Is there a controllable way to slow down my C++ program on online judges?
I am looking for a controllable way (easy to set the time for delay) to slow down my C++ solution on online judges. (Mainly for UVa, g++ 4.8.2 -lm -lcrypt -O2 -std=c++11 -pipe) I've tried the ...
5 votes
3 answers
4k views
Access data from proc file within kernel module
I need to access some proc files in a module on Android kernel. Basically i need the info shown in cat command, like cat /proc/uptime. However i need to do it programmatically. I tried work with ...
2 votes
2 answers
5k views
Calculating CPU Usage of a Process in Android
I am trying to calculate the CPU usage of a process in Android as follows, however i am not sure if its right due to the output produced. To convert from jiffie to seconds: jiffie / hertz 1st step: ...
7 votes
1 answer
2k views
top command returns 0% CPU usage when I check my process's CPU usage from within the process
I have written a C program which needs to get its own CPU and memory usage. So I have written something like this: system("prs_pid=`ps | grep prs-m1 | awk '{print $1}'` \n top -n1 | grep -m1 $...
4 votes
1 answer
3k views
What is exactly a "Clock Tick" in the context of Android CPU Usage?
I am currently working on a project in Android. I want to get the total cpu usage of each and every process. So i am using the contents of "/proc/pid/stat". I referred this answer to get the stats. ...
3 votes
1 answer
7k views
How to convert process cpu usage in clock ticks to percentage?
I setup collectd on my Debian 6 virtual machine for monitoring and performance analysis. Collectd's processes plugin provides statistics about a process' cpu usage, though what units these statistics ...
1 vote
0 answers
6k views
How to convert the clock ticks to milliseconds?
I want to retrieve the amount of time in milliseconds that a process has spent taking up CPU time since the process was started. I can found in the /proc/<pid>/stat the fields: #14 utime - CPU ...
7 votes
1 answer
5k views
Is there a way to get Application CPU usage with Android 7 (nougat)
In previous releases of Android I was able to get the CPU usage by using a top call String[] cmd = { "sh", "-c", "top -m 1000 -d 0 -n 1 | grep ...
0 votes
1 answer
3k views
How do apps measure CPU usage (as a %)?
So I'm trying to write an app that measures CPU usage (ie, the time CPU is working vs the time it isn't). I've done some research, but unfortunately there are a bunch of different opinions on how it ...
1 vote
1 answer
735 views
Unix process' CPU usage
I need to determeni the unix process' CPU usage... So, i want to write a bash script which will enable timer, run some process, stop timer. And I must know how that process used the CPU. And then ...