Linux 3.1已经将cpupower-utils中放入内核的tools目录,见:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=tree;f=tools/power;h=f6a98ba17528ed7645f53bb8cb67f59112adf346;hb=c3b92c8787367a8bb53d57d9789b558f1295cc96
在其中有一个工具叫cpufreq-bench,可以用于测试ondemand等cpufreq策略的使用对系统性能的影响,譬如:
#/usr/sbin/cpufreq-bench -l 50000 -s 100000 -x 50000 -y 100000 -g interactive -
r 5 -n 5 -v
loading defaults
parsing: sleep ->50000
parsing: load ->50000
parsing: cpu -> 0
parsing: priority-> LOW
parsing: output ->/var/log/cpufreq-bench
logilename:/var/log/cpufreq-bench/benchmark_localhost_2.6.38.8-xxx_6470.log
Logfile:/var/log/cpufreq-bench/benchmark_localhost_2.6.38.8-xxx_6470.log
parsing: sleep_step-> 50000
parsing: load_step-> 50000
parsing: cycles ->20
parsing: rounds ->40
parsing: verbose-> 0
parsing: governor-> ondemand
user load time ->50000
user sleep time ->100000
user load_step ->50000
user sleep_step ->100000
user governor ->interactive
user rounds -> 5
user cycles -> 5
verbose outputenabled
starting benchmarkwith parameters:
config:
sleep=100000
load=50000
sleep_step=100000
load_step=50000
cpu=0
cycles=5
rounds=5
governor=interactive
approx. testduration: 0m
set cpu affinity tocpu #0
set affinity to cpu#0
low prioritycondition requested
set schedulerpriority to 0
set performance ascpufreq governor
calibrating load of50000us, please wait...
calibrating with 6rounds
calibrating with 6rounds
calibrating with 6rounds
calibrating with 6rounds
calibration done
_round 1: doing 5cycles with 6 calculations for 50000us
avarage: 8333us,rps:120
performance cycletook 147635us, sleep: 100000us, load: 50000us, rounds: 6
performance cycletook 147506us, sleep: 100000us, load: 50000us, rounds: 6
performance cycletook 147590us, sleep: 100000us, load: 50000us, rounds: 6
performance cycletook 147755us, sleep: 100000us, load: 50000us, rounds: 6
performance cycletook 147563us, sleep: 100000us, load: 50000us, rounds: 6
set interactive ascpufreq governor
powersave cycle took166866us, sleep: 100000us, load: 50000us, rounds: 6
powersave cycle took164004us, sleep: 100000us, load: 50000us, rounds: 6
powersave cycle took165926us, sleep: 100000us, load: 50000us, rounds: 6
powersave cycle took163750us, sleep: 100000us, load: 50000us, rounds: 6
powersave cycle took165789us, sleep: 100000us, load: 50000us, rounds: 6
performance is at 72.95%
set performance ascpufreq governor
calibrating load of100000us, please wait...
calibrating with 12rounds
calibrating with 12rounds
calibrating with 12rounds
calibrating with 12rounds
calibration done
_round 2: doing 5cycles with 12 calculations for 100000us
avarage: 8333us,rps:120
performance cycletook 296382us, sleep: 200000us, load: 100000us, rounds: 12
performance cycletook 296349us, sleep: 200000us, load: 100000us, rounds: 12
performance cycletook 296266us, sleep: 200000us, load: 100000us, rounds: 12
performance cycletook 296152us, sleep: 200000us, load: 100000us, rounds: 12
performance cycletook 295848us, sleep: 200000us, load: 100000us, rounds: 12
set interactive ascpufreq governor
powersave cycle took314330us, sleep: 200000us, load: 100000us, rounds: 12
powersave cycle took308119us, sleep: 200000us, load: 100000us, rounds: 12
powersave cycle took309546us, sleep: 200000us, load: 100000us, rounds: 12
powersave cycle took309942us, sleep: 200000us, load: 100000us, rounds: 12
powersave cycle took309673us, sleep: 200000us, load: 100000us, rounds: 12
performance is at 87.20%
set performance ascpufreq governor
calibrating load of150000us, please wait...
calibrating with 18rounds
calibrating with 18rounds
calibrating with 18rounds
calibrating with 18rounds
calibration done
_round 3: doing 5cycles with 18 calculations for 150000us
avarage: 8333us,rps:120
performance cycletook 445460us, sleep: 300000us, load: 150000us, rounds: 18
performance cycletook 445368us, sleep: 300000us, load: 150000us, rounds: 18
performance cycletook 445724us, sleep: 300000us, load: 150000us, rounds: 18
performance cycletook 445194us, sleep: 300000us, load: 150000us, rounds: 18
performance cycletook 445266us, sleep: 300000us, load: 150000us, rounds: 18
set interactive ascpufreq governor
powersave cycle took457701us, sleep: 300000us, load: 150000us, rounds: 18
powersave cycle took462000us, sleep: 300000us, load: 150000us, rounds: 18
powersave cycle took457623us, sleep: 300000us, load: 150000us, rounds: 18
powersave cycle took461664us, sleep: 300000us, load: 150000us, rounds: 18
powersave cycle took458122us, sleep: 300000us, load: 150000us, rounds: 18
performance is at 91.21%
set performance ascpufreq governor
calibrating load of200000us, please wait...
calibrating with 24rounds
calibrating with 25rounds
calibrating with 25rounds
calibrating with 25rounds
calibration done
_round 4: doing 5cycles with 25 calculations for 200000us
avarage: 8000us,rps:125
performance cycletook 602273us, sleep: 400000us, load: 200000us, rounds: 25
performance cycletook 602022us, sleep: 400000us, load: 200000us, rounds: 25
performance cycletook 602541us, sleep: 400000us, load: 200000us, rounds: 25
performance cycletook 602642us, sleep: 400000us, load: 200000us, rounds: 25
performance cycletook 603079us, sleep: 400000us, load: 200000us, rounds: 25
set interactive ascpufreq governor
powersave cycle took616433us, sleep: 400000us, load: 200000us, rounds: 25
powersave cycle took613765us, sleep: 400000us, load: 200000us, rounds: 25
powersave cycle took616331us, sleep: 400000us, load: 200000us, rounds: 25
powersave cycle took614218us, sleep: 400000us, load: 200000us, rounds: 25
powersave cycle took615348us, sleep: 400000us, load: 200000us, rounds: 25
performance is at 94.10%
set performance ascpufreq governor
calibrating load of250000us, please wait...
calibrating with 30rounds
calibrating with 31rounds
calibrating with 31rounds
calibrating with 31rounds
calibration done
_round 5: doing 5cycles with 31 calculations for 250000us
avarage: 8064us,rps:124
performance cycletook 752050us, sleep: 500000us, load: 250000us, rounds: 31
performance cycletook 751701us, sleep: 500000us, load: 250000us, rounds: 31
performance cycletook 751966us, sleep: 500000us, load: 250000us, rounds: 31
performance cycletook 752029us, sleep: 500000us, load: 250000us, rounds: 31
performance cycletook 752338us, sleep: 500000us, load: 250000us, rounds: 31
set interactive ascpufreq governor
powersave cycle took768047us, sleep: 500000us, load: 250000us, rounds: 31
powersave cycle took763706us, sleep: 500000us, load: 250000us, rounds: 31
powersave cycle took766064us, sleep: 500000us, load: 250000us, rounds: 31
powersave cycle took763898us, sleep: 500000us, load: 250000us, rounds: 31
powersave cycle took765694us, sleep: 500000us, load: 250000us, rounds: 31
performance is at 94.93%
可见它的结果为:
Round 1 - 72.95%
Round 2 - 87.20%
Round 3 - 91.21%
Round 4 - 94.10%
Round 5 - 94.93%
interactive为UI或者说IO更好的响应而设计,测试结果也显示它在性能方面的考量更加aggressive一些。