androidperformancecpu-usageandroid-testingcpu-speed

Locking the CPU on android for app performance testing


I'm trying to test an app's performance on android at different CPU states. So i will like to lock the CPU at say 1000Mhz and take readings and then overload the CPU and take readings. My question is: Is there anyway to lock the CPU and possibly the RAM at certain lock/freeze rates?? Any link to documentations on this will be highly appreciated.


Solution

  • Follow these steps(all steps with root privilege):
    1. stop mpdecision
    2. In /sys/devices/system/cpu you can see how many cores in your device, if dual core, you will see cpu0 and cpu1 two folders.
    3. write 0 or 1 to disable or enable core

    echo "0" > /sys/devices/system/cpu/cpu1/online # disable core
    echo "1" > /sys/devices/system/cpu/cpu1/online # enable core
    

    4. change governor of CPU

    echo "userspace" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    

    5. set frequency

    echo "1000000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
    

    remember to check /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq to see what frequency you can set in step 5.

    For step 4 and 5, you can set frequency through this app(need root privilege).

    For more details, you can see this.