#!/bin/bash # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # Author/Copyright(c): 2009, Thomas Renninger , Novell Inc. # Ondemand up_threshold and sampling rate test script for cpufreq-bench # mircobenchmark. # Modify the general variables at the top or extend or copy out parts # if you want to test other things # # Default with latest kernels is 95, before micro account patches # it was 80, cmp. with git commit 808009131046b62ac434dbc796 global UP_THRESHOLD := '"60 80 95'" # Depending on the kernel and the HW sampling rate could be restricted # and cannot be set that low... # E.g. before git commit cef9615a853ebc4972084f7 one could only set # min sampling rate of 80000 if CONFIG_HZ=250 global SAMPLING_RATE := '"20000 80000'" proc measure { var -i up_threshold_set = '' var -i sampling_rate_set = '' for up_threshold in [$UP_THRESHOLD]{ for sampling_rate in [$SAMPLING_RATE]{ # Set values in sysfs echo $up_threshold >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold echo $sampling_rate >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate up_threshold_set := $[cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold] sampling_rate_set := $[cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate] # Verify set values in sysfs if test $(up_threshold_set) -eq $(up_threshold){ echo "up_threshold: $up_threshold, set in sysfs: $(up_threshold_set)" } else { echo "WARNING: Tried to set up_threshold: $up_threshold, set in sysfs: $(up_threshold_set)" } if test $(sampling_rate_set) -eq $(sampling_rate){ echo "sampling_rate: $sampling_rate, set in sysfs: $(sampling_rate_set)" } else { echo "WARNING: Tried to set sampling_rate: $sampling_rate, set in sysfs: $(sampling_rate_set)" } # Benchmark cpufreq-bench -o /var/log/cpufreq-bench/up_threshold_$(up_threshold)_sampling_rate_$(sampling_rate) } } } proc create_plots { var command = '' for up_threshold in [$UP_THRESHOLD]{ command := ""cpufreq-bench_plot.sh -o \"sampling_rate_$(SAMPLING_RATE)_up_threshold_$(up_threshold)\" -t \"Ondemand sampling_rate: $(SAMPLING_RATE) comparison - Up_threshold: $up_threshold %"\"" for sampling_rate in [$SAMPLING_RATE]{ command := ""$(command) /var/log/cpufreq-bench/up_threshold_$(up_threshold)_sampling_rate_$(sampling_rate)/* \"sampling_rate = $sampling_rate"\"" } echo $command eval $command echo } for sampling_rate in [$SAMPLING_RATE]{ command := ""cpufreq-bench_plot.sh -o \"up_threshold_$(UP_THRESHOLD)_sampling_rate_$(sampling_rate)\" -t \"Ondemand up_threshold: $(UP_THRESHOLD) % comparison - sampling_rate: $sampling_rate"\"" for up_threshold in [$UP_THRESHOLD]{ command := ""$(command) /var/log/cpufreq-bench/up_threshold_$(up_threshold)_sampling_rate_$(sampling_rate)/* \"up_threshold = $up_threshold"\"" } echo $command eval $command echo } command := ""cpufreq-bench_plot.sh -o \"up_threshold_$(UP_THRESHOLD)_sampling_rate_$(SAMPLING_RATE)\" -t \"Ondemand up_threshold: $(UP_THRESHOLD) and sampling_rate $(SAMPLING_RATE) comparison"\"" for sampling_rate in [$SAMPLING_RATE]{ for up_threshold in [$UP_THRESHOLD]{ command := ""$(command) /var/log/cpufreq-bench/up_threshold_$(up_threshold)_sampling_rate_$(sampling_rate)/* \"up_threshold = $up_threshold - sampling_rate = $sampling_rate"\"" } } echo $command eval $command } measure create_plots (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:UP_THRESHOLD) op: Equal rhs: {(DQ ("60 80 95"))} spids: [69] ) ] spids: [69] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:SAMPLING_RATE) op: Equal rhs: {(DQ ("20000 80000"))} spids: [86] ) ] spids: [86] ) (FuncDef name: measure body: (BraceGroup children: [ (Assignment keyword: Assign_Local flags: ["'-i'"] pairs: [(assign_pair lhs:(LhsName name:up_threshold_set) op:Equal spids:[105])] spids: [101] ) (Assignment keyword: Assign_Local flags: ["'-i'"] pairs: [(assign_pair lhs:(LhsName name:sampling_rate_set) op:Equal spids:[112])] spids: [108] ) (ForEach iter_name: up_threshold iter_words: [{($ VSub_Name "$UP_THRESHOLD")}] do_arg_iter: False body: (DoGroup children: [ (ForEach iter_name: sampling_rate iter_words: [{($ VSub_Name "$SAMPLING_RATE")}] do_arg_iter: False body: (DoGroup children: [ (SimpleCommand words: [{(echo)} {($ VSub_Name "$up_threshold")}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold)} spids: [146] ) ] ) (SimpleCommand words: [{(echo)} {($ VSub_Name "$sampling_rate")}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate)} spids: [154] ) ] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:up_threshold_set) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(cat)} { ( /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold ) } ) ] ) left_token: spids: [159 163] ) } spids: [158] ) ] spids: [158] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:sampling_rate_set) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (C {(cat)} { ( /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate ) } ) ] ) left_token: spids: [167 171] ) } spids: [166] ) ] spids: [166] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name up_threshold_set)} {(-eq)} {(${ VSub_Name up_threshold)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} { (DQ ("up_threshold: ") ($ VSub_Name "$up_threshold") (", set in sysfs: ") (${ VSub_Name up_threshold_set) ) } ) ] spids: [-1 195] ) ] else_action: [ (C {(echo)} { (DQ ("WARNING: Tried to set up_threshold: ") ($ VSub_Name "$up_threshold") (", set in sysfs: ") (${ VSub_Name up_threshold_set) ) } ) ] spids: [210 225] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(${ VSub_Name sampling_rate_set)} {(-eq)} {(${ VSub_Name sampling_rate)} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} { (DQ ("sampling_rate: ") ($ VSub_Name "$sampling_rate") (", set in sysfs: ") (${ VSub_Name sampling_rate_set) ) } ) ] spids: [-1 244] ) ] else_action: [ (C {(echo)} { (DQ ("WARNING: Tried to set sampling_rate: ") ($ VSub_Name "$sampling_rate") (", set in sysfs: ") (${ VSub_Name sampling_rate_set) ) } ) ] spids: [259 274] ) (C {(cpufreq-bench)} {(-o)} {(/var/log/cpufreq-bench/up_threshold_) (${ VSub_Name up_threshold) (_sampling_rate_) (${ VSub_Name sampling_rate) } ) ] spids: [135 296] ) spids: [132 134] ) ] spids: [124 299] ) spids: [121 123] ) ] spids: [98] ) spids: [92 97] ) (FuncDef name: create_plots body: (BraceGroup children: [ (Assignment keyword: Assign_Local pairs: [(assign_pair lhs:(LhsName name:command) op:Equal spids:[315])] spids: [313] ) (ForEach iter_name: up_threshold iter_words: [{($ VSub_Name "$UP_THRESHOLD")}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:command) op: Equal rhs: { (DQ ("cpufreq-bench_plot.sh -o ") (EscapedLiteralPart token: ) (sampling_rate_) (${ VSub_Name SAMPLING_RATE) (_up_threshold_) (${ VSub_Name up_threshold) (EscapedLiteralPart token: ) (" -t ") (EscapedLiteralPart token:) ("Ondemand sampling_rate: ") (${ VSub_Name SAMPLING_RATE) (" comparison - Up_threshold: ") ($ VSub_Name "$up_threshold") (" %") (EscapedLiteralPart token: ) ) } spids: [330] ) ] spids: [330] ) (ForEach iter_name: sampling_rate iter_words: [{($ VSub_Name "$SAMPLING_RATE")}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:command) op: Equal rhs: { (DQ (${ VSub_Name command) (" /var/log/cpufreq-bench/up_threshold_") (${ VSub_Name up_threshold) (_sampling_rate_) (${ VSub_Name sampling_rate) ("/* ") (EscapedLiteralPart token: ) ("sampling_rate = ") ($ VSub_Name "$sampling_rate") (EscapedLiteralPart token:) ) } spids: [367] ) ] spids: [367] ) ] spids: [364 388] ) spids: [361 363] ) (C {(echo)} {($ VSub_Name "$command")}) (C {(eval)} {(DQ ($ VSub_Name "$command"))}) (C {(echo)}) ] spids: [327 406] ) spids: [324 326] ) (ForEach iter_name: sampling_rate iter_words: [{($ VSub_Name "$SAMPLING_RATE")}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:command) op: Equal rhs: { (DQ ("cpufreq-bench_plot.sh -o ") (EscapedLiteralPart token: ) (up_threshold_) (${ VSub_Name UP_THRESHOLD) (_sampling_rate_) (${ VSub_Name sampling_rate) (EscapedLiteralPart token: ) (" -t ") (EscapedLiteralPart token:) ("Ondemand up_threshold: ") (${ VSub_Name UP_THRESHOLD) (" % comparison - sampling_rate: ") ($ VSub_Name "$sampling_rate") (EscapedLiteralPart token: ) ) } spids: [421] ) ] spids: [421] ) (ForEach iter_name: up_threshold iter_words: [{($ VSub_Name "$UP_THRESHOLD")}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:command) op: Equal rhs: { (DQ (${ VSub_Name command) (" /var/log/cpufreq-bench/up_threshold_") (${ VSub_Name up_threshold) (_sampling_rate_) (${ VSub_Name sampling_rate) ("/* ") (EscapedLiteralPart token: ) ("up_threshold = ") ($ VSub_Name "$up_threshold") (EscapedLiteralPart token:) ) } spids: [457] ) ] spids: [457] ) ] spids: [454 478] ) spids: [451 453] ) (C {(echo)} {($ VSub_Name "$command")}) (C {(eval)} {(DQ ($ VSub_Name "$command"))}) (C {(echo)}) ] spids: [418 496] ) spids: [415 417] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:command) op: Equal rhs: { (DQ ("cpufreq-bench_plot.sh -o ") (EscapedLiteralPart token:) (up_threshold_) (${ VSub_Name UP_THRESHOLD) (_sampling_rate_) (${ VSub_Name SAMPLING_RATE) (EscapedLiteralPart token:) (" -t ") (EscapedLiteralPart token:) ("Ondemand up_threshold: ") (${ VSub_Name UP_THRESHOLD) (" and sampling_rate ") (${ VSub_Name SAMPLING_RATE) (" comparison") (EscapedLiteralPart token:) ) } spids: [500] ) ] spids: [500] ) (ForEach iter_name: sampling_rate iter_words: [{($ VSub_Name "$SAMPLING_RATE")}] do_arg_iter: False body: (DoGroup children: [ (ForEach iter_name: up_threshold iter_words: [{($ VSub_Name "$UP_THRESHOLD")}] do_arg_iter: False body: (DoGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:command) op: Equal rhs: { (DQ (${ VSub_Name command) (" /var/log/cpufreq-bench/up_threshold_") (${ VSub_Name up_threshold) (_sampling_rate_) (${ VSub_Name sampling_rate) ("/* ") (EscapedLiteralPart token: ) ("up_threshold = ") ($ VSub_Name "$up_threshold") (" - sampling_rate = ") ($ VSub_Name "$sampling_rate") (EscapedLiteralPart token: ) ) } spids: [550] ) ] spids: [550] ) ] spids: [547 573] ) spids: [544 546] ) ] spids: [536 576] ) spids: [533 535] ) (C {(echo)} {(DQ ($ VSub_Name "$command"))}) (C {(eval)} {(DQ ($ VSub_Name "$command"))}) ] spids: [310] ) spids: [304 309] ) (C {(measure)}) (C {(create_plots)}) ] )