Reputation: 165
i am to get the pid of the process and i want to calculate the cpu usage of the process of which i have the pid in android ndk.i am a newbie to ndk. Anyone knows how to do that,any help will be really appreciated.
Upvotes: 3
Views: 2127
Reputation: 8725
From this discussion I found that it's impossible to get that information on Android. And also I used many task managers on Android and none of them didn't provide such data (they show only memory usage).
Update:
Looks like your question is duplicate to this one.
So all you need to do is to analyze file /proc/<pid>/stat
to get CPU usage.
Update #2:
From source Android top.c I found how to get process usage in function print_procs
:
proc->delta_time * 100 / total_delta_time
Upvotes: 1