fio2gnuplot: Plotting average value for compare graphs
authorErwan Velu <erwan@enovance.com>
Fri, 2 Aug 2013 12:16:14 +0000 (14:16 +0200)
committerErwan Velu <erwan@enovance.com>
Mon, 5 Aug 2013 15:09:59 +0000 (17:09 +0200)
When comparing in 2D several plots, it's pretty useful to have the
average value printed in the same graph.

tools/plot/fio2gnuplot.py

index efd9681048ab19fd760d25bf34d534a49c017c67..64b41c184897bf387bc3a6133abc04602a971445 100755 (executable)
@@ -57,6 +57,7 @@ set key top left reverse
 set xlabel "Time (Seconds)"
 set ylabel '%s'
 set yrange [0:]
+set style line 1 lt 1 lw 3 pt 3 linecolor rgb "green"
 '''% (title,mode))
                compare.close()
                #Copying the common file for all kind of graph (raw/smooth/trend)
@@ -75,6 +76,13 @@ set yrange [0:]
                compare_trend=open(gnuplot_output_dir+compare_trend_filename+".gnuplot",'a')
                compare_trend.write("set output '%s.png'\n" % compare_trend_filename)
 
+               # Let's plot the average value for all the traces
+               global_disk_perf = sum(disk_perf, [])
+               global_avg  = average(global_disk_perf)
+               compare_raw.write("plot %s w l ls 1 ti 'Global average value (%.2f)'" % (global_avg,global_avg));
+               compare_smooth.write("plot %s w l ls 1 ti 'Global average value (%.2f)'" % (global_avg,global_avg));
+               compare_trend.write("plot %s w l ls 1 ti 'Global average value (%.2f)'" % (global_avg,global_avg));
+
         pos=0
         # Let's create a temporary file for each selected fio file
         for file in fio_data_file:
@@ -83,14 +91,9 @@ set yrange [0:]
                # Plotting comparing graphs doesn't have a meaning unless if there is at least 2 traces
                if len(fio_data_file) > 1:
                        # Adding the plot instruction for each kind of comparing graphs
-                       if pos ==0 :
-                               compare_raw.write("plot '%s' using 2:3 with linespoints title '%s'" % (tmp_filename,fio_data_file[pos]))
-                               compare_smooth.write("plot '%s' using 2:3 smooth csplines title '%s'" % (tmp_filename,fio_data_file[pos]))
-                               compare_trend.write("plot '%s' using 2:3 smooth bezier title '%s'" % (tmp_filename,fio_data_file[pos]))
-                       else:
-                               compare_raw.write(",\\\n'%s' using 2:3 with linespoints title '%s'" % (tmp_filename,fio_data_file[pos]))
-                               compare_smooth.write(",\\\n'%s' using 2:3 smooth csplines title '%s'" % (tmp_filename,fio_data_file[pos]))
-                               compare_trend.write(",\\\n'%s' using 2:3 smooth bezier title '%s'" % (tmp_filename,fio_data_file[pos]))
+                       compare_raw.write(",\\\n'%s' using 2:3 with linespoints title '%s'" % (tmp_filename,fio_data_file[pos]))
+                       compare_smooth.write(",\\\n'%s' using 2:3 smooth csplines title '%s'" % (tmp_filename,fio_data_file[pos]))
+                       compare_trend.write(",\\\n'%s' using 2:3 smooth bezier title '%s'" % (tmp_filename,fio_data_file[pos]))
 
                png_file=file.replace('.log','')
                 raw_filename = "%s-2Draw" % (png_file)