Path: blob/master/tools/power/cpupower/bench/cpufreq-bench_script.sh
26292 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.0-or-later234# Author/Copyright(c): 2009, Thomas Renninger <[email protected]>, Novell Inc.56# Ondemand up_threshold and sampling rate test script for cpufreq-bench7# mircobenchmark.8# Modify the general variables at the top or extend or copy out parts9# if you want to test other things10#1112# Default with latest kernels is 95, before micro account patches13# it was 80, cmp. with git commit 808009131046b62ac434dbc79614UP_THRESHOLD="60 80 95"15# Depending on the kernel and the HW sampling rate could be restricted16# and cannot be set that low...17# E.g. before git commit cef9615a853ebc4972084f7 one could only set18# min sampling rate of 80000 if CONFIG_HZ=25019SAMPLING_RATE="20000 80000"2021function measure()22{23local -i up_threshold_set24local -i sampling_rate_set2526for up_threshold in $UP_THRESHOLD;do27for sampling_rate in $SAMPLING_RATE;do28# Set values in sysfs29echo $up_threshold >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold30echo $sampling_rate >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate31up_threshold_set=$(cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold)32sampling_rate_set=$(cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate)3334# Verify set values in sysfs35if [ ${up_threshold_set} -eq ${up_threshold} ];then36echo "up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"37else38echo "WARNING: Tried to set up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"39fi40if [ ${sampling_rate_set} -eq ${sampling_rate} ];then41echo "sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"42else43echo "WARNING: Tried to set sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"44fi4546# Benchmark47cpufreq-bench -o /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}48done49done50}5152function create_plots()53{54local command5556for up_threshold in $UP_THRESHOLD;do57command="cpufreq-bench_plot.sh -o \"sampling_rate_${SAMPLING_RATE}_up_threshold_${up_threshold}\" -t \"Ondemand sampling_rate: ${SAMPLING_RATE} comparison - Up_threshold: $up_threshold %\""58for sampling_rate in $SAMPLING_RATE;do59command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"sampling_rate = $sampling_rate\""60done61echo $command62eval "$command"63echo64done6566for sampling_rate in $SAMPLING_RATE;do67command="cpufreq-bench_plot.sh -o \"up_threshold_${UP_THRESHOLD}_sampling_rate_${sampling_rate}\" -t \"Ondemand up_threshold: ${UP_THRESHOLD} % comparison - sampling_rate: $sampling_rate\""68for up_threshold in $UP_THRESHOLD;do69command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold\""70done71echo $command72eval "$command"73echo74done7576command="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\""77for sampling_rate in $SAMPLING_RATE;do78for up_threshold in $UP_THRESHOLD;do79command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold - sampling_rate = $sampling_rate\""80done81done82echo "$command"83eval "$command"84}8586measure87create_plots888990