2023-05-14 15:06:33 +00:00
|
|
|
#!/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"
|
2023-11-15 14:37:46 +00:00
|
|
|
echo " cache_util_freq : graph of the likelihood of the cache for each utilisation"
|
2023-05-14 15:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$#" != 3 ] || ! [ -e "$1" ]
|
|
|
|
then
|
|
|
|
print_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
CSV_FILE=$(mktemp)
|
|
|
|
IN=$1
|
|
|
|
OUT=$3
|
|
|
|
|
2023-05-21 01:59:53 +00:00
|
|
|
jq -r '.Cycles[]| [.C,.L1,.VDI,.JMP]|@csv' -- "$IN" > "$CSV_FILE"
|
2023-05-14 15:06:33 +00:00
|
|
|
|
|
|
|
BASE_GNUPLOT_OPTIONS="set datafile separator ',';set term svg;set output \"${OUT}\";"
|
|
|
|
|
2023-05-18 19:15:52 +00:00
|
|
|
parse_cache_size(){
|
|
|
|
CACHE_SIZE=$(jq -r .L1_size -- "$IN")
|
|
|
|
}
|
|
|
|
|
2023-05-21 01:59:53 +00:00
|
|
|
parse_total_cycles(){
|
|
|
|
TOTAL_CYCLES=$(jq -r .\"Total\ Cycles\" -- "$IN")
|
|
|
|
}
|
|
|
|
|
2023-05-14 15:06:33 +00:00
|
|
|
case "$2" in
|
|
|
|
"cache_time")
|
2023-05-18 19:15:52 +00:00
|
|
|
parse_cache_size
|
2023-05-21 01:59:53 +00:00
|
|
|
parse_total_cycles
|
2023-05-14 15:06:33 +00:00
|
|
|
gnuplot -e "${BASE_GNUPLOT_OPTIONS}\
|
2023-10-30 08:00:09 +00:00
|
|
|
set term svg name \"Cache_time\";\
|
2023-05-14 15:06:33 +00:00
|
|
|
set xlabel \"Clock cycles\";\
|
|
|
|
set ylabel \"Cache utilisation (bytes)\";\
|
|
|
|
set offsets 0, 0, 3, 1;\
|
|
|
|
set ytics 0,1,$((CACHE_SIZE-1));\
|
2023-05-21 01:59:53 +00:00
|
|
|
set xtics 0,$((TOTAL_CYCLES/15)),${TOTAL_CYCLES};\
|
2023-05-14 15:06:33 +00:00
|
|
|
unset colorbox;\
|
|
|
|
set ytics add (\"Valid\" -1);\
|
2023-05-18 19:15:52 +00:00
|
|
|
set grid ytics;\
|
|
|
|
set yrange [-2:${CACHE_SIZE}];\
|
2023-10-30 08:00:09 +00:00
|
|
|
set xrange [-10:${TOTAL_CYCLES}+9];\
|
2023-05-21 01:59:53 +00:00
|
|
|
set palette model RGB defined ( 0 'red', 1 'green', 2 'dark-khaki' );\
|
|
|
|
plot\
|
|
|
|
'${CSV_FILE}' using 1:(-2):(0):("'$'"4*100):(2) with vectors nohead palette notitle,\
|
|
|
|
'${CSV_FILE}' using 1:2 with histeps notitle ls 1,\
|
|
|
|
'${CSV_FILE}' using 1:(-0.75):(0):(-0.5):3 with vectors nohead palette notitle \
|
|
|
|
"
|
2023-05-14 15:06:33 +00:00
|
|
|
|
|
|
|
;;
|
|
|
|
"cache_util_freq")
|
2023-05-18 19:15:52 +00:00
|
|
|
parse_cache_size
|
2023-05-14 15:06:33 +00:00
|
|
|
gnuplot -e "${BASE_GNUPLOT_OPTIONS}\
|
2023-10-30 08:00:09 +00:00
|
|
|
set term svg name \"cache_util_freq\";\
|
2023-05-14 15:06:33 +00:00
|
|
|
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
|