Tasker : Scale Up/Down CPU Speed at Different Times
http://techsplurge.com/4926/android-awesome-15-tasker-profiles-tutorials/
Yeah I know, there’s SetCPU app for under/over clocking CPU but it cannot be used to scale up or down when specific apps are launched or during a certain time period. So here’s how this can be achieved with Tasker. This is a very advanced profile and relatively long as well.
- You’ll need 2 apps for this profile: Locale Execute plug-in (free) and a terminal editor such as theAndroid Terminal Emulator. Download them from the link given and install ‘em.
- Download this script and save it to your sdcard.
- Open up the terminal editor and type these lines:
su
mkdir /data/local/bin
mv /sdcard/setcpu.sh /data/local/bin/setcpu
chmod /data/local/bin/setcpu
script :
#!/system/bin/sh # setcpu, a set cpu script written for custom Android Roms by clvv <[email protected]>
# Usage: setcpu [MINFREQ MAXFREQ GOVERNOR]
# setcpu -h, --help #print this message
# setcpu -s, --status #print CPU status
# If no parameter is specified, an interactive setup guide will start.
# NOTE: This script MUST be run as root in order to make configuration change!
# Tips: run 'watch -n1 setcpu -s' to watch CPU status, refresh every second.
# Happy overclocking! :)
# Script written by clvv <[email protected]> if [ $# -eq 0 ]; then
freqs=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies)
echo "NOTE: This script MUST be run as root in order to make configuration change!"
echo -n "Current CPU min_freq: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo -n "Current CPU max_freq: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo -n "Current CPU governor: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo -n "Current CPU frequency: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
echo "Available CPU frequencies: $freqs"
echo -n "Please enter a desired CPU min_freq: "
read min
if [ $min ]; then
if [ $(echo $freqs | grep -q -E " $min |^$min | $min$"; echo $?) -eq 0 ]; then
echo $min > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq && echo "Done"
else
echo "Please enter a valid value of CPU min_freq!" 1>&2
fi
fi
unset min
echo -n "Please enter a desired CPU max_freq: "
read max
if [ $max ]; then
if [ $(echo $freqs | grep -q -E " $max |^$max | $max$"; echo $?) -eq 0 ]; then
echo $max > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq && echo "Done"
else
echo "Please enter a valid value of CPU max_freq!" 1>&2
fi
fi
unset max
unset freqs
gvnrs=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
echo "Available CPU governors: $gvnrs"
echo -n "Please enter a desired type of CPU governor: "
read gvnr
if [ $gvnr ]; then
if [ $(echo $gvnrs | grep -q -E " $gvnr |^$gvnr | $gvnr$"; echo $?) -eq 0 ]; then
echo $gvnr > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor && echo "Done"
else
echo "Please enter a valid type of CPU governor!" 1>&2
fi
fi
unset gvnr
unset gvnrs
elif [[ "$1" = '-h' -o "$1" = '--help' ]]; then
echo "Usage: setcpu [MINFREQ MAXFREQ GOVERNOR]"
echo " setcpu -h, --help #print this message"
echo " setcpu -s, --status #print CPU status"
echo "If no parameter is specified, an interactive setup guide will start."
echo "NOTE: This script MUST be run as root in order to make configuration change!"
echo "Tips: run 'watch -n1 setcpu -s' to watch CPU status, refresh every second."
echo -n "Your available CPU frequencies are:"
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
echo "Happy overclocking! :)"
echo "Script written by clvv <[email protected]>"
elif [[ "$1" = '-s' -o "$1" = '--status' ]]; then
echo -n "Available CPU frequencies:"; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
echo -n "Current CPU min_freq: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo -n "Current CPU max_freq: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo -n "Current CPU governor: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo -n "Current CPU frequency: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
else
freqs=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies)
if [ $1 ]; then
if [ $(echo $freqs | grep -q -E " $1 |^$1 | $1$"; echo $?) -eq 0 ]; then
echo $1 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
else
echo "Please use a valid value of CPU min_freq!" 1>&2
fi
fi
if [ $2 ]; then
if [ $(echo $freqs | grep -q -E " $2 |^$2 | $2$"; echo $?) -eq 0 ]; then
echo $2 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
else
echo "Please use a valid value of CPU max_freq!" 1>&2
fi
fi
unset freqs
if [ $3 ]; then
if [ $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | grep -q -E " $3 |^$3 | $3$"; echo $?) -eq 0 ]; then
echo $3 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
else
echo "Please use a valid type of CPU governor!" 1>&2
fi
fi
fi
Now, Create multiple profiles, categorized like:
- Display off: “CPU LOW” (Context: Event –> Display –> Display Off)
- Playing a game: “CPU HIGH” (Context: Application)
- Battery > 50%: “CPU MED” (Context: State –> Battery Level)
Then, in each of them, execute the Locale Execute plugin the script in the following format:
/data/local/bin/setcpu <min> <max> <scaling type>
e.g.: “setcpu 200000 800000 ondemand” will set my cpu speed to 200Mhz at minimum and 800Mhz at most with the scaling type as “ondemand”. In most of the kernels, “ondemand” and “performance” are available as the scaling governor.
ondemand – When the CPU load reaches a certain point, ondemand will rapidly scale the CPU up to meet demand, then gradually scale the CPU down when it isn’t needed.
performance – It will keep the CPU running at the “max” set value at all times for best performance.
SetCPU Step by Step Instructions
I fould this online and thought it may come in handy for some people ...
SetCPU for Root Users
SetCPU for Root Users allows you to manage the CPU frequency settings of your Android device. It works with most commercial Android devices that have root access enabled for applications. Combined with custom profiles, SetCPU can help you manage your CPU settings to optimize performance and battery life. On many phones, oftentimes with the help of custom kernels, SetCPU can also manage overclocking on your device. SetCPU is currently available on the Android Market and the SlideME Market.
SetCPU works on most devices running Android 1.5 to Android 2.2, with Android 1.6 and above recommended. If you have an HTC device, you may need to disable perflock (see 10) depending on your kernel.
1. Benefits
The CPU drains more power if it is running at a higher frequency. If the processor is running faster, the phone will be faster and more responsive, but the battery may drain more quickly. If the processor is running more slowly, the phone will be less responsive and take longer to complete tasks, but battery life will be increased. With SetCPU, you can set up profiles to manage the CPU speed based on certain conditions.
2. Main Tab and Basic Usage
To get started with SetCPU, start the app, read the introduction, and pick "autodetect frequencies." If you ever need to access this screen again, press the Menu button in SetCPU's Main tab, then choose Device Selection.
If your kernel doesn't support autodetect, you won't see it choose the device that best matches your phone from the list. After you've passed the introduction screen, you may get a request from Superuser Permissions. Depending on your version of Superuser Permissions, either check the box for "remember" and press "allow" or press the "always allow" button.
The sliders here allow you to manually control the CPU scaling bounds. The CPU frequency will always be between these two values. By default, the CPU should scale between the max and min frequencies based on need. The sliders also control the "main" profile as explained later.
The "scaling" drop-down list is an advanced feature that allows you to control the behavior of the CPU scaling mechanism. See explanations for the different governors in the CPU Scaling Governors section.
SetCPU also includes a widget for your home screen. Add SetCPU's widget like you would any other widget: long press on your home screen, select Widgets, and select the SetCPU widget. A screen will pop up so you can configure the widget's appearance. If you would like it to show current CPU speed, set the Active Refresh Interval to something other than "Passive," though a passive refresh interval is recommended to save battery.
HTC device users: If the green "current" display doesn't change as you change the sliders, you may be using an incompatible HTC kernel with a driver called "perflock" that prevents SetCPU from changing frequencies. To enable SetCPU, press the "Menu" button in SetCPU's main tab and select "disable perflock." Read through the notice and then press the button in the dialog. If successful, you should be able to change the frequency with SetCPU. If this process fails, please e-mail the developer with your kernel version and device so support can be added. For more details, see the perflock section below.

