Reputation: 2077
Is there any way to find out CPU usage of my Android application programmatically? I'm aware of this question already, but it is about Corona SDK.
Note that I want to do this on non-root devices.
Any help would be appreciated.
Upvotes: 0
Views: 3208
Reputation: 2077
I just found a way to calculate the CPU usage of a process by PID. According to the doc, the /proc/[pid]/stat
file contains status information about the process. So we can parse this file to get the following members:
Check this page to get more information about the /proc/[pid]/stat
file and the way to parse it.
Also here is a relevant question about utime
and stime
.
Upvotes: 0
Reputation: 296
I am not sure about programmatically, but you can use Android profiler to achieve the same.
- Run your application, either in a physical device or emulator (doesn't matter here)
- When the application is running, you will see a Profile tab in the toolbar
If you don't see a Profile tab, you can access the same using Run > Profile 'app'
Edit
Check this answer
Edit 2 You can use firebase performance monitoring for runtime data collection about performance. Follow this link
Upvotes: 2