how to get memory usage and cpu usage by application?

后端 未结 4 735
耶瑟儿~
耶瑟儿~ 2021-02-09 16:23

I found this code to get overall cpu usage. is this possible to convert this to tell cpu usage by process? Is there any API by which we can get CPU or Memory usage of android?

4条回答
  •  滥情空心
    2021-02-09 17:16

    Read /proc/[pid]/stat - [pid] is your target process's pid

    Then look for the following members.

    • utime %lu
    • stime %lu

    man /proc @ http://linux.die.net/man/5/proc

提交回复
热议问题