#!/usr/bin/perl # # Copyright 2007 Red Hat Inc # Author Steven Rostedt # # This software may be used and distributed according to the terms # of the GNU General Public License version 2, incorporated herein by reference. # # set to one to display by X so we can slant the X ticks. my $rotate = 0; my $ROTATE = 90; if ($rotate) { $ROTATE = -45; } my $dir = "./"; ($#ARGV >= 0) && ($dir = $ARGV[0]); my @ls = `ls $dir/results-hackbench-*.out`; my $output = "results-hackbench"; my $output_plt = "$output.plt"; my $output_dat = "$output.dat"; my $output_png = "$output.png"; my %rtlist; my %nonlist; my %list; my %rtmax; my %rtmin; my %rtavg; my %nonmax; my %nonmin; my %nonavg; my $totmax = 0.0; my $totmin = -1.0; foreach my $file (@ls) { chomp $file; if ($file =~ /results-hackbench-rt-(.*)\.out/) { $rtlist{$1} = $file; } elsif ($file =~ /results-hackbench-(.*)\.out/) { $nonlist{$1} = $file; } } sub read_values { my ($file, $max, $min, $avg) = @_; $$min = -1.0; my $tot = 0.0; my $count = 0; $$max = 0.0; $$min = -1.0; open(IN, "$file") || die "Can't read file $file"; while () { if (/Time:\s+(\S+)/) { my $time = $1; $tot += $time; $count++; if ($$min < 0.0 || $time < $$min) { $$min = $time; } if ($$max < $time) { $$max = $time; } if ($totmax < $$max) { $totmax = $$max; } if ($totmin < 0.0 || $$min < $totmin) { $totmin = $$min; } } } close IN; $$avg = $tot / $count; } foreach my $ver (keys %nonlist) { if (!defined($rtlist{$ver})) { print "Warning: $nonlist{$ver} has no RT match\n"; } # save all versions $list{$ver} = 1; read_values $nonlist{$ver}, \$nonmax{$ver}, \$nonmin{$ver}, \$nonavg{$ver}; } foreach my $ver (keys %rtlist) { if (!defined($nonlist{$ver})) { print "Warning: $rtlist{$ver} has no non RT match\n"; } # save all versions $list{$ver} = 1; read_values $rtlist{$ver}, \$rtmax{$ver}, \$rtmin{$ver}, \$rtavg{$ver}; } open(OUT, ">$output_plt") || die "Can't write $output_plt file"; my $ytop = $totmax + $totmax / 4.0; my $ybot = $totmin - $totmin / 4.0; print OUT << "EOF"; set title "Hackbench Results" set ylabel "Times (secs)" set yrange [$ybot:$ytop] set auto x unset xtics set xtics nomirror rotate by $ROTATE set style data histogram set style histogram rowstacked set style fill solid border -1 set boxwidth 0.75 EOF if ($rotate) { print OUT << "EOF"; plot "$output_dat" using 2:xtic(1) tit "min", "" using 3 tit "avg", "" using 4 tit "max" pause -1 " to quit" EOF } else { print OUT << "EOF"; set terminal png set output "$output_png" plot "$output_dat" using 2:xtic(1) tit "min", "" using 3 tit "avg", "" using 4 tit "max" EOF } close OUT; open(OUT, ">$output_dat") || die "Can't write $output_dat"; foreach my $ver (sort keys %list) { if (defined($nonlist{$ver})) { my $min = $nonmin{$ver}; my $avg = $nonavg{$ver} - $min; my $max = $nonmax{$ver} - ($avg + $min); print OUT "$ver $min $avg $max\n"; } if (defined($rtlist{$ver})) { my $min = $rtmin{$ver}; my $avg = $rtavg{$ver} - $min; my $max = $rtmax{$ver} - ($avg + $min); print OUT "rt:$ver $min $avg $max\n"; } } print OUT "spacer 0 0 0\n"; close OUT;