1 #!/bin/bash 1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0-or-later << 3 2 >> 3 # This program is free software: you can redistribute it and/or modify >> 4 # it under the terms of the GNU General Public License as published by >> 5 # the Free Software Foundation; either version 2, or (at your option) >> 6 # any later version. >> 7 >> 8 # This program is distributed in the hope that it will be useful, >> 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of >> 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 11 # GNU General Public License for more details. >> 12 >> 13 # You should have received a copy of the GNU General Public License >> 14 # along with this program; if not, write to the Free Software >> 15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA >> 16 # 02110-1301, USA. 4 17 5 # Author/Copyright(c): 2009, Thomas Renninger < 18 # Author/Copyright(c): 2009, Thomas Renninger <trenn@suse.de>, Novell Inc. 6 19 7 # Helper script to easily create nice plots of 20 # Helper script to easily create nice plots of your cpufreq-bench results 8 21 9 dir=`mktemp -d` 22 dir=`mktemp -d` 10 output_file="cpufreq-bench.png" 23 output_file="cpufreq-bench.png" 11 global_title="cpufreq-bench plot" 24 global_title="cpufreq-bench plot" 12 picture_type="jpeg" 25 picture_type="jpeg" 13 file[0]="" 26 file[0]="" 14 27 15 function usage() 28 function usage() 16 { 29 { 17 echo "cpufreq-bench_plot.sh [OPTIONS] logf 30 echo "cpufreq-bench_plot.sh [OPTIONS] logfile [measure_title] [logfile [measure_title]] ...]" 18 echo 31 echo 19 echo "Options" 32 echo "Options" 20 echo " -o output_file" 33 echo " -o output_file" 21 echo " -t global_title" 34 echo " -t global_title" 22 echo " -p picture_type [jpeg|gif|png|pos 35 echo " -p picture_type [jpeg|gif|png|postscript|...]" 23 exit 1 36 exit 1 24 } 37 } 25 38 26 if [ $# -eq 0 ];then 39 if [ $# -eq 0 ];then 27 echo "No benchmark results file provid 40 echo "No benchmark results file provided" 28 echo 41 echo 29 usage 42 usage 30 fi 43 fi 31 44 32 while getopts o:t:p: name ; do 45 while getopts o:t:p: name ; do 33 case $name in 46 case $name in 34 o) 47 o) 35 output_file="$OPTARG".$picture_typ 48 output_file="$OPTARG".$picture_type 36 ;; 49 ;; 37 t) 50 t) 38 global_title="$OPTARG" 51 global_title="$OPTARG" 39 ;; 52 ;; 40 p) 53 p) 41 picture_type="$OPTARG" 54 picture_type="$OPTARG" 42 ;; 55 ;; 43 ?) 56 ?) 44 usage 57 usage 45 ;; 58 ;; 46 esac 59 esac 47 done 60 done 48 shift $(($OPTIND -1)) 61 shift $(($OPTIND -1)) 49 62 50 plots=0 63 plots=0 51 while [ "$1" ];do 64 while [ "$1" ];do 52 if [ ! -f "$1" ];then 65 if [ ! -f "$1" ];then 53 echo "File $1 does not exist" 66 echo "File $1 does not exist" 54 usage 67 usage 55 fi 68 fi 56 file[$plots]="$1" 69 file[$plots]="$1" 57 title[$plots]="$2" 70 title[$plots]="$2" 58 # echo "File: ${file[$plots]} - ${title[pl 71 # echo "File: ${file[$plots]} - ${title[plots]}" 59 shift;shift 72 shift;shift 60 plots=$((plots + 1)) 73 plots=$((plots + 1)) 61 done 74 done 62 75 63 echo "set terminal $picture_type" >> $di 76 echo "set terminal $picture_type" >> $dir/plot_script.gpl 64 echo "set output \"$output_file\"" >> $di 77 echo "set output \"$output_file\"" >> $dir/plot_script.gpl 65 echo "set title \"$global_title\"" >> $di 78 echo "set title \"$global_title\"" >> $dir/plot_script.gpl 66 echo "set xlabel \"sleep/load time\"" >> $di 79 echo "set xlabel \"sleep/load time\"" >> $dir/plot_script.gpl 67 echo "set ylabel \"Performance (%)\"" >> $di 80 echo "set ylabel \"Performance (%)\"" >> $dir/plot_script.gpl 68 81 69 for((plot=0;plot<$plots;plot++));do 82 for((plot=0;plot<$plots;plot++));do 70 83 71 # Sanity check 84 # Sanity check 72 ###### I am to dump to get this redirected 85 ###### I am to dump to get this redirected to stderr/stdout in one awk call... ##### 73 cat ${file[$plot]} |grep -v "^#" |awk '{if 86 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}' 74 ###### I am to dump to get this redirected 87 ###### I am to dump to get this redirected in one awk call... ##### 75 88 76 # Parse out load time (which must be equal 89 # Parse out load time (which must be equal to sleep time for a plot), divide it by 1000 77 # to get ms and parse out the performance 90 # to get ms and parse out the performance in percentage and write it to a temp file for plotting 78 cat ${file[$plot]} |grep -v "^#" |awk '{pr 91 cat ${file[$plot]} |grep -v "^#" |awk '{printf "%lu %.1f\n",$2/1000, $6}' >$dir/data_$plot 79 92 80 if [ $plot -eq 0 ];then 93 if [ $plot -eq 0 ];then 81 echo -n "plot " >> $dir/plot_script.gp 94 echo -n "plot " >> $dir/plot_script.gpl 82 fi 95 fi 83 echo -n "\"$dir/data_$plot\" title \"${tit 96 echo -n "\"$dir/data_$plot\" title \"${title[$plot]}\" with lines" >> $dir/plot_script.gpl 84 if [ $(($plot + 1)) -ne $plots ];then 97 if [ $(($plot + 1)) -ne $plots ];then 85 echo -n ", " >> $dir/plot_script.gpl 98 echo -n ", " >> $dir/plot_script.gpl 86 fi 99 fi 87 done 100 done 88 echo >> $dir/plot_script.gpl 101 echo >> $dir/plot_script.gpl 89 102 90 gnuplot $dir/plot_script.gpl 103 gnuplot $dir/plot_script.gpl 91 rm -r $dir !! 104 rm -r $dir
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.