#!/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 = "./"; @excludes; while ($#ARGV >= 0 && $ARGV[0] eq "-x") { my $parm = splice @ARGV, 0, 1; my $file = splice @ARGV, 0, 1; @files = split /\//, $file; $excludes[$#excludes+1] = $files[$#files]; } ($#ARGV >= 0) && ($dir = $ARGV[0]); my @ls = `ls $dir/results-preempt-test-*.out`; my $output = "results-preempt-test"; my $output_plt = "$output.plt"; my $output_dat = "$output.dat"; my $output_png = "$output.png"; my %list; my %max; my %min; my %avg; my $totmax = 0; my $totmin = -1; foreach my $file (@ls) { chomp $file; if ($file =~ /results-preempt-test-(.*)\.out/) { my $skip = 0; foreach my $ex (@excludes) { @files = split /\//, $file; if ($files[$#files] eq $ex) { print "skipping file $file\n"; $skip = 1; last; } } next if ($skip); $list{$1} = $file; } } sub read_values { my ($file, $max, $min, $avg, $totmax, $totmin) = @_; open(IN, "$file") || die "Can't read file $file"; while () { if (/Stats:.*min:\s+(\d+).*max:\s+(\d+).*ave:\s+(\d+)/) { $$min = $1; $$max = $2; $$avg = $3; if ($$totmax < $$max) { $$totmax = $$max; } if ($$totmin == -1 || $$totmin > $$min) { $$totmin = $$min; } last; } } close IN; } foreach my $ver (keys %list) { read_values $list{$ver}, \$max{$ver}, \$min{$ver}, \$avg{$ver}, \$totmax, \$totmin; } open(OUT, ">$output_plt") || die "Can't write $output_plt file"; my $ytop = $totmax + $totmax / 4; my $ybot = $totmin - $totmin / 4; print OUT << "EOF"; set title "Preempt Test Results" set ylabel "Times (usecs)" 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) { my $min = $min{$ver}; my $avg = $avg{$ver} - $min; my $max = $max{$ver} - ($avg + $min); print OUT "$ver $min $avg $max\n"; } print OUT "spacer 0 0 0\n"; close OUT;