cpufreq-bench_script.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/bash
  2. # This program is free software: you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 2, or (at your option)
  5. # any later version.
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. # You should have received a copy of the GNU General Public License
  11. # along with this program; if not, write to the Free Software
  12. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  13. # 02110-1301, USA.
  14. # Author/Copyright(c): 2009, Thomas Renninger <trenn@suse.de>, Novell Inc.
  15. # Ondemand up_threshold and sampling rate test script for cpufreq-bench
  16. # mircobenchmark.
  17. # Modify the general variables at the top or extend or copy out parts
  18. # if you want to test other things
  19. #
  20. # Default with latest kernels is 95, before micro account patches
  21. # it was 80, cmp. with git commit 808009131046b62ac434dbc796
  22. UP_THRESHOLD="60 80 95"
  23. # Depending on the kernel and the HW sampling rate could be restricted
  24. # and cannot be set that low...
  25. # E.g. before git commit cef9615a853ebc4972084f7 one could only set
  26. # min sampling rate of 80000 if CONFIG_HZ=250
  27. SAMPLING_RATE="20000 80000"
  28. function measure()
  29. {
  30. local -i up_threshold_set
  31. local -i sampling_rate_set
  32. for up_threshold in $UP_THRESHOLD;do
  33. for sampling_rate in $SAMPLING_RATE;do
  34. # Set values in sysfs
  35. echo $up_threshold >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
  36. echo $sampling_rate >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
  37. up_threshold_set=$(cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold)
  38. sampling_rate_set=$(cat /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate)
  39. # Verify set values in sysfs
  40. if [ ${up_threshold_set} -eq ${up_threshold} ];then
  41. echo "up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"
  42. else
  43. echo "WARNING: Tried to set up_threshold: $up_threshold, set in sysfs: ${up_threshold_set}"
  44. fi
  45. if [ ${sampling_rate_set} -eq ${sampling_rate} ];then
  46. echo "sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"
  47. else
  48. echo "WARNING: Tried to set sampling_rate: $sampling_rate, set in sysfs: ${sampling_rate_set}"
  49. fi
  50. # Benchmark
  51. cpufreq-bench -o /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}
  52. done
  53. done
  54. }
  55. function create_plots()
  56. {
  57. local command
  58. for up_threshold in $UP_THRESHOLD;do
  59. 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 %\""
  60. for sampling_rate in $SAMPLING_RATE;do
  61. command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"sampling_rate = $sampling_rate\""
  62. done
  63. echo $command
  64. eval "$command"
  65. echo
  66. done
  67. for sampling_rate in $SAMPLING_RATE;do
  68. 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\""
  69. for up_threshold in $UP_THRESHOLD;do
  70. command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold\""
  71. done
  72. echo $command
  73. eval "$command"
  74. echo
  75. done
  76. 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\""
  77. for sampling_rate in $SAMPLING_RATE;do
  78. for up_threshold in $UP_THRESHOLD;do
  79. command="${command} /var/log/cpufreq-bench/up_threshold_${up_threshold}_sampling_rate_${sampling_rate}/* \"up_threshold = $up_threshold - sampling_rate = $sampling_rate\""
  80. done
  81. done
  82. echo "$command"
  83. eval "$command"
  84. }
  85. measure
  86. create_plots