9086/tools/plot.sh

57 lines
1.4 KiB
Bash
Raw Normal View History

#!/bin/sh
set -euf
print_help(){
echo "$0 <json data file> <function> <output filename>"
echo " Possible functions:"
echo " cache_time : graph of cache utilisation in bytes over time in clock cycles"
echo " cache_util_freq : graph of the likelyhood of the cache for each utilisation"
}
if [ "$#" != 3 ] || ! [ -e "$1" ]
then
print_help
exit 1
fi
CSV_FILE=$(mktemp)
IN=$1
OUT=$3
jq -r '.Cycles[]| [.C,.L1,.VDI]|@csv' -- "$IN" > "$CSV_FILE"
BASE_GNUPLOT_OPTIONS="set datafile separator ',';set term svg;set output \"${OUT}\";"
case "$2" in
"cache_time")
CACHE_SIZE=$(jq -r .L1_size -- "$IN")
gnuplot -e "${BASE_GNUPLOT_OPTIONS}\
set xlabel \"Clock cycles\";\
set ylabel \"Cache utilisation (bytes)\";\
set offsets 0, 0, 3, 1;\
set ytics 0,1,$((CACHE_SIZE-1));\
unset colorbox;\
set ytics add (\"Valid\" -1);\
set palette model RGB defined ( 0 'red', 1 'green' );\
plot '${CSV_FILE}' using 1:2 with lines notitle ,\
'${CSV_FILE}' using 1:(-0.75):(0):(-0.5):3 with vectors nohead palette notitle"
;;
"cache_util_freq")
CACHE_SIZE=$(jq -r .L1_size -- "$IN")
gnuplot -e "${BASE_GNUPLOT_OPTIONS}\
set xlabel \"Utilisation (bytes)\";\
set ylabel \"Occurrences\";\
set boxwidth 0.5;\
set style fill solid 0.4;\
set xtics 0,1,$((CACHE_SIZE-1));\
set offsets 1, 2, 0, 0;\
plot '${CSV_FILE}' using 2:(1) smooth frequency with boxes notitle"
;;
*)
print_help;
exit 1
;;
esac