Whamcloud - gitweb
Removing IOR tarball
[fs/lustre-release.git] / lustre-iokit / ior-survey / parse-ior.pl
1 #!/usr/bin/perl -w
2
3 # arg 0 is filename 
4
5 sub usages_msg(){
6         print "Usage: $0 <results_filename>\n";
7         print "  parses and plots IOR results using gnuplot, and generates a .dat file for\n";
8         print "  simple graphing in spreadhseets\n";
9         print "e.g.> perl parse-ior.pl ior-log\n";
10         exit 1;
11 }
12  
13 if ( !$ARGV[0] ) {
14         usages_msg();   
15 }
16 $file = $ARGV[0];
17
18 # Open log file for reading
19 open ( PFILE, "$file") or die "Can't open results log file";
20 # Open .csv file for writting required columns from log file.
21 open ( DATAFILE, "> $file.dat" ) or die "Can't open csv file for writting";
22 $count = 0;
23 while ( <PFILE> ) {
24         chomp;
25         @line = split( /\s+/ ); # splits line into tokens
26         if ( $line[0] ) {
27                 # This comparison will be changed if there will be changes log file.
28                 if( $line[0] eq "access" && $line[1] eq "bw(MiB/s)" ) { 
29                         print DATAFILE "$count $line[1] $line[4] $line[5] $line[6] br(MiB/s) ropen(s) rd(s) rclose(s)\n";
30                         $count = $count + 1;                    
31                 }               
32                 # Two columns from output file are skiped since 
33                 # they are constant and may not be so useful while graphing results.
34                 if( $line[0] eq "write" ) {
35                         print DATAFILE "$count $line[1] $line[4] $line[5] $line[6] ";
36                 }               
37                 if( $line[0] eq "read" ) {
38                         print DATAFILE "$line[1] $line[4] $line[5] $line[6]\n";
39                         $count = $count + 1;
40                 }               
41         }
42 }
43 close PFILE;
44 close DATAFILE;
45
46 # Open .scr file for writting instructions for gnuplot.
47 open ( SCRFILE, "> $file.scr" ) or die "Can't open scr file for writting";
48 # Only two columns bw(MiB/s) and br(MiB/s) are considered for graphing results.
49 print SCRFILE "plot \"$file.dat\" using 1:2 axes x1y1 title \"bw(MiB/s)\" with line\n";
50 print SCRFILE "replot \"$file.dat\" using 1:6 axes x1y1 title \"br(MiB/s)\" with line\n";
51 print SCRFILE "pause -1\n";
52 close SCRFILE;
53 # check whether gnuplot exists?
54 system ("which gnuplot > /dev/null") == 0 or die "gnuplot does not exists, Please install it and try again.\n";
55 # invoke gnuplot to display graph.
56 system ("gnuplot $file.scr");