Whamcloud - gitweb
b=11171
[fs/lustre-release.git] / lustre-iokit / sgpdd-survey / plot-sgpdd
index 36d95aa..8b5d8b8 100755 (executable)
@@ -2,7 +2,7 @@
 # Report generation for plot-sgpdd
 # ================================
 #        The plot-sgpdd script is used to generate csv file and
-# instructions files for gnuplot from the output of sgpdd-survey.pl script.
+# instructions files for gnuplot from the output of sgpdd-survey script.
 #
 #        The plot-sgpdd also creates .scr file that contains instructions
 # for gnuplot to plot the graph. After generating .dat and .scr files this
 # $ sgpdd-survey > log_filename
 # $ plot-sgpdd <log_filename>
 # [Note: 1. This script may need modifications whenever there will be
-#           modifications in output format of sgpdd-survey.pl script.
+#           modifications in output format of sgpdd-survey script.
 #        2. Gnuplot version 4.0 or above is required.]
 
-my @GraphTitle;
-sub usage() {
-       print "Usage: $0 <log_filename> [--rt=<read title>] [--wt=<write title>]\n";
-       print "       The $0 parses and plots graph for output of sgpdd-survey.pl using gnuplot,\n";
-       print "       it generates <log_filename>-<Rsize><rd/wr>.dat and <log_filename>-<Rsize>-<rd/wr>.scr files\n";
-       print "       those will be used for graphing the results\n";
-       print "e.g.   # perl $0 sgpdd-log \"8 devices, chunk = 256\"\n";
-       print "       # gnuplot <log_filename>-<Rsize>.scr\n";
+sub usage() 
+{
+       print STDERR "Usage: $0 [options] <log_filename>\n";
+       print STDERR "  $0 parses and plots graphs from the output of sgpdd-survey\n";
+       print STDERR "  It generates text data files (.dat) and graphs (.png) using gnuplot.\n";
+       print STDERR "options:\n";
+       print STDERR "  --rt: Subtitle for read graphs\n";
+       print STDERR "  --wt: Subtitle for write graphs\n";
+       print STDERR "  --y: Y-axis scale\n";
+       print STDERR "e.g. # $0 --rt=\"no prefetch\" --wt=\"WB disabled\" --y=500 sgpdd.summary\n";
        exit 1;
 }
 
 # check whether gnuplot exists?
 system ("which gnuplot > /dev/null") == 0 or die "gnuplot does not exist, please install it and try again.\n";
 
+my @GraphTitle;
+
 #Subroutine to write .scr file that further used by gnuplot to plot the graph.
 sub write_scr_file() {
        my $op = $_[0];
@@ -54,14 +58,18 @@ sub write_scr_file() {
        print SCRFILE "set xlabel \"Threads\"\n";
        print SCRFILE "set ylabel \"Speeds(MB/s)\"\n";
        print SCRFILE "set logscale x\n";
+       print SCRFILE "set grid\n";
+       if ($opt_y != 0) {
+               print SCRFILE "set yrange [ 0:$opt_y ]\n";
+       } else {
+               print SCRFILE "set yrange [ 0: ]\n";
+       }
+
        my $plot = "plot";
        $i = 2;
        $xrange = 1;
        # generate instructions for gnuplot, with adjusting X-axes ranges
        for ($j = 1; $j <= $thread ; $j = $j + $j) {
-               if ($j > 15 ) {
-                       $xrange = 2;
-               }
                if ($op eq "wr") {
                        printf SCRFILE "$plot \"$file-$rsz-$op.dat\" using 1:$i axes x%dy1 title \"write$j\" with line\n", $xrange;
                }
@@ -71,7 +79,7 @@ sub write_scr_file() {
                $i++;
                $plot = "replot";
        }
-       #print SCRFILE "set terminal png transparent\n";
+       print SCRFILE "set terminal png\n";
        print SCRFILE "set output \"$file-$rsz-$op.png\"\n";
        print SCRFILE "replot\n";
        close SCRFILE;
@@ -112,10 +120,10 @@ sub write_dat_file() {
        }
        close DATAFILE;
 }
+
 if ( !$ARGV[0] ) {
        usage();
 }
-$file = $ARGV[0];
 $region = 0;
 $thread = 0;
 $count = 0;
@@ -126,13 +134,16 @@ $readop = 0;
 $rsz = 0;
 $opt_rdtitle = "";
 $opt_wrtitle = "";
+$opt_y = 0;
 # Command line parameter parsing
 use Getopt::Long;
-GetOptions ('help' => \$opt_help, 'rt=s' => \$opt_rdtitle, 'wt=s' => \$opt_wrtitle) or usage(); 
+GetOptions ('help' => \$opt_help, 'rt=s' => \$opt_rdtitle, 'wt=s' => \$opt_wrtitle, 'y=i' => \$opt_y) or usage(); 
 if ($opt_help) {
        usage();
 }
-open ( PFILE, "$file") or die "Can't open results";
+$file = $ARGV[0];
+
+open ( PFILE, "$file") or die "Can't open $file";
 LABEL: while ( <PFILE> ) {
        chomp;
        @line = split( /\s+/ );