cpufreq-bench_plot.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. # Author/Copyright(c): 2009, Thomas Renninger <trenn@suse.de>, Novell Inc.
  4. # Helper script to easily create nice plots of your cpufreq-bench results
  5. dir=`mktemp -d`
  6. output_file="cpufreq-bench.png"
  7. global_title="cpufreq-bench plot"
  8. picture_type="jpeg"
  9. file[0]=""
  10. function usage()
  11. {
  12. echo "cpufreq-bench_plot.sh [OPTIONS] logfile [measure_title] [logfile [measure_title]] ...]"
  13. echo
  14. echo "Options"
  15. echo " -o output_file"
  16. echo " -t global_title"
  17. echo " -p picture_type [jpeg|gif|png|postscript|...]"
  18. exit 1
  19. }
  20. if [ $# -eq 0 ];then
  21. echo "No benchmark results file provided"
  22. echo
  23. usage
  24. fi
  25. while getopts o:t:p: name ; do
  26. case $name in
  27. o)
  28. output_file="$OPTARG".$picture_type
  29. ;;
  30. t)
  31. global_title="$OPTARG"
  32. ;;
  33. p)
  34. picture_type="$OPTARG"
  35. ;;
  36. ?)
  37. usage
  38. ;;
  39. esac
  40. done
  41. shift $(($OPTIND -1))
  42. plots=0
  43. while [ "$1" ];do
  44. if [ ! -f "$1" ];then
  45. echo "File $1 does not exist"
  46. usage
  47. fi
  48. file[$plots]="$1"
  49. title[$plots]="$2"
  50. # echo "File: ${file[$plots]} - ${title[plots]}"
  51. shift;shift
  52. plots=$((plots + 1))
  53. done
  54. echo "set terminal $picture_type" >> $dir/plot_script.gpl
  55. echo "set output \"$output_file\"" >> $dir/plot_script.gpl
  56. echo "set title \"$global_title\"" >> $dir/plot_script.gpl
  57. echo "set xlabel \"sleep/load time\"" >> $dir/plot_script.gpl
  58. echo "set ylabel \"Performance (%)\"" >> $dir/plot_script.gpl
  59. for((plot=0;plot<$plots;plot++));do
  60. # Sanity check
  61. ###### I am to dump to get this redirected to stderr/stdout in one awk call... #####
  62. cat ${file[$plot]} |grep -v "^#" |awk '{if ($2 != $3) printf("Error in measure %d:Load time %s does not equal sleep time %s, plot will not be correct\n", $1, $2, $3); ERR=1}'
  63. ###### I am to dump to get this redirected in one awk call... #####
  64. # Parse out load time (which must be equal to sleep time for a plot), divide it by 1000
  65. # to get ms and parse out the performance in percentage and write it to a temp file for plotting
  66. cat ${file[$plot]} |grep -v "^#" |awk '{printf "%lu %.1f\n",$2/1000, $6}' >$dir/data_$plot
  67. if [ $plot -eq 0 ];then
  68. echo -n "plot " >> $dir/plot_script.gpl
  69. fi
  70. echo -n "\"$dir/data_$plot\" title \"${title[$plot]}\" with lines" >> $dir/plot_script.gpl
  71. if [ $(($plot + 1)) -ne $plots ];then
  72. echo -n ", " >> $dir/plot_script.gpl
  73. fi
  74. done
  75. echo >> $dir/plot_script.gpl
  76. gnuplot $dir/plot_script.gpl
  77. rm -r $dir