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.

  1. 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.
  2. Download this script and save it to your sdcard.
  3. 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 prioritiesFor 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的更多相关文章

  1. Send a WhatsApp Message programatically -- Tasker WhatsTasker

    Here is My code snippet: Uri mUri = Uri.parse("smsto:+9876543210"); Intent mIntent = new I ...

  2. 来一个使用sysbench测试cpu性能的简单脚本

    #!/bin/bash for ((i=1; i<16; i++)); do sysbench cpu run --cpu-max-prime=10000 --threads=4 --time= ...

  3. linux sysbench (一): CPU性能测试详解

    网上sysbench教材众多,但没有一篇中文教材对cpu测试参数和结果进行详解. 本文旨在能够让读者对sysbench的cpu有一定了解. 小慢哥的原创文章,欢迎转载 1.sysbench基础知识 s ...

  4. 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 ...

  5. Linux服务器CPU性能模式

    环境: Red Hat Enterprise Linux 4 Red Hat Enterprise Linux 5 Red Hat Enterprise Linux 6 Red Hat Enterpr ...

  6. 使用 tuned/tuned-adm工具动态调优系统CPU性能模式

    1)环境机器品牌:DELL  型号:R620配置:32核 * 1/256 GB*1/300 GB*4() + 1200 GB*2() 系统版本:CentOSLinux release 7.2.1511 ...

  7. linux sysbench : CPU性能测试详解

    1.sysbench基础知识 sysbench的cpu测试是在指定时间内,循环进行素数计算 素数(也叫质数)就是从1开始的自然数中,无法被整除的数,比如2.3.5.7.11.13.17等.编程公式:对 ...

  8. CloudStack全局参数

    {     "listconfigurationsresponse": {         "count": 305,         "config ...

  9. conky 配置变量表

    转自conky 配置变量表 项目主页:http://conky.sourceforge.net/ 文档说明:http://conky.sourceforge.net/docs.html Variabl ...

随机推荐

  1. 洛谷P1938 找工就业

    传送门啦 这个题本质就是跑一边最长路,重点就是在怎么建图上. 我们可以把点权放到边权上面,即将每一个边的终点点权当做这个边的边权,这个题里就是将工钱 $ d $ 当做边权. 如果这一条边需要坐飞机才能 ...

  2. (一) solr的安装与配置

    载solr文件压缩包,并解压 ,要运行solr服务之前需要先安装jdk,具体安装过程可以参看下面这篇文章: http://www.cnblogs.com/xiazh/archive/2012/05/2 ...

  3. MySQL学习笔记:case when

    一.MySQL case when的三种用法: 1.case 字段 when, 字段的具体值: select a.*, case sex when '1' then '男' else '女' end ...

  4. Python获取指定文件夹下的文件名

    本文采用os.walk()和os.listdir()两种方法,获取指定文件夹下的文件名. 一.os.walk() 模块os中的walk()函数可以遍历文件夹下所有的文件. os.walk(top, t ...

  5. Delphi与Socket

    一.Delphi与Socket计算机网络是由一系列网络通信协议组成的,其中的核心协议是传输层的TCPIP和UDP协议.TCP是面向连接的,通信双方保持一条通路,好比目前的电话线,使用telnet登陆B ...

  6. 《精通Python设计模式》学习结构型之外观模式

    这个我在工作中也有所应用的. 就是在真正的实现层上面,再封装一个函数的调用的. 这样就可以在内层函数作真正实现, 而外层调用函数对外开放, 隔离内外的变化性. from enum import Enu ...

  7. bzoj 1925 dp

    思路:dp[ i ][ 0 ]表示第一个是山谷的方案,dp[ i ][ 1 ]表示第一个是山峰的方案, 我们算dp[ x ][ state ]的时候枚举 x 的位置 x 肯定是山峰, 然后就用组合数算 ...

  8. Django实战(19):自定义many-to-many关系,实现Atom订阅

    记得有人跟我说过,rails的has_many :through是一个”亮点“,在Django看来,该功能简直不值一提.rails中的many-to-many关联中,还需要你手工创建关联表(写 mig ...

  9. PHP学习日记 函数

    可变函数 PHP支持可变函数的概念.所以如果一个变量后面有圆括号“()”,PHP将寻找与变量值同名的函数,并尝试执行此函数,可变函数可以用来实现回调函数.函数列表等.可变函数不能用于echo.prin ...

  10. ubuntu16.04 安装symfony3.3.11 碰到的问题:extension dom is required | oops an error occurred 500

    问题1:Uncaught exception 'RuntimeException' with message 'Extension DOM is required' 解决:sudo apt-get i ...