As tiotest's funnyscripts/ directory is largely (if not wholly)
out-dated and broken, I've tried a first-pass perl script replacement for
makeimages.sh that takes the same params as the tiobench.pl perl script
and makes a gnuplot output.  Currently only plots the read performance
(will be fairly easy to extend later)... it's currently intentionally
fairly simple until output format(s) are stable.

This is mainly to solicit input on what valuable gnuplot output could look
like.  I'm not against surface plots, but trying to figure out good x,
y, and z variable selections for them hasn't been working well for me :)

Example output from this command:

funnyscripts/makeimages.pl --threads 1 --threads 2 --threads 4 --threads 6 --threads 8 
--threads 10 --threads 12 --threads 16 --threads 20 --threads 24 --dir /tmp --dir /src

is located here:

http://sublogic.com/reads.png

James
#!/usr/bin/perl -w

#    Author: James Manning <[EMAIL PROTECTED]>
#       This software may be used and distributed according to the terms of
#       the GNU General Public License, http://www.gnu.org/copyleft/gpl.html
#
#    Description:
#       Perl wrapper for calling tiobench.pl and displaying results
#       graphically using gnuplot

use strict;

my $args = join(" ",@ARGV);
my %input_fields; my %output_fields; my %values_present;
my %data; my $dir; my $size; my $blk; my $thr; my $read; my $read_cpu;
my $field;           my $write; my $write_cpu; my $seek; my $seek_cpu;
open(TIO,"tiobench.pl $args 2> /dev/null |") or die "failed on tiobench";

while(<TIO> !~ m/^---/) {} # get rid of header stuff

while(my $line = <TIO>) {
   $line =~ s/^\s+//g; # remove any leading whitespace
   ($input_fields{'dir'},    $input_fields{'size'}, 
    $input_fields{'blk'},    $input_fields{'thr'},

    $output_fields{'read'},  $output_fields{'read_cpu'},
    $output_fields{'write'}, $output_fields{'write_cpu'},
    $output_fields{'seek'},  $output_fields{'seek_cpu'}
      ) = split(/[\s%]+/, $line);
   foreach $field (keys %input_fields) { # mark values that appear
      $values_present{$field}{$input_fields{$field}}=1;
   }
   foreach $field (keys %output_fields) { # mark values that appear
      $data{$input_fields{'dir'}}{$input_fields{'thr'}}{$field}
         =$output_fields{$field};
   }
}

my $gnuplot_input = "\n".
   "set terminal png medium color;\n".
   "set output \"reads.png\";\n".
   "set title \"Reads\";\n".
   "set xlabel \"Threads\";\n".
   "set ylabel \"MB/s\";\n".
   "plot ";

my @gnuplot_files;

foreach my $dir (sort keys %{$values_present{'dir'}}) {
   my $file="read_dir=$dir";
   $file =~ s#/#_#g;
   push(@gnuplot_files,"\"$file\" with lines");
   open(FILE,"> $file") or die $file;
   foreach my $thr (sort {$a <=> $b} keys %{$values_present{'thr'}}) {
      print FILE "$thr $data{$dir}{$thr}{'read'}\n";
      print "DEBUG: $thr $data{$dir}{$thr}{'read'}\n";
   }
   close(FILE);
}

$gnuplot_input .= join(", ",@gnuplot_files) . ";\n";

print "DEBUG: feeding gnuplot $gnuplot_input";

open(GNUPLOT,"|gnuplot") or die "could not run gnuplot";
print GNUPLOT $gnuplot_input;
close(GNUPLOT);

Reply via email to