Debian Codegraph @

benchmarks/summarize.pl

raw
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 sub average {
6 my $n = 0;
7 my $s = 0;
8 $n++, $s+=$_ foreach @_;
9 $s/$n;
10 }
11
12 sub min {
13 my $m = shift;
14 ($_ < $m) and $m = $_ foreach @_;
15 $m;
16 }
17
18 sub max {
19 my $m = shift;
20 ($_ > $m) and $m = $_ foreach @_;
21 $m;
22 }
23
24
25
26 my %times;
27 my %benchmarks;
28 my %runtimes;
29 my %gctimes;
30
31 {
32 my $curtime;
33 my $curbench;
34 my $counter = 0;
35 open F, "<timelog" or die;
36 while(<F>){
37 if (/^NOW: (.*)/){
38 $curtime = $1;
39 $times{$curtime} = ++$counter;
40 next;
41 }
42 if(/^running stats for (.*):$/){
43 $curbench = $1;
44 $benchmarks{$curbench} ||= ++$counter;
45 next;
46 }
47 if(/^ *(\d*) ms elapsed cpu time, including (\d*) ms collecting$/){
48 push @{$runtimes{$curbench}{$curtime}}, $1;
49 push @{$gctimes{$curbench}{$curtime}}, $2;
50 next;
51 }
52 }
53 close F;
54 }
55
56 my @times = sort { $times{$a} <=> $times{$b} } keys %times;
57 my @benchmarks = sort { $benchmarks{$a} <=> $benchmarks{$b} } keys %benchmarks;
58
59 my $verbose = 0;
60
61 foreach my $bench (@benchmarks){
62 print "benchmark: $bench\n";
63 my $prev = 0;
64 foreach my $time (@times){
65 defined $runtimes{$bench}{$time} or next;
66 my @times = @{$runtimes{$bench}{$time}};
67 my $t = min(@times);
68 if($prev){
69 my $diff = (($t - $prev) / $prev) * 100;
70 printf " %6d %6s on $time\n",
71 $t,
72 sprintf("(%s%d%%)", ($diff>0) ? "+" : ($diff<0) ? "-" : "", abs $diff);
73 } else {
74 printf " %6d on $time\n", $t;
75 }
76 $prev = $t;
77 }
78 }
79
80