From b35c036c8db9ece002b019f4a462a303ceb130fa Mon Sep 17 00:00:00 2001 From: Louwrentius Date: Fri, 24 May 2013 07:56:38 +0200 Subject: [PATCH] Rework fio_generate_plots script Signed-off-by: Jens Axboe --- fio_generate_plots | 201 ++++++++++++++++++++++++--------------------- 1 file changed, 106 insertions(+), 95 deletions(-) diff --git a/fio_generate_plots b/fio_generate_plots index 5e2febda..f65a326c 100755 --- a/fio_generate_plots +++ b/fio_generate_plots @@ -1,115 +1,126 @@ -#! /bin/sh - -# Use gnuplot to generate plots from fio run with -l and/or -w - -if [ "$1"x = "x" ]; then - echo "Usage: fio_generate_plots title [xres yres]" +#!/bin/sh +# +# This script is an almost total rewrite by Louwrentius +# of the original fio_generate_plots script provided as part of the FIO storage +# benchmark utiliy. I only retained how GNUplot is used to generate graphs, as +# that is something I know nothing about. +# +# The script uses the files generated by FIO to create nice graphs in the +# SVG format. This output format is supported by most modern browsers and +# allows resolution independant graphs to be generated. +# +# This script supports GNUPLOT 4.4 and higher. +# +# Version 1.0 @ 20121231 +# +# +# + +if [ -z "$1" ]; then + echo "Usage: fio_generate_plots subtitle [xres yres]" exit 1 fi GNUPLOT=$(which gnuplot) -if [ ! -x "$GNUPLOT" ]; then +if [ ! -x $GNUPLOT ] +then echo You need gnuplot installed to generate graphs exit 1 fi -TITLE=$1 +TITLE="$1" # set resolution -if [ "$2"x != "x" -a "$3"x != "x" ]; then +if [ ! -z "$2" ] && [ ! -z "$3" ] +then XRES="$2" YRES="$3" else - XRES=1024 + XRES=1280 YRES=768 fi -PLOT_LINE="" -for i in *bw.log; do - if [ ! -r $i ]; then - continue - fi - PT=$(echo $i | sed s/_bw.log//g) - if [ "$PLOT_LINE"x != "x" ]; then - PLOT_LINE=$PLOT_LINE", " - fi - - PLOT_LINE=$PLOT_LINE"'$i' title '$PT' with lines" -done - -if [ "$PLOT_LINE"x != "x" ]; then - echo Making bw logs - echo "set title 'Bandwidth - $TITLE'; set xlabel 'time (msec)'; set ylabel 'KB/sec'; set terminal png size $XRES,$YRES; set output '$TITLE-bw.png'; plot " $PLOT_LINE | $GNUPLOT - +if [ -z "$SAMPLE_DURATION" ] +then + SAMPLE_DURATION="*" fi -PLOT_LINE="" -for i in *iops.log; do - if [ ! -r $i ]; then - continue - fi - PT=$(echo $i | sed s/_iops.log//g) - if [ "$PLOT_LINE"x != "x" ]; then - PLOT_LINE=$PLOT_LINE", " - fi - - PLOT_LINE=$PLOT_LINE"'$i' title '$PT' with lines" -done - -if [ "$PLOT_LINE"x != "x" ]; then - echo Making bw logs - echo "set title 'IOPS - $TITLE'; set xlabel 'time (msec)'; set ylabel 'IOPS'; set terminal png size $XRES,$YRES; set output '$TITLE-IOPS.png'; plot " $PLOT_LINE | $GNUPLOT - -fi +DEFAULT_GRID_LINE_TYPE=3 +DEFAULT_LINE_WIDTH=2 +DEFAULT_LINE_COLORS=" +set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb\"#ffffff\" behind +set style line 1 lc rgb \"#E41A1C\" lw $DEFAULT_LINE_WIDTH lt 1; +set style line 2 lc rgb \"#377EB8\" lw $DEFAULT_LINE_WIDTH lt 1; +set style line 3 lc rgb \"#4DAF4A\" lw $DEFAULT_LINE_WIDTH lt 1; +set style line 4 lc rgb \"#984EA3\" lw $DEFAULT_LINE_WIDTH lt 1; +set style line 5 lc rgb \"#FF7F00\" lw $DEFAULT_LINE_WIDTH lt 1; +set style line 6 lc rgb \"#DADA33\" lw $DEFAULT_LINE_WIDTH lt 1; +set style line 7 lc rgb \"#A65628\" lw $DEFAULT_LINE_WIDTH lt 1; +set style line 20 lc rgb \"#000000\" lt $DEFAULT_GRID_LINE_TYPE lw $DEFAULT_LINE_WIDTH; +" + +DEFAULT_TERMINAL="set terminal svg enhanced dashed size $XRES,$YRES dynamic" +DEFAULT_TITLE_FONT="\"Helvetica,28\"" +DEFAULT_AXIS_FONT="\"Helvetica,14\"" +DEFAULT_AXIS_LABEL_FONT="\"Helvetica,16\"" +DEFAULT_XLABEL="set xlabel \"Time (sec)\" font $DEFAULT_AXIS_LABEL_FONT" +DEFAULT_XTIC="set xtics font $DEFAULT_AXIS_FONT" +DEFAULT_YTIC="set ytics font $DEFAULT_AXIS_FONT" +DEFAULT_MXTIC="set mxtics 0" +DEFAULT_MYTIC="set mytics 2" +DEFAULT_XRANGE="set xrange [0:$SAMPLE_DURATION]" +DEFAULT_YRANGE="set yrange [0:*]" +DEFAULT_GRID="set grid ls 20" +DEFAULT_KEY="set key outside bottom center ; set key box enhanced spacing 2.0 samplen 3 horizontal width 4 height 1.2 " +DEFAULT_SOURCE="set label 30 \"Data source: http://example.com\" font $DEFAULT_AXIS_FONT tc rgb \"#00000f\" at screen 0.976,0.175 right" +DEFAULT_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" + +plot () { + + if [ -z "$TITLE" ] + then + PLOT_TITLE=" set title \"$1\" font $DEFAULT_TITLE_FONT" + else + PLOT_TITLE=" set title \"$TITLE\\\n\\\n{/*0.6 "$1"}\" font $DEFAULT_TITLE_FONT" + fi + FILETYPE="$2" + YAXIS="set ylabel \"$3\" font $DEFAULT_AXIS_LABEL_FONT" + SCALE=$4 + + echo "Title: $PLOT_TITLE" + echo "File type: $FILETYPE" + echo "yaxis: $YAXIS" + + i=0 + + for x in *_"$FILETYPE".log + do + i=$((i+1)) + PT=$(echo $x | sed s/_"$FILETYPE".log//g) + if [ ! -z "$PLOT_LINE" ] + then + PLOT_LINE=$PLOT_LINE", " + fi + + DEPTH=$(echo $PT | cut -d "-" -f 4) + PLOT_LINE=$PLOT_LINE"'$x' using (\$1/1000):(\$2/$SCALE) title \"Queue depth $DEPTH\" with lines ls $i" + + done + + OUTPUT="set output \"$TITLE-$FILETYPE.svg\" " + + echo " $PLOT_TITLE ; $YAXIS ; $DEFAULT_OPTS ; show style lines ; $OUTPUT ; plot " $PLOT_LINE | $GNUPLOT - + unset PLOT_LINE +} + +# +# plot +# + +plot "I/O Latency" lat "Time (msec)" 1000 +plot "I/O Operations Per Second" iops "IOPS" 1 +plot "I/O Submission Latency" slat "Time (μsec)" 1 +plot "I/O Completion Latency" clat "Time (msec)" 1000 +plot "I/O Bandwidth" bw "Throughput (KB/s)" 1 -PLOT_LINE="" -for i in *slat.log; do - if [ ! -r $i ]; then - continue - fi - PT=$(echo $i | sed s/_slat.log//g) - if [ "$PLOT_LINE"x != "x" ]; then - PLOT_LINE=$PLOT_LINE", " - fi - - PLOT_LINE=$PLOT_LINE"'$i' title '$PT' with lines" -done - -if [ "$PLOT_LINE"x != "x" ]; then - echo Making slat logs $PLOT_LINE - echo "set title 'Submission latency - $TITLE'; set xlabel 'time (msec)'; set ylabel 'latency (msec)'; set terminal png size $XRES,$YRES; set output '$TITLE-slat.png'; plot " $PLOT_LINE | $GNUPLOT - -fi -PLOT_LINE="" -for i in *clat.log; do - if [ ! -r $i ]; then - continue - fi - PT=$(echo $i | sed s/_clat.log//g) - if [ "$PLOT_LINE"x != "x" ]; then - PLOT_LINE=$PLOT_LINE", " - fi - - PLOT_LINE=$PLOT_LINE"'$i' title '$PT' with lines" -done - -if [ "$PLOT_LINE"x != "x" ]; then - echo Making clat logs $PLOT_LINE - echo "set title 'Completion latency - $TITLE'; set xlabel 'time (msec)'; set ylabel 'latency (msec)'; set terminal png size $XRES,$YRES; set output '$TITLE-clat.png'; plot " $PLOT_LINE | $GNUPLOT - -fi - -PLOT_LINE="" -for i in *_lat.log; do - if [ ! -r $i ]; then - continue - fi - PT=$(echo $i | sed s/_lat.log//g) - if [ "$PLOT_LINE"x != "x" ]; then - PLOT_LINE=$PLOT_LINE", " - fi - - PLOT_LINE=$PLOT_LINE"'$i' title '$PT' with lines" -done - -if [ "$PLOT_LINE"x != "x" ]; then - echo Making lat logs $PLOT_LINE - echo "set title 'Latency - $TITLE'; set xlabel 'time (msec)'; set ylabel 'latency (msec)'; set terminal png size $XRES,$YRES; set output '$TITLE-lat.png'; plot " $PLOT_LINE | $GNUPLOT - -fi -- 2.25.1