92 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.0-or-later3 4 5# Author/Copyright(c): 2009, Thomas Renninger <trenn@suse.de>, Novell Inc.6 7# Helper script to easily create nice plots of your cpufreq-bench results8 9dir=`mktemp -d`10output_file="cpufreq-bench.png"11global_title="cpufreq-bench plot"12picture_type="jpeg"13file[0]=""14 15function usage()16{17 echo "cpufreq-bench_plot.sh [OPTIONS] logfile [measure_title] [logfile [measure_title]] ...]"18 echo19 echo "Options"20 echo " -o output_file"21 echo " -t global_title"22 echo " -p picture_type [jpeg|gif|png|postscript|...]"23 exit 124}25 26if [ $# -eq 0 ];then27 echo "No benchmark results file provided"28 echo29 usage30fi31 32while getopts o:t:p: name ; do33 case $name in34 o)35 output_file="$OPTARG".$picture_type36 ;;37 t)38 global_title="$OPTARG"39 ;;40 p)41 picture_type="$OPTARG"42 ;;43 ?)44 usage45 ;;46 esac47done48shift $(($OPTIND -1))49 50plots=051while [ "$1" ];do52 if [ ! -f "$1" ];then53 echo "File $1 does not exist"54 usage55 fi56 file[$plots]="$1"57 title[$plots]="$2"58 # echo "File: ${file[$plots]} - ${title[plots]}"59 shift;shift60 plots=$((plots + 1))61done62 63echo "set terminal $picture_type" >> $dir/plot_script.gpl64echo "set output \"$output_file\"" >> $dir/plot_script.gpl65echo "set title \"$global_title\"" >> $dir/plot_script.gpl66echo "set xlabel \"sleep/load time\"" >> $dir/plot_script.gpl67echo "set ylabel \"Performance (%)\"" >> $dir/plot_script.gpl68 69for((plot=0;plot<$plots;plot++));do70 71 # Sanity check72 ###### I am to dump to get this redirected to stderr/stdout in one awk call... #####73 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 in one awk call... #####75 76 # Parse out load time (which must be equal to sleep time for a plot), divide it by 100077 # to get ms and parse out the performance in percentage and write it to a temp file for plotting78 cat ${file[$plot]} |grep -v "^#" |awk '{printf "%lu %.1f\n",$2/1000, $6}' >$dir/data_$plot79 80 if [ $plot -eq 0 ];then81 echo -n "plot " >> $dir/plot_script.gpl82 fi83 echo -n "\"$dir/data_$plot\" title \"${title[$plot]}\" with lines" >> $dir/plot_script.gpl84 if [ $(($plot + 1)) -ne $plots ];then85 echo -n ", " >> $dir/plot_script.gpl86 fi87done88echo >> $dir/plot_script.gpl89 90gnuplot $dir/plot_script.gpl91rm -r $dir92