fio2gnuplot: Don't plot fake data
[fio.git] / tools / plot / fio2gnuplot.py
index c1a5cfb0a1d94ed6a5016abb51af95a571a14bd1..03ef0ddab98e1fbbf581180d2eddb514aef9f529 100755 (executable)
@@ -39,7 +39,8 @@ def find_file(path, pattern):
 
 def generate_gnuplot_script(fio_data_file,title,gnuplot_output_filename,mode,disk_perf):
        f=open("mygraph",'w')
-        f.write("call \'graph3D.gpm\' \'%s' \'%s\' \'\' \'%s\' \'%s\'\n" % (title,gnuplot_output_filename,gnuplot_output_filename,mode))
+       if len(fio_data_file) > 1:
+               f.write("call \'graph3D.gpm\' \'%s' \'%s\' \'\' \'%s\' \'%s\'\n" % (title,gnuplot_output_filename,gnuplot_output_filename,mode))
 
         pos=0
         # Let's create a temporary file for each selected fio file
@@ -90,17 +91,26 @@ def compute_temp_file(fio_data_file,disk_perf):
                files.append(open(file))
                pos = len(files) - 1
                tmp_filename = "gnuplot_temp_file.%d" % pos
-               temp_outfile.append(open(tmp_filename,'w'))
+               gnuplot_file=open(tmp_filename,'w')
+               temp_outfile.append(gnuplot_file)
+               gnuplot_file.write("#Temporary file based on file %s\n" % file)
                disk_perf.append([])
 
        shall_break = False
        while True:
                current_line=[]
+               nb_empty_files=0
+               nb_files=len(files)
                for file in files:
                        s=file.readline().replace(',',' ').split()
                        if not s:
+                               nb_empty_files+=1
+                               s="-1, 0, 0, 0'".replace(',',' ').split()
+
+                       if (nb_empty_files == nb_files):
                                shall_break=True
                                break;
+
                        current_line.append(s);
 
                if shall_break == True:
@@ -116,14 +126,17 @@ def compute_temp_file(fio_data_file,disk_perf):
 
                        # We ignore the first 500msec as it doesn't seems to be part of the real benchmark
                        # Time < 500 usually reports BW=0 breaking the min computing
-                       if ((int(time)) > 500):
+                       if (((int(time)) > 500) or (int(time)==-1)):
                                disk_perf[index].append(int(perf))
-                               perfs.append(perf)
+                               perfs.append("%s %s"% (time, perf))
                                index = index + 1
 
                # If we reach this point, it means that all the traces are coherent
                for p in enumerate(perfs):
-                       temp_outfile[p[0]].write("%s %.2f %s\n" % (p[0], float(float(time)/1000), p[1]))
+                       perf_time,perf = p[1].split()
+                       if (perf_time != "-1"):
+                               temp_outfile[p[0]].write("%s %.2f %s\n" % (p[0], float(float(perf_time)/1000), perf))
+
 
        for file in files:
                file.close()