Android number of clock ticks [Hertz]

≯℡__Kan透↙ 提交于 2019-12-21 21:36:50

问题


In question about "total cpu usage of an application from /proc/pid/stat" is explanation, how to get cpu usage, but to do it, we must know clock ticks.

But how I can get this value in Android (directly from device)? I just don´t get how to use following function in Android, because it seems to be Linux command.

Hertz (number of clock ticks per second) of your system. In most cases, sysconf(_SC_CLK_TCK) can be used to return the number of clock ticks.


回答1:


Knowing the CPU frequency of your device should allows you to calculate the total CPU usage for an application, as discussed in the post you mentioned in your question. You can get information about your current CPU frequency by accessing the specific system files located in the /sys directory:

/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

This will tell you what the current CPU frequency is. You can also determine the maximum and minimum possible CPU frequencies by reading the cpuinfo_max_freq and cpuinfo_min_freq files, respectively:

/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq



来源:https://stackoverflow.com/questions/27671744/android-number-of-clock-ticks-hertz

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!