0

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.

amrezzd
  • 1,787
  • 15
  • 38

2 Answers2

2

I am not sure about programmatically, but you can use Android profiler to achieve the same.

  1. Run your application, either in a physical device or emulator (doesn't matter here)
  2. 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

Saurabh Mishra
  • 306
  • 3
  • 12
0

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:

  • utime %lu
  • stime %lu

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.

amrezzd
  • 1,787
  • 15
  • 38