File: makeimages.pl

package info (click to toggle)
tiobench 0.3.3-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge, squeeze, wheezy
  • size: 176 kB
  • ctags: 159
  • sloc: ansic: 1,365; perl: 301; makefile: 97; sh: 59
file content (67 lines) | stat: -rwxr-xr-x 2,226 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl -w

#    Author: James Manning <jmm@users.sf.net>
#       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);