ikarus/benchmarks/summarize.pl

81 lines
1.5 KiB
Perl
Raw Normal View History

#!/usr/bin/perl -w
use strict;
2007-11-05 22:49:38 -05:00
sub average {
my $n = 0;
my $s = 0;
$n++, $s+=$_ foreach @_;
$s/$n;
}
sub min {
my $m = shift;
($_ < $m) and $m = $_ foreach @_;
$m;
}
sub max {
my $m = shift;
($_ > $m) and $m = $_ foreach @_;
$m;
}
my %times;
my %benchmarks;
my %runtimes;
my %gctimes;
{
my $curtime;
my $curbench;
my $counter = 0;
2007-11-05 22:49:38 -05:00
open F, "<timelog" or die;
while(<F>){
if (/^NOW: (.*)/){
$curtime = $1;
$times{$curtime} = ++$counter;
next;
}
if(/^running stats for (.*):$/){
$curbench = $1;
$benchmarks{$curbench} ||= ++$counter;
next;
}
if(/^ *(\d*) ms elapsed cpu time, including (\d*) ms collecting$/){
2007-11-05 22:49:38 -05:00
push @{$runtimes{$curbench}{$curtime}}, $1;
push @{$gctimes{$curbench}{$curtime}}, $2;
next;
}
}
close F;
}
my @times = sort { $times{$a} <=> $times{$b} } keys %times;
my @benchmarks = sort { $benchmarks{$a} <=> $benchmarks{$b} } keys %benchmarks;
my $verbose = 0;
foreach my $bench (@benchmarks){
print "benchmark: $bench\n";
my $prev = 0;
foreach my $time (@times){
defined $runtimes{$bench}{$time} or next;
2007-11-05 22:49:38 -05:00
my @times = @{$runtimes{$bench}{$time}};
my $avg = average(@times);
if($prev){
my $diff = (($avg - $prev) / $prev) * 100;
printf " %6d %6s on $time\n",
$avg,
sprintf("(%s%d%%)", ($diff>0) ? "+" : ($diff<0) ? "-" : "", abs $diff);
} else {
printf " %6d on $time\n", $avg;
}
$prev = $avg;
}
}