Path: blob/master/tools/power/cpupower/bench/cpufreq-bench_plot.sh
26292 views
#!/bin/bash1# SPDX-License-Identifier: GPL-2.0-or-later234# Author/Copyright(c): 2009, Thomas Renninger <[email protected]>, Novell Inc.56# Helper script to easily create nice plots of your cpufreq-bench results78dir=`mktemp -d`9output_file="cpufreq-bench.png"10global_title="cpufreq-bench plot"11picture_type="jpeg"12file[0]=""1314function usage()15{16echo "cpufreq-bench_plot.sh [OPTIONS] logfile [measure_title] [logfile [measure_title]] ...]"17echo18echo "Options"19echo " -o output_file"20echo " -t global_title"21echo " -p picture_type [jpeg|gif|png|postscript|...]"22exit 123}2425if [ $# -eq 0 ];then26echo "No benchmark results file provided"27echo28usage29fi3031while getopts o:t:p: name ; do32case $name in33o)34output_file="$OPTARG".$picture_type35;;36t)37global_title="$OPTARG"38;;39p)40picture_type="$OPTARG"41;;42?)43usage44;;45esac46done47shift $(($OPTIND -1))4849plots=050while [ "$1" ];do51if [ ! -f "$1" ];then52echo "File $1 does not exist"53usage54fi55file[$plots]="$1"56title[$plots]="$2"57# echo "File: ${file[$plots]} - ${title[plots]}"58shift;shift59plots=$((plots + 1))60done6162echo "set terminal $picture_type" >> $dir/plot_script.gpl63echo "set output \"$output_file\"" >> $dir/plot_script.gpl64echo "set title \"$global_title\"" >> $dir/plot_script.gpl65echo "set xlabel \"sleep/load time\"" >> $dir/plot_script.gpl66echo "set ylabel \"Performance (%)\"" >> $dir/plot_script.gpl6768for((plot=0;plot<$plots;plot++));do6970# Sanity check71###### I am to dump to get this redirected to stderr/stdout in one awk call... #####72cat ${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}'73###### I am to dump to get this redirected in one awk call... #####7475# Parse out load time (which must be equal to sleep time for a plot), divide it by 100076# to get ms and parse out the performance in percentage and write it to a temp file for plotting77cat ${file[$plot]} |grep -v "^#" |awk '{printf "%lu %.1f\n",$2/1000, $6}' >$dir/data_$plot7879if [ $plot -eq 0 ];then80echo -n "plot " >> $dir/plot_script.gpl81fi82echo -n "\"$dir/data_$plot\" title \"${title[$plot]}\" with lines" >> $dir/plot_script.gpl83if [ $(($plot + 1)) -ne $plots ];then84echo -n ", " >> $dir/plot_script.gpl85fi86done87echo >> $dir/plot_script.gpl8889gnuplot $dir/plot_script.gpl90rm -r $dir919293