3. Profiles
Profiles allow you to configure SetCPU to set your CPU speed under certain conditions. This is useful to manage battery savings. To get started with profiles, check the "Enable" button in the Profiles tab and press "Add Profile" to add your first profile.
Your profile settings will be triggered if the condition you set in the profile is met. For example, if you choose "Screen Off," the profile settings will be set when the screen is off. If no profiles are met, SetCPU reverts to the default profile specified in the Main tab. Several conditions are available:
- Charging/Full - Set when the phone is charging from any source and when the battery is full while charging.
- Charging AC/Full - Set only when the phone is charging from a wall plug (AC adapter) and when the battery is full while charging from a wall plug.
- Charging USB/Full - Set only when the phone is charging from a computer (USB port) and when the battery is full while charging from the USB port.
- Screen Off - Set when the phone's screen is turned off.
- Battery < - Set when the battery falls below a certain point. You will also be able to specifiy battery level for this profile.
- Temp > - Set when the battery or system temperature rises above a certain point. SetCPU will notify you with a ringtone notification if you check the "Audible Warning" checkbox here. You will also be able to specify a temperature for this profile.
- CPU Temp > - Limited to phones whose hardware and kernels support it. Set when the CPU temperature rises above a certain point. SetCPU will notify you with a ringtone notification if you check the "Audible Warning" checkbox here. You will also be able to specify a temperature for this profile.
The priority of each profile specifies the order in which it will be evaluated. If the conditions of two profiles are both true, the one with the higher priority will be set. For example, if you have both a Screen Off and a Charging profile and the screen is off and charging at the same time, the one with the higher priority will be set.
You can add as many profiles as you want, and selectively enable and disable profiles by using the checkbox next to them. To edit profiles, click on them, make the necessary changes, and press "save." To remove profiles, click on it to edit, and press "delete."
Some things to keep in mind: For multiple battery level profiles, assign the profiles with lower percentages higher priorities. For multiple temperature profiles, assign the profiles with higher temperatures higher priories. Generally, battery level profiles should have lower priorities than other profiles, and temperature profiles should have higher priorites than other profiles.
Check the "Notifications" box to enable a persistent notification in the top bar showing exactly which profile is currently active.
4. Advanced Tab
The Advanced menu allows you to tweak the finer aspects of certain CPU governors. It is only activated when you choose the ondemand or conservative governors.
- Sampling Rate - An interval (in microseconds) at which the governor will poll for updates. When this happens, the governor will decide whether to scale the CPU up or down.
- Up Threshold - Defines a percentage from 1% to 100%. When the CPU load reaches this point, the governor will scale the CPU up.
- Down Threshold (conservative only) - Defines a percentage from 1% to 100%. When the CPU load reaches this point, the governor will scale the CPU down.
- Ignore Nice Load - If this value is "1," the system will ignore "Nice" processes when deciding to scale up or down.
- Powersave Bias (ondemand only) - Setting this value higher will "bias" the governor toward lower frequencies. This is a percentage, where 1000 is 100%, 100 is 10%, and 0 is 0%. The ondemand governor will scale the CPU to a frequency lower than its "target" speed according to this value.
- Freq Step (conservative only) - Defines how much (as a percentage of the maximum CPU speed) the conservative governor will increase the CPU speed by each time the CPU load reaches the Up Threshold.
Choose the "Set on Boot" checkbox to apply advanced settings when the phone boots. This option is completely independent of the similar option in the Main tab.
5. System Info
The System Info tab allows you to view information about your kernel, CPU, battery, phone, and memory status. It also includes a few tools for benchmarking the speed of the phone.
The lower the benchmark score, the faster the phone is running. Keep in mind that this score can only be used to accurately compare different frequencies across the same ROM and kernel. The score may fluctuate between runs due to interference by background processes. For best results, use the "performance" governor.
There is also a "stress test" function. Stress testing allows you to test the stability of undervolted kernels or higher overclocks. The stress test will peg your CPU usage to 100% The phone may be somewhat unresponsive during this time. The stress test will continue forever, so you have to manually end it after some time. To do this, simply press the back button.
To copy the text of the System Info menu to the clipboard, press the Menu button on your device and press "Copy to Clipboard."
6. About
The About menu prints information about SetCPU, including the current version. You can change the theme of the Main tab from using the drop down box. Restart SetCPU to apply it.
7. CPU Scaling Governors
CPU governors control exactly how the CPU scales between your "max" and "min" set frequencies. Most kernels have "ondemand" and "performance." The availability
- ondemand - Available in most kernels, and the default governor in most kernels. When the CPU load reaches a certain point (see "up threshold" in Advanced Settings), ondemand will rapidly scale the CPU up to meet demand, then gradually scale the CPU down when it isn't needed.
- conservative - Available in some kernels. It is similar to the ondemand governor, but will scale the CPU up more gradually to better fit demand. Conservative provides a less responsive experience than ondemand, but can save battery.
- performance - Available in most kernels. It will keep the CPU running at the "max" set value at all times. This is a bit more efficient than simply setting "max" and "min" to the same value and using ondemand because the system will not waste resources scanning for the CPU load. This governor is recommended for stable benchmarking.
- powersave - Available in some kernels. It will keep the CPU running at the "min" set value at all times.
- userspace- A method for controlling the CPU speed that isn't currently used by SetCPU. For best results, do not use the userspace governor.
8. Custom Frequency Config
In rare situations and in older kernels, SetCPU may not be able to autodetect the full range of speeds supported by the kernel. If this is the case, you can configure SetCPU to use custom frequencies. To get started, you'll need the list of frequencies your kernel can support in kHz (not MHz!). Only certain frequencies work, so be sure you know which speeds your kernel supports before using the custom option.
Create a plain text file called "setcpu.txt" and place it on the root directory of your SD card or on your SD card's ext partition (/sdcard/ or /system/sd/). The text files should sort the frequencies on one line by comma, from lowest to highest. For example, the following is a valid config file for some Motorola Droid kernels:
125000,250000,500000,550000,600000
To store the custom frequency list on your phone, save it as "setcpu" with no extension and put it in /data/local/. SetCPU reads from the SD card first and uses that text file if present, then tries to read from /data/local/.
To configure SetCPU to read your custom frequencies, go back to the device selection screen (in the Main tab, press Menu > Device Selection), choose "show other frequencies" if necessary, and choose the custom config option at the very bottom.
9. Task Managers
SetCPU does not run a background service unless profiles or the widget are enabled. Due to how multitasking works on Android, the Android system will automatically free up SetCPU if memory is needed and SetCPU isn't being used.
If either profiles or the widget are enabled, SetCPU does run background processes that keep them running. It's important that you add SetCPU to your task manager's "ignore" list, or otherwise avoid disabling the SetCPU process, if you have either profiles or the widget enabled. You should not have to use task managers to disable SetCPU at any time.
To disable all SetCPU background processes, remove the widget from the home screen and uncheck the "enable" box in the profiles menu. Anything else should be taken care of the Android system when memory is needed, just like any other app. Note that SetCPU briefly runs (and then immediately disables) a service upon startup to perform its "start on boot" duties. This is normal and should not add to memory usage.
10. Disabling Perflock
On most stock HTC kernels and some custom kernels, HTC has enabled a driver called "perflock" that constantly resets SetCPU's Max and Min settings. This does not apply to mostly "Google experience" HTC devices such as the T-Mobile G1, the myTouch 3G, any Google development device, or the Nexus One. It does, however, apply to "HTC Sense" devices such as the HTC Hero, Droid Eris, HTC Desire, HTC Incredible, EVO 4G, and myTouch Slide. Non-HTC devices never have perflock enabled.
SetCPU can disable perflock on newer HTC kernels, giving you control of the Max and Min settings of the CPU. To do this, press the Menu button on your device in the Main tab and choose "Disable Perflock." Read through the notice and then press the button in the dialog. If successful, you should be able to change the frequency with SetCPU. If this process fails, please e-mail the developer with your kernel version and device so support can be added.
Keep in mind that disabling perflock does not enable overclocking, though some overclocked kernels may require perflock to be disabled. Overclocking, in most cases, requires a custom kernel.
Tasker : Scale Up/Down CPU Speed at Different Times的更多相关文章
- Send a WhatsApp Message programatically -- Tasker WhatsTasker
Here is My code snippet: Uri mUri = Uri.parse("smsto:+9876543210"); Intent mIntent = new I ...
- 来一个使用sysbench测试cpu性能的简单脚本
#!/bin/bash for ((i=1; i<16; i++)); do sysbench cpu run --cpu-max-prime=10000 --threads=4 --time= ...
- linux sysbench (一): CPU性能测试详解
网上sysbench教材众多,但没有一篇中文教材对cpu测试参数和结果进行详解. 本文旨在能够让读者对sysbench的cpu有一定了解. 小慢哥的原创文章,欢迎转载 1.sysbench基础知识 s ...
- System and method for dynamically adjusting to CPU performance changes
FIELD OF THE INVENTION The present invention is related to computing systems, and more particularly ...
- Linux服务器CPU性能模式
环境: Red Hat Enterprise Linux 4 Red Hat Enterprise Linux 5 Red Hat Enterprise Linux 6 Red Hat Enterpr ...
- 使用 tuned/tuned-adm工具动态调优系统CPU性能模式
1)环境机器品牌:DELL 型号:R620配置:32核 * 1/256 GB*1/300 GB*4() + 1200 GB*2() 系统版本:CentOSLinux release 7.2.1511 ...
- linux sysbench : CPU性能测试详解
1.sysbench基础知识 sysbench的cpu测试是在指定时间内,循环进行素数计算 素数(也叫质数)就是从1开始的自然数中,无法被整除的数,比如2.3.5.7.11.13.17等.编程公式:对 ...
- CloudStack全局参数
{ "listconfigurationsresponse": { "count": 305, "config ...
- conky 配置变量表
转自conky 配置变量表 项目主页:http://conky.sourceforge.net/ 文档说明:http://conky.sourceforge.net/docs.html Variabl ...
随机推荐
- const 和 #define区别_fenglovel_新浪博客
const 和 #define区别 (2012-12-11 14:14:07) 转载▼ 标签: 杂谈 (1) 编译器处理方式不同 define宏是在预处理阶段展开. const常量是编译运行阶段使 ...
- windows环境下的heap spray+stack pivot gadget 实现绕过dep
ASLR+DEP是windows平台下最为常见的两种保护手段.这两种手段使得最基础的jmp esp等手法不再适用,而单纯的堆喷也会因为堆内存不可执行而失效.那么这里就来介绍一下heap spray+s ...
- java通过POI和easypoi实现Excel的导出
前言 在工作经常会遇到excel导出报表的功能,自己也做过一些,然后在项目里看到同事封装的一个excel导出工具类,着实不错,拿来分享一下.然后,又在网上看到一个使用easypoi实现cxcel导出的 ...
- 在MVC中如何使用vs2013编译调试razor cshtml
打开mvc项目的csproj文件: <MvcBuildViews>false</MvcBuildViews> 改为 <MvcBuildViews>true</ ...
- 【POJ】2165.Gunman
题解 把直线的斜率分解成二维,也就是随着z的增加x的增量和y的增量 我们发现一条合法直线向上移一点一定能碰到一条横线 知道了这条横线可以算出y的斜率 我们旋转一下,让这条横线碰到两条竖线,就可以算出x ...
- 配置tomcat报错: Unknown version of Tomcat was specified.
报错原因:路劲没选择对,应选择bin文件夹的上一层目录,也不能选择bin目录
- win10字体大小设置
有时图形化界面不能正常显示,需要改变字体大小来查看 更改字体大小: 更改字体:
- poj3268 Silver Cow Party(两次SPFA || 两次Dijkstra)
题目链接 http://poj.org/problem?id=3268 题意 有向图中有n个结点,编号1~n,输入终点编号x,求其他结点到x结点来回最短路长度的最大值. 思路 最短路问题,有1000个 ...
- source Insight 软件使用注意点
1. 需要将 tab键转为 4个空格 首先通过路径(Options->Document Options)进入以下界面: step 1:将 Visible tabs 打勾. step 2 :将 E ...
- rabbitmq学习(二) —— helloword!
rabbitmq学习当然是跟着官网走最好了,官网的教程写的很好,跟着官网教程走一遍就会有个初步了解了 下面的教程转自http://cmsblogs.com/?p=2768,该博客对官网的翻译还不错 介 ...