From fd58a2ec3c5e5da4f9cfd8f28197397ee9e3783b Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 24 Jan 2007 18:50:00 +0000 Subject: [PATCH] b=10958 r=nathan set y0=0 ymax can be user-specified white background move options before filename --- lustre-iokit/sgpdd-survey/plot-sgpdd | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/lustre-iokit/sgpdd-survey/plot-sgpdd b/lustre-iokit/sgpdd-survey/plot-sgpdd index 06a5eb7..85aa388 100755 --- a/lustre-iokit/sgpdd-survey/plot-sgpdd +++ b/lustre-iokit/sgpdd-survey/plot-sgpdd @@ -15,20 +15,24 @@ # modifications in output format of sgpdd-survey.pl script. # 2. Gnuplot version 4.0 or above is required.] -my @GraphTitle; -sub usage() { - print "Usage: $0 [--rt=] [--wt=]\n"; - print " The $0 parses and plots graph for output of sgpdd-survey.pl using gnuplot,\n"; - print " it generates -.dat and --.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 -.scr\n"; +sub usage() +{ + print STDERR "Usage: $0 [options] \n"; + print STDERR " $0 parses and plots graphs from the output of sgpdd-survey.pl\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,6 +58,13 @@ 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; @@ -68,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; @@ -109,10 +120,10 @@ sub write_dat_file() { } close DATAFILE; } + if ( !$ARGV[0] ) { usage(); } -$file = $ARGV[0]; $region = 0; $thread = 0; $count = 0; @@ -123,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 ( ) { chomp; @line = split( /\s+/ ); -- 1.8.3.1