fio2gnuplot: fix TabErrors when running with Python 3
[fio.git] / tools / plot / fio2gnuplot
CommitLineData
60023ade 1#!/usr/bin/python2.7
50d2a375 2# Note: this script is python2 and python3 compatible.
9402b895
EV
3#
4# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
5# Author: Erwan Velu <erwan@enovance.com>
6#
7# The license below covers all files distributed with fio unless otherwise
8# noted in the file itself.
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License version 2 as
12# published by the Free Software Foundation.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
fa07eaa6 21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9402b895 22
50d2a375
BD
23from __future__ import absolute_import
24from __future__ import print_function
9402b895
EV
25import os
26import fnmatch
27import sys
28import getopt
29import re
30import math
795ae706 31import shutil
50d2a375
BD
32from six.moves import map
33from six.moves import range
9402b895
EV
34
35def find_file(path, pattern):
36 fio_data_file=[]
37 # For all the local files
38 for file in os.listdir(path):
4cbe3909
AK
39 # If the file matches the glob
40 if fnmatch.fnmatch(file, pattern):
41 # Let's consider this file
42 fio_data_file.append(file)
9402b895
EV
43
44 return fio_data_file
45
1cc6579e 46def generate_gnuplot_script(fio_data_file,title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir):
50d2a375 47 if verbose: print("Generating rendering scripts")
5923d3a5 48 filename=gnuplot_output_dir+'mygraph'
590846bd 49 temporary_files.append(filename)
5923d3a5 50 f=open(filename,'w')
795ae706
EV
51
52 # Plotting 3D or comparing graphs doesn't have a meaning unless if there is at least 2 traces
d270b8bc 53 if len(fio_data_file) > 1:
4cbe3909 54 f.write("call \'%s/graph3D.gpm\' \'%s' \'%s\' \'\' \'%s\' \'%s\'\n" % (gpm_dir,title,gnuplot_output_filename,gnuplot_output_filename,mode))
67b7db1e 55
795ae706
EV
56 # Setting up the compare files that will be plot later
57 compare=open(gnuplot_output_dir + 'compare.gnuplot','w')
58 compare.write('''
59set title '%s'
60set terminal png size 1280,1024
61set ytics axis out auto
62set key top left reverse
63set xlabel "Time (Seconds)"
64set ylabel '%s'
795ae706 65set yrange [0:]
b68e5f80 66set style line 1 lt 1 lw 3 pt 3 linecolor rgb "green"
795ae706
EV
67'''% (title,mode))
68 compare.close()
69 #Copying the common file for all kind of graph (raw/smooth/trend)
70 compare_raw_filename="compare-%s-2Draw" % (gnuplot_output_filename)
71 compare_smooth_filename="compare-%s-2Dsmooth" % (gnuplot_output_filename)
72 compare_trend_filename="compare-%s-2Dtrend" % (gnuplot_output_filename)
590846bd 73
795ae706
EV
74 shutil.copy(gnuplot_output_dir+'compare.gnuplot',gnuplot_output_dir+compare_raw_filename+".gnuplot")
75 shutil.copy(gnuplot_output_dir+'compare.gnuplot',gnuplot_output_dir+compare_smooth_filename+".gnuplot")
76 shutil.copy(gnuplot_output_dir+'compare.gnuplot',gnuplot_output_dir+compare_trend_filename+".gnuplot")
590846bd
EV
77 temporary_files.append(gnuplot_output_dir+compare_raw_filename+".gnuplot")
78 temporary_files.append(gnuplot_output_dir+compare_smooth_filename+".gnuplot")
79 temporary_files.append(gnuplot_output_dir+compare_trend_filename+".gnuplot")
795ae706
EV
80
81 #Setting up a different output filename for each kind of graph
82 compare_raw=open(gnuplot_output_dir+compare_raw_filename + ".gnuplot",'a')
83 compare_raw.write("set output '%s.png'\n" % compare_raw_filename)
84 compare_smooth=open(gnuplot_output_dir+compare_smooth_filename+".gnuplot",'a')
85 compare_smooth.write("set output '%s.png'\n" % compare_smooth_filename)
86 compare_trend=open(gnuplot_output_dir+compare_trend_filename+".gnuplot",'a')
87 compare_trend.write("set output '%s.png'\n" % compare_trend_filename)
88
b68e5f80
EV
89 # Let's plot the average value for all the traces
90 global_disk_perf = sum(disk_perf, [])
91 global_avg = average(global_disk_perf)
92 compare_raw.write("plot %s w l ls 1 ti 'Global average value (%.2f)'" % (global_avg,global_avg));
93 compare_smooth.write("plot %s w l ls 1 ti 'Global average value (%.2f)'" % (global_avg,global_avg));
94 compare_trend.write("plot %s w l ls 1 ti 'Global average value (%.2f)'" % (global_avg,global_avg));
95
4cbe3909
AK
96 pos=0
97 # Let's create a temporary file for each selected fio file
98 for file in fio_data_file:
99 tmp_filename = "gnuplot_temp_file.%d" % pos
795ae706
EV
100
101 # Plotting comparing graphs doesn't have a meaning unless if there is at least 2 traces
102 if len(fio_data_file) > 1:
103 # Adding the plot instruction for each kind of comparing graphs
b68e5f80
EV
104 compare_raw.write(",\\\n'%s' using 2:3 with linespoints title '%s'" % (tmp_filename,fio_data_file[pos]))
105 compare_smooth.write(",\\\n'%s' using 2:3 smooth csplines title '%s'" % (tmp_filename,fio_data_file[pos]))
106 compare_trend.write(",\\\n'%s' using 2:3 smooth bezier title '%s'" % (tmp_filename,fio_data_file[pos]))
795ae706
EV
107
108 png_file=file.replace('.log','')
4cbe3909
AK
109 raw_filename = "%s-2Draw" % (png_file)
110 smooth_filename = "%s-2Dsmooth" % (png_file)
111 trend_filename = "%s-2Dtrend" % (png_file)
112 avg = average(disk_perf[pos])
113 f.write("call \'%s/graph2D.gpm\' \'%s' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%s\' \'%f\'\n" % (gpm_dir,title,tmp_filename,fio_data_file[pos],raw_filename,mode,smooth_filename,trend_filename,avg))
114 pos = pos +1
67b7db1e 115
795ae706
EV
116 # Plotting comparing graphs doesn't have a meaning unless if there is at least 2 traces
117 if len(fio_data_file) > 1:
118 os.remove(gnuplot_output_dir+"compare.gnuplot")
119 compare_raw.close()
120 compare_smooth.close()
121 compare_trend.close()
9402b895
EV
122 f.close()
123
1cc6579e 124def generate_gnuplot_math_script(title,gnuplot_output_filename,mode,average,gnuplot_output_dir,gpm_dir):
5923d3a5 125 filename=gnuplot_output_dir+'mymath';
590846bd 126 temporary_files.append(filename)
5923d3a5 127 f=open(filename,'a')
4cbe3909 128 f.write("call \'%s/math.gpm\' \'%s' \'%s\' \'\' \'%s\' \'%s\' %s\n" % (gpm_dir,title,gnuplot_output_filename,gnuplot_output_filename,mode,average))
9402b895
EV
129 f.close()
130
5923d3a5 131def compute_aggregated_file(fio_data_file, gnuplot_output_filename, gnuplot_output_dir):
50d2a375 132 if verbose: print("Processing data file 2/2")
9402b895
EV
133 temp_files=[]
134 pos=0
5923d3a5 135
9402b895
EV
136 # Let's create a temporary file for each selected fio file
137 for file in fio_data_file:
5923d3a5 138 tmp_filename = "%sgnuplot_temp_file.%d" % (gnuplot_output_dir, pos)
9402b895
EV
139 temp_files.append(open(tmp_filename,'r'))
140 pos = pos +1
141
1cc6579e 142 f = open(gnuplot_output_dir+gnuplot_output_filename, "w")
590846bd 143 temporary_files.append(gnuplot_output_dir+gnuplot_output_filename)
9402b895
EV
144 index=0
145 # Let's add some information
146 for tempfile in temp_files:
147 f.write("# Disk%d was coming from %s\n" % (index,fio_data_file[index]))
148 f.write(tempfile.read())
149 f.write("\n")
150 tempfile.close()
151 index = index + 1
152 f.close()
153
154def average(s): return sum(s) * 1.0 / len(s)
155
932f303b
EV
156def compute_temp_file(fio_data_file,disk_perf,gnuplot_output_dir, min_time, max_time):
157 end_time=max_time
158 if end_time == -1:
159 end_time="infinite"
50d2a375 160 if verbose: print("Processing data file 1/2 with %s<time<%s" % (min_time,end_time))
9402b895
EV
161 files=[]
162 temp_outfile=[]
163 blk_size=0
164 for file in fio_data_file:
165 files.append(open(file))
166 pos = len(files) - 1
5923d3a5 167 tmp_filename = "%sgnuplot_temp_file.%d" % (gnuplot_output_dir,pos)
590846bd 168 temporary_files.append(tmp_filename)
09f30f43
EV
169 gnuplot_file=open(tmp_filename,'w')
170 temp_outfile.append(gnuplot_file)
171 gnuplot_file.write("#Temporary file based on file %s\n" % file)
9402b895
EV
172 disk_perf.append([])
173
174 shall_break = False
175 while True:
176 current_line=[]
f9846c39
EV
177 nb_empty_files=0
178 nb_files=len(files)
51d52208
EV
179 for myfile in files:
180 s=myfile.readline().replace(',',' ').split()
9402b895 181 if not s:
f9846c39 182 nb_empty_files+=1
4ff1f2d0 183 s="-1, 0, 0, 0".replace(',',' ').split()
f9846c39
EV
184
185 if (nb_empty_files == nb_files):
9402b895
EV
186 shall_break=True
187 break;
f9846c39 188
9402b895
EV
189 current_line.append(s);
190
191 if shall_break == True:
192 break
193
194 last_time = -1
ffab7c2f 195 index=-1
9402b895 196 perfs=[]
ffab7c2f
EV
197 for line in enumerate(current_line):
198 # Index will be used to remember what file was featuring what value
199 index=index+1
200
201 time, perf, x, block_size = line[1]
9402b895 202 if (blk_size == 0):
32deaac9
EV
203 try:
204 blk_size=int(block_size)
205 except:
50d2a375
BD
206 print("Error while reading the following line :")
207 print(line)
32deaac9 208 sys.exit(1);
9402b895
EV
209
210 # We ignore the first 500msec as it doesn't seems to be part of the real benchmark
211 # Time < 500 usually reports BW=0 breaking the min computing
ffab7c2f
EV
212 if (min_time == 0):
213 min_time==0.5
214
215 # Then we estimate if the data we got is part of the time range we want to plot
216 if ((float(time)>(float(min_time)*1000)) and ((int(time) < (int(max_time)*1000)) or max_time==-1)):
932f303b 217 disk_perf[index].append(int(perf))
ffab7c2f 218 perfs.append("%d %s %s"% (index, time, perf))
9402b895
EV
219
220 # If we reach this point, it means that all the traces are coherent
221 for p in enumerate(perfs):
ffab7c2f
EV
222 index, perf_time,perf = p[1].split()
223 temp_outfile[int(index)].write("%s %.2f %s\n" % (index, float(float(perf_time)/1000), perf))
d7e30e61 224
9402b895
EV
225
226 for file in files:
227 file.close()
228 for file in temp_outfile:
229 file.close()
230 return blk_size
231
1cc6579e 232def compute_math(fio_data_file, title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir):
50d2a375 233 if verbose: print("Computing Maths")
9402b895
EV
234 global_min=[]
235 global_max=[]
5923d3a5
EV
236 average_file=open(gnuplot_output_dir+gnuplot_output_filename+'.average', 'w')
237 min_file=open(gnuplot_output_dir+gnuplot_output_filename+'.min', 'w')
238 max_file=open(gnuplot_output_dir+gnuplot_output_filename+'.max', 'w')
239 stddev_file=open(gnuplot_output_dir+gnuplot_output_filename+'.stddev', 'w')
240 global_file=open(gnuplot_output_dir+gnuplot_output_filename+'.global','w')
590846bd
EV
241 temporary_files.append(gnuplot_output_dir+gnuplot_output_filename+'.average')
242 temporary_files.append(gnuplot_output_dir+gnuplot_output_filename+'.min')
243 temporary_files.append(gnuplot_output_dir+gnuplot_output_filename+'.max')
244 temporary_files.append(gnuplot_output_dir+gnuplot_output_filename+'.stddev')
245 temporary_files.append(gnuplot_output_dir+gnuplot_output_filename+'.global')
9402b895
EV
246
247 min_file.write('DiskName %s\n' % mode)
248 max_file.write('DiskName %s\n'% mode)
249 average_file.write('DiskName %s\n'% mode)
250 stddev_file.write('DiskName %s\n'% mode )
50d2a375 251 for disk in range(len(fio_data_file)):
9402b895 252# print disk_perf[disk]
4cbe3909
AK
253 min_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
254 max_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
255 average_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
256 stddev_file.write("# Disk%d was coming from %s\n" % (disk,fio_data_file[disk]))
9402b895 257 avg = average(disk_perf[disk])
50d2a375 258 variance = [(x - avg)**2 for x in disk_perf[disk]]
9402b895
EV
259 standard_deviation = math.sqrt(average(variance))
260# print "Disk%d [ min=%.2f max=%.2f avg=%.2f stddev=%.2f \n" % (disk,min(disk_perf[disk]),max(disk_perf[disk]),avg, standard_deviation)
261 average_file.write('%d %d\n' % (disk, avg))
262 stddev_file.write('%d %d\n' % (disk, standard_deviation))
263 local_min=min(disk_perf[disk])
264 local_max=max(disk_perf[disk])
265 min_file.write('%d %d\n' % (disk, local_min))
266 max_file.write('%d %d\n' % (disk, local_max))
267 global_min.append(int(local_min))
268 global_max.append(int(local_max))
269
270 global_disk_perf = sum(disk_perf, [])
271 avg = average(global_disk_perf)
50d2a375 272 variance = [(x - avg)**2 for x in global_disk_perf]
9402b895
EV
273 standard_deviation = math.sqrt(average(variance))
274
275 global_file.write('min=%.2f\n' % min(global_disk_perf))
276 global_file.write('max=%.2f\n' % max(global_disk_perf))
277 global_file.write('avg=%.2f\n' % avg)
278 global_file.write('stddev=%.2f\n' % standard_deviation)
279 global_file.write('values_count=%d\n' % len(global_disk_perf))
280 global_file.write('disks_count=%d\n' % len(fio_data_file))
281 #print "Global [ min=%.2f max=%.2f avg=%.2f stddev=%.2f \n" % (min(global_disk_perf),max(global_disk_perf),avg, standard_deviation)
282
283 average_file.close()
284 min_file.close()
285 max_file.close()
286 stddev_file.close()
287 global_file.close()
288 try:
1cc6579e 289 os.remove(gnuplot_output_dir+'mymath')
9402b895
EV
290 except:
291 True
292
1cc6579e
EV
293 generate_gnuplot_math_script("Average values of "+title,gnuplot_output_filename+'.average',mode,int(avg),gnuplot_output_dir,gpm_dir)
294 generate_gnuplot_math_script("Min values of "+title,gnuplot_output_filename+'.min',mode,average(global_min),gnuplot_output_dir,gpm_dir)
295 generate_gnuplot_math_script("Max values of "+title,gnuplot_output_filename+'.max',mode,average(global_max),gnuplot_output_dir,gpm_dir)
296 generate_gnuplot_math_script("Standard Deviation of "+title,gnuplot_output_filename+'.stddev',mode,int(standard_deviation),gnuplot_output_dir,gpm_dir)
9402b895
EV
297
298def parse_global_files(fio_data_file, global_search):
299 max_result=0
300 max_file=''
301 for file in fio_data_file:
302 f=open(file)
303 disk_count=0
304 search_value=-1
305
306 # Let's read the complete file
307 while True:
308 try:
309 # We do split the name from the value
310 name,value=f.readline().split("=")
311 except:
312 f.close()
313 break
314 # If we ended the file
315 if not name:
316 # Let's process what we have
317 f.close()
318 break
319 else:
320 # disks_count is not global_search item
321 # As we need it for some computation, let's save it
322 if name=="disks_count":
323 disks_count=int(value)
324
325 # Let's catch the searched item
326 if global_search in name:
327 search_value=float(value)
328
329 # Let's process the avg value by estimated the global bandwidth per file
330 # We keep the biggest in memory for reporting
331 if global_search == "avg":
332 if (disks_count > 0) and (search_value != -1):
333 result=disks_count*search_value
334 if (result > max_result):
335 max_result=result
336 max_file=file
337 # Let's print the avg output
338 if global_search == "avg":
50d2a375 339 print("Biggest aggregated value of %s was %2.f in file %s\n" % (global_search, max_result, max_file))
9402b895 340 else:
50d2a375 341 print("Global search %s is not yet implemented\n" % global_search)
9402b895 342
795ae706 343def render_gnuplot(fio_data_file, gnuplot_output_dir):
50d2a375 344 print("Running gnuplot Rendering")
9402b895 345 try:
795ae706
EV
346 # Let's render all the compared files if some
347 if len(fio_data_file) > 1:
50d2a375 348 if verbose: print(" |-> Rendering comparing traces")
795ae706 349 os.system("cd %s; for i in *.gnuplot; do gnuplot $i; done" % gnuplot_output_dir)
50d2a375 350 if verbose: print(" |-> Rendering math traces")
5923d3a5 351 os.system("cd %s; gnuplot mymath" % gnuplot_output_dir)
50d2a375 352 if verbose: print(" |-> Rendering 2D & 3D traces")
5923d3a5 353 os.system("cd %s; gnuplot mygraph" % gnuplot_output_dir)
d0b4ba6c
EV
354
355 name_of_directory="the current"
356 if gnuplot_output_dir != "./":
357 name_of_directory=gnuplot_output_dir
50d2a375 358 print("\nRendering traces are available in %s directory" % name_of_directory)
2fa23380
EV
359 global keep_temp_files
360 keep_temp_files=False
9402b895 361 except:
50d2a375 362 print("Could not run gnuplot on mymath or mygraph !\n")
9402b895
EV
363 sys.exit(1);
364
365def print_help():
50d2a375
BD
366 print('fio2gnuplot -ghbiodvk -t <title> -o <outputfile> -p <pattern> -G <type> -m <time> -M <time>')
367 print()
368 print('-h --help : Print this help')
369 print('-p <pattern> or --pattern <pattern> : A glob pattern to select fio input files')
370 print('-b or --bandwidth : A predefined pattern for selecting *_bw.log files')
371 print('-i or --iops : A predefined pattern for selecting *_iops.log files')
372 print('-g or --gnuplot : Render gnuplot traces before exiting')
373 print('-o or --outputfile <file> : The basename for gnuplot traces')
374 print(' - Basename is set with the pattern if defined')
375 print('-d or --outputdir <dir> : The directory where gnuplot shall render files')
376 print('-t or --title <title> : The title of the gnuplot traces')
377 print(' - Title is set with the block size detected in fio traces')
378 print('-G or --Global <type> : Search for <type> in .global files match by a pattern')
379 print(' - Available types are : min, max, avg, stddev')
380 print(' - The .global extension is added automatically to the pattern')
381 print('-m or --min_time <time> : Only consider data starting from <time> seconds (default is 0)')
382 print('-M or --max_time <time> : Only consider data ending before <time> seconds (default is -1 aka nolimit)')
383 print('-v or --verbose : Increasing verbosity')
384 print('-k or --keep : Keep all temporary files from gnuplot\'s output dir')
9402b895
EV
385
386def main(argv):
387 mode='unknown'
388 pattern=''
389 pattern_set_by_user=False
390 title='No title'
391 gnuplot_output_filename='result'
5923d3a5 392 gnuplot_output_dir='./'
1cc6579e 393 gpm_dir="/usr/share/fio/"
9402b895
EV
394 disk_perf=[]
395 run_gnuplot=False
396 parse_global=False
397 global_search=''
932f303b
EV
398 min_time=0
399 max_time=-1
649d3011
EV
400 global verbose
401 verbose=False
590846bd
EV
402 global temporary_files
403 temporary_files=[]
2fa23380
EV
404 global keep_temp_files
405 keep_temp_files=True
406 force_keep_temp_files=False
9402b895 407
1cc6579e 408 if not os.path.isfile(gpm_dir+'math.gpm'):
4cbe3909
AK
409 gpm_dir="/usr/local/share/fio/"
410 if not os.path.isfile(gpm_dir+'math.gpm'):
411 print("Looks like fio didn't get installed properly as no gpm files found in '/usr/share/fio' or '/usr/local/share/fio'\n")
412 sys.exit(3)
1cc6579e 413
9402b895 414 try:
4cbe3909 415 opts, args = getopt.getopt(argv[1:],"ghkbivo:d:t:p:G:m:M:",['bandwidth', 'iops', 'pattern', 'outputfile', 'outputdir', 'title', 'min_time', 'max_time', 'gnuplot', 'Global', 'help', 'verbose','keep'])
9402b895 416 except getopt.GetoptError:
4cbe3909
AK
417 print("Error: One of the options passed to the cmdline was not supported")
418 print("Please fix your command line or read the help (-h option)")
419 sys.exit(2)
9402b895
EV
420
421 for opt, arg in opts:
4cbe3909
AK
422 if opt in ("-b", "--bandwidth"):
423 pattern='*_bw.log'
424 elif opt in ("-i", "--iops"):
425 pattern='*_iops.log'
426 elif opt in ("-v", "--verbose"):
427 verbose=True
428 elif opt in ("-k", "--keep"):
429 #User really wants to keep the temporary files
430 force_keep_temp_files=True
431 elif opt in ("-p", "--pattern"):
432 pattern_set_by_user=True
433 pattern=arg
434 pattern=pattern.replace('\\','')
435 elif opt in ("-o", "--outputfile"):
436 gnuplot_output_filename=arg
437 elif opt in ("-d", "--outputdir"):
438 gnuplot_output_dir=arg
439 if not gnuplot_output_dir.endswith('/'):
440 gnuplot_output_dir=gnuplot_output_dir+'/'
441 if not os.path.exists(gnuplot_output_dir):
442 os.makedirs(gnuplot_output_dir)
443 elif opt in ("-t", "--title"):
444 title=arg
445 elif opt in ("-m", "--min_time"):
446 min_time=arg
447 elif opt in ("-M", "--max_time"):
448 max_time=arg
449 elif opt in ("-g", "--gnuplot"):
450 run_gnuplot=True
451 elif opt in ("-G", "--Global"):
452 parse_global=True
453 global_search=arg
454 elif opt in ("-h", "--help"):
455 print_help()
456 sys.exit(1)
9402b895
EV
457
458 # Adding .global extension to the file
459 if parse_global==True:
4cbe3909
AK
460 if not gnuplot_output_filename.endswith('.global'):
461 pattern = pattern+'.global'
9402b895
EV
462
463 fio_data_file=find_file('.',pattern)
464 if len(fio_data_file) == 0:
4cbe3909
AK
465 print("No log file found with pattern %s!" % pattern)
466 # Try numjob log file format if per_numjob_logs=1
467 if (pattern == '*_bw.log'):
468 fio_data_file=find_file('.','*_bw.*.log')
469 if (pattern == '*_iops.log'):
470 fio_data_file=find_file('.','*_iops.*.log')
471 if len(fio_data_file) == 0:
472 sys.exit(1)
473 else:
474 print("Using log file per job format instead")
356a65dd 475 else:
4cbe3909 476 print("%d files Selected with pattern '%s'" % (len(fio_data_file), pattern))
9402b895
EV
477
478 fio_data_file=sorted(fio_data_file, key=str.lower)
479 for file in fio_data_file:
4cbe3909
AK
480 print(' |-> %s' % file)
481 if "_bw.log" in file :
482 mode="Bandwidth (KB/sec)"
483 if "_iops.log" in file :
484 mode="IO per Seconds (IO/sec)"
9402b895 485 if (title == 'No title') and (mode != 'unknown'):
4cbe3909
AK
486 if "Bandwidth" in mode:
487 title='Bandwidth benchmark with %d fio results' % len(fio_data_file)
488 if "IO" in mode:
489 title='IO benchmark with %d fio results' % len(fio_data_file)
9402b895 490
50d2a375 491 print()
9402b895
EV
492 #We need to adjust the output filename regarding the pattern required by the user
493 if (pattern_set_by_user == True):
4cbe3909
AK
494 gnuplot_output_filename=pattern
495 # As we do have some glob in the pattern, let's make this simpliest
496 # We do remove the simpliest parts of the expression to get a clear file name
497 gnuplot_output_filename=gnuplot_output_filename.replace('-*-','-')
498 gnuplot_output_filename=gnuplot_output_filename.replace('*','-')
499 gnuplot_output_filename=gnuplot_output_filename.replace('--','-')
500 gnuplot_output_filename=gnuplot_output_filename.replace('.log','')
501 # Insure that we don't have any starting or trailing dash to the filename
502 gnuplot_output_filename = gnuplot_output_filename[:-1] if gnuplot_output_filename.endswith('-') else gnuplot_output_filename
503 gnuplot_output_filename = gnuplot_output_filename[1:] if gnuplot_output_filename.startswith('-') else gnuplot_output_filename
504 if (gnuplot_output_filename == ''):
505 gnuplot_output_filename='default'
9402b895
EV
506
507 if parse_global==True:
4cbe3909 508 parse_global_files(fio_data_file, global_search)
9402b895 509 else:
4cbe3909
AK
510 blk_size=compute_temp_file(fio_data_file,disk_perf,gnuplot_output_dir,min_time,max_time)
511 title="%s @ Blocksize = %dK" % (title,blk_size/1024)
512 compute_aggregated_file(fio_data_file, gnuplot_output_filename, gnuplot_output_dir)
513 compute_math(fio_data_file,title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir)
514 generate_gnuplot_script(fio_data_file,title,gnuplot_output_filename,gnuplot_output_dir,mode,disk_perf,gpm_dir)
515
516 if (run_gnuplot==True):
517 render_gnuplot(fio_data_file, gnuplot_output_dir)
518
519 # Shall we clean the temporary files ?
520 if keep_temp_files==False and force_keep_temp_files==False:
521 # Cleaning temporary files
522 if verbose: print("Cleaning temporary files")
523 for f in enumerate(temporary_files):
524 if verbose: print(" -> %s"%f[1])
525 try:
526 os.remove(f[1])
527 except:
528 True
9402b895
EV
529
530#Main
531if __name__ == "__main__":
532 sys.exit(main(sys.argv))