2 # Report generation for plot-sgpdd.pl
3 # ===================================
4 # The plot-sgpdd.pl script is used to generate csv file and
5 # instructions files for gnuplot from the output of sgpdd-survey.pl script.
7 # The plot-sgpdd.pl also creates .scr file that contains instructions
8 # for gnuplot to plot the graph. After generating .dat and .scr files this
9 # script invokes gnuplot to display graph.
12 # $ plot-sgpdd.pl <log_filename>
13 # [Note: 1. This script may need modifications whenever there will be
14 # modifications in output format of sgpdd-survey.pl script.
15 # 2. Gnuplot version 4.0 or above is required.]
19 print "Usage: $0 <log_filename> \n";
20 print " The $0 parses and plots graph for output of sgpdd-survey.pl using gnuplot,\n";
21 print " it generates .dat and .scr files for results graphing\n";
22 print "e.g.> perl $0 sgpdd-log \n";
34 open ( PFILE, "$file") or die "Can't open results";
35 LABEL: while ( <PFILE> ) {
37 @line = split( /\s+/ );
45 if ($line[10] eq "failed") {
48 $out{$line[7]}{$line[5]} = $line[9];
51 #print "rg$line[5] th$line[7] w$line[9] r$line[$rindex]\n";
53 if (!($line[$rindex+1] eq "failed")) {
55 $out{$line[7]}{$line[5] - 1} = $line[$rindex];
57 $out{$line[7]}{$line[5] + 1} = $line[$rindex];
61 if ( $region < $line[7] ) {
64 if ( $thread < $line[5] ) {
71 print "@GraphTitle\n";
72 # Open .csv file for writting required columns from log file.
73 open ( DATAFILE, "> $file.dat" ) or die "Can't open csv file for writting";
75 for ($j = 1; $j <= $thread ; $j = $j + $j) {
76 print DATAFILE " write$j read$j";
78 for ( $i = 1; $i <= $region; $i = $i + $i ) {
79 printf DATAFILE "\n%-4s", $i;
80 for ($j = 1; $j <= $thread ; $j = $j + $j) {
82 print DATAFILE " $out{$i}{$j}";
86 if ( $j <= 1 && $out{$i}{$j - 1}) {
87 print DATAFILE " $out{$i}{$j - 1}";
88 } elsif ($out{$i}{$j + 1}) {
89 print DATAFILE " $out{$i}{$j + 1}";
96 open ( SCRFILE, "> $file.scr" ) or die "Can't open scr file for writting";
97 print SCRFILE "set title \"@GraphTitle\"\n";
98 print SCRFILE "set xlabel \"Threads\"\n";
99 print SCRFILE "set ylabel \"Speeds(MB/s)\"\n";
103 # generate instructions for gnuplot, with adjusting X-axes ranges
104 for ($j = 1; $j <= $thread ; $j = $j + $j) {
108 printf SCRFILE "$plot \"$file.dat\" using 1:$i axes x%dy1 title \"write$j\" with line\n", $xrange;
111 printf SCRFILE "$plot \"$file.dat\" using 1:$i axes x%dy1 title \"read$j\" with line\n", $xrange;
114 print SCRFILE "pause -1\n";
116 system ("gnuplot $file.scr") == 0 or die "ERROR: while ploting graph.\nMake sure that gnuplot is working properly";