Fix misspellings using 'codespell' tool
[fio.git] / tools / fio_generate_plots
CommitLineData
b35c036c
L
1#!/bin/sh
2#
3# This script is an almost total rewrite by Louwrentius
4# of the original fio_generate_plots script provided as part of the FIO storage
5# benchmark utiliy. I only retained how GNUplot is used to generate graphs, as
6# that is something I know nothing about.
7#
8# The script uses the files generated by FIO to create nice graphs in the
9# SVG format. This output format is supported by most modern browsers and
de8f6de9 10# allows resolution independent graphs to be generated.
b35c036c
L
11#
12# This script supports GNUPLOT 4.4 and higher.
13#
14# Version 1.0 @ 20121231
15#
16#
17#
18
19if [ -z "$1" ]; then
20 echo "Usage: fio_generate_plots subtitle [xres yres]"
ebac4655
JA
21 exit 1
22fi
23
1618495b 24GNUPLOT=$(which gnuplot)
bd33a2f5 25if [ ! -x "$GNUPLOT" ]
b35c036c 26then
1618495b
JA
27 echo You need gnuplot installed to generate graphs
28 exit 1
29fi
30
b35c036c 31TITLE="$1"
ebac4655 32
4d1577b1 33# set resolution
b35c036c
L
34if [ ! -z "$2" ] && [ ! -z "$3" ]
35then
4d1577b1
MS
36 XRES="$2"
37 YRES="$3"
38else
b35c036c 39 XRES=1280
4d1577b1
MS
40 YRES=768
41fi
42
b35c036c
L
43if [ -z "$SAMPLE_DURATION" ]
44then
45 SAMPLE_DURATION="*"
ebac4655
JA
46fi
47
b35c036c
L
48DEFAULT_GRID_LINE_TYPE=3
49DEFAULT_LINE_WIDTH=2
50DEFAULT_LINE_COLORS="
51set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb\"#ffffff\" behind
52set style line 1 lc rgb \"#E41A1C\" lw $DEFAULT_LINE_WIDTH lt 1;
53set style line 2 lc rgb \"#377EB8\" lw $DEFAULT_LINE_WIDTH lt 1;
54set style line 3 lc rgb \"#4DAF4A\" lw $DEFAULT_LINE_WIDTH lt 1;
55set style line 4 lc rgb \"#984EA3\" lw $DEFAULT_LINE_WIDTH lt 1;
56set style line 5 lc rgb \"#FF7F00\" lw $DEFAULT_LINE_WIDTH lt 1;
57set style line 6 lc rgb \"#DADA33\" lw $DEFAULT_LINE_WIDTH lt 1;
58set style line 7 lc rgb \"#A65628\" lw $DEFAULT_LINE_WIDTH lt 1;
59set style line 20 lc rgb \"#000000\" lt $DEFAULT_GRID_LINE_TYPE lw $DEFAULT_LINE_WIDTH;
60"
61
62DEFAULT_TERMINAL="set terminal svg enhanced dashed size $XRES,$YRES dynamic"
63DEFAULT_TITLE_FONT="\"Helvetica,28\""
64DEFAULT_AXIS_FONT="\"Helvetica,14\""
65DEFAULT_AXIS_LABEL_FONT="\"Helvetica,16\""
66DEFAULT_XLABEL="set xlabel \"Time (sec)\" font $DEFAULT_AXIS_LABEL_FONT"
67DEFAULT_XTIC="set xtics font $DEFAULT_AXIS_FONT"
68DEFAULT_YTIC="set ytics font $DEFAULT_AXIS_FONT"
69DEFAULT_MXTIC="set mxtics 0"
70DEFAULT_MYTIC="set mytics 2"
71DEFAULT_XRANGE="set xrange [0:$SAMPLE_DURATION]"
72DEFAULT_YRANGE="set yrange [0:*]"
73DEFAULT_GRID="set grid ls 20"
74DEFAULT_KEY="set key outside bottom center ; set key box enhanced spacing 2.0 samplen 3 horizontal width 4 height 1.2 "
75DEFAULT_SOURCE="set label 30 \"Data source: http://example.com\" font $DEFAULT_AXIS_FONT tc rgb \"#00000f\" at screen 0.976,0.175 right"
76DEFAULT_OPTS="$DEFAULT_LINE_COLORS ; $DEFAULT_GRID_LINE ; $DEFAULT_GRID ; $DEFAULT_GRID_MINOR ; $DEFAULT_XLABEL ; $DEFAULT_XRANGE ; $DEFAULT_YRANGE ; $DEFAULT_XTIC ; $DEFAULT_YTIC ; $DEFAULT_MXTIC ; $DEFAULT_MYTIC ; $DEFAULT_KEY ; $DEFAULT_TERMINAL ; $DEFAULT_SOURCE"
77
78plot () {
79
80 if [ -z "$TITLE" ]
81 then
82 PLOT_TITLE=" set title \"$1\" font $DEFAULT_TITLE_FONT"
83 else
84 PLOT_TITLE=" set title \"$TITLE\\\n\\\n{/*0.6 "$1"}\" font $DEFAULT_TITLE_FONT"
85 fi
86 FILETYPE="$2"
87 YAXIS="set ylabel \"$3\" font $DEFAULT_AXIS_LABEL_FONT"
88 SCALE=$4
89
90 echo "Title: $PLOT_TITLE"
91 echo "File type: $FILETYPE"
92 echo "yaxis: $YAXIS"
93
94 i=0
95
96 for x in *_"$FILETYPE".log
97 do
98 i=$((i+1))
99 PT=$(echo $x | sed s/_"$FILETYPE".log//g)
100 if [ ! -z "$PLOT_LINE" ]
101 then
102 PLOT_LINE=$PLOT_LINE", "
103 fi
104
105 DEPTH=$(echo $PT | cut -d "-" -f 4)
106 PLOT_LINE=$PLOT_LINE"'$x' using (\$1/1000):(\$2/$SCALE) title \"Queue depth $DEPTH\" with lines ls $i"
107
108 done
109
110 OUTPUT="set output \"$TITLE-$FILETYPE.svg\" "
111
112 echo " $PLOT_TITLE ; $YAXIS ; $DEFAULT_OPTS ; show style lines ; $OUTPUT ; plot " $PLOT_LINE | $GNUPLOT -
113 unset PLOT_LINE
114}
115
116#
117# plot <sub title> <file name tag> <y axis label> <y axis scale>
118#
119
120plot "I/O Latency" lat "Time (msec)" 1000
121plot "I/O Operations Per Second" iops "IOPS" 1
122plot "I/O Submission Latency" slat "Time (╬╝sec)" 1
123plot "I/O Completion Latency" clat "Time (msec)" 1000
124plot "I/O Bandwidth" bw "Throughput (KB/s)" 1
c8eeb9df 125
ebac4655 126