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. linux 安装 Elasticsearch6.4.0详细步骤以及问题解决方案

    1.jdk 安装 参考资料:https://www.cnblogs.com/shihaiming/p/5809553.html 2.elasticsearch 安装 下载:https://artifa ...

  2. Python学习1-Python和Pycharm的下载与安装

    本文主要介绍Python的下载安装和Python编辑器Pycharm的下载与安装. 一.Python的下载与安装 1.下载 到Python官网上下载Python的安装文件,进入网站后显示如下图: 网速 ...

  3. hihocoder1636 Pangu and Stones(区间DP(石子合并变形))

    题目链接:http://hihocoder.com/problemset/problem/1636 题目大意:有n堆石头,每次只能合并l~r堆,每次合并的花费是要合并的石子的重量,问你合并n堆石子的最 ...

  4. 如何使用 JMeter 调用你的 Restful Web Service?进行简单的压力测试和自动化测试

    表述性状态传输(REST)作为对基于 SOAP 和 Web 服务描述语言(WSDL)的 Web 服务的简单替代,在 Web 开发上得到了广泛的接受.能够充分证明这点的是主流 Web 2.0 服务提供商 ...

  5. sass问题

     用sass的minix定义一些代码片段,且可传参数 /** * @module 功能 * @description 生成全屏方法 * @method fullscreen * @version 1. ...

  6. 参数化SQL语句

    避免SQL注入的方法有两种:一是所有的SQL语句都存放在存储过程中,这样不但可以避免SQL注入,还能提高一些性能,并且存储过程可以由专门的数据库管理员(DBA)编写和集中管理,不过这种做法有时候针对相 ...

  7. WangSql 3.0源码共享(WangSql 1.0重大升级到3.0)

    WangSql 1.0博文阅读: http://www.cnblogs.com/deeround/p/6204610.html 基于1.0做了以下重大改动: 1.多数据实现方式调整 2.使用EmitM ...

  8. 【LOJ】#2057. 「TJOI / HEOI2016」游戏

    题解 我并不会做,我觉得很像网络流但是毫无建图思路 我猜了个贪心,写了一下--啥过了90分?!这数据是有多水啊.. 哦又是行列拆点 不过要按照'#'进行拆点,也就是一段横着的区间只能放一个炸弹,一段竖 ...

  9. 【BZOJ】1336: [Balkan2002]Alien最小圆覆盖

    题解 我们先把所有点random_shuffle一下 然后对前i - 1个点计算一个最小圆覆盖,然后第i个点如果不在这个圆里,那么我们把这个点当成一个新的点,作为圆心,半径为0 从头枚举1 - i - ...

  10. python之web框架(3):WSGI之web应用完善

    python之web框架(3):WSGI之web应用完善 1.上篇的web框架太low,只能实现回应固定页面.现在将它进行完善.首先将wsgi和web服务器进行分离,并给予它回复静态页面的能力. we ...