|
1 #!/usr/bin/perl -w |
|
2 # This Source Code Form is subject to the terms of the Mozilla Public |
|
3 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 |
|
6 |
|
7 %::Sites = (); |
|
8 |
|
9 @::Categories = ( |
|
10 Content, |
|
11 Reflow, |
|
12 Frame, |
|
13 Style, |
|
14 Parse, |
|
15 DTD, |
|
16 Tokenize, |
|
17 Total |
|
18 ); |
|
19 |
|
20 $::CurrentSite = ""; |
|
21 |
|
22 LINE: while (<>) { |
|
23 if (/^\*\*\* Timing layout processes on url: '(.*)'/) { |
|
24 # This will generate a URL that looks something like: |
|
25 # |
|
26 # file:///foo/bar/website/index.html |
|
27 # |
|
28 # So, we'll parse out the ``website'' part... |
|
29 my @parts = split('/', $1); |
|
30 $::CurrentSite = $parts[$#parts - 1]; |
|
31 |
|
32 if (! $::Sites{$::CurrentSite}) { |
|
33 $::Sites{$::CurrentSite} = {}; |
|
34 } |
|
35 next LINE; |
|
36 } |
|
37 |
|
38 next LINE unless $::CurrentSite; |
|
39 |
|
40 CATEGORY: foreach $category (@::Categories) { |
|
41 next CATEGORY unless (/$category/); |
|
42 |
|
43 # The "real time" is indicated in HH:MM:SS.mmmm format |
|
44 my ($h,$m,$s,$ms) = /Real time (..):(..):(..)\.(....)/; |
|
45 my $real = $ms; |
|
46 $real += $s * 1000; |
|
47 $real += $m * 1000 * 60; |
|
48 $real += $h * 1000 * 60 * 60; |
|
49 |
|
50 # The "CPU time" is indicated in m.uuu format |
|
51 my ($cpu) = /CP time (.*\....)/; |
|
52 |
|
53 my $site = $::Sites{$::CurrentSite}; |
|
54 if (! $site->{$category}) { |
|
55 $site->{$category} = { Count => 0, Real => 0, CPU => 0, Real2 => 0, CPU2 => 0 }; |
|
56 } |
|
57 |
|
58 $site->{$category}->{Count} += 1; |
|
59 $site->{$category}->{Real} += $real; |
|
60 $site->{$category}->{CPU} += $cpu; |
|
61 $site->{$category}->{Real2} += $real * $real; |
|
62 $site->{$category}->{CPU2} += $cpu * $cpu; |
|
63 } |
|
64 } |
|
65 |
|
66 my $bgcolor0 = '#999999'; |
|
67 my $bgcolor1 = '#777777'; |
|
68 |
|
69 my $bgcolor; |
|
70 |
|
71 print "<table border='0' cellpadding='2' cellspacing='0'>\n"; |
|
72 |
|
73 print "<tr>\n"; |
|
74 print " <td rowspan='2' valign='bottom'>Site</td>\n"; |
|
75 |
|
76 $bgcolor = $bgcolor0; |
|
77 foreach $category (@::Categories) { |
|
78 print " <td bgcolor='$bgcolor' align='center' colspan='4'>$category</td>\n"; |
|
79 $bgcolor = ($bgcolor eq $bgcolor0) ? $bgcolor1 : $bgcolor0; |
|
80 } |
|
81 print "</tr>\n"; |
|
82 |
|
83 print "<tr>\n"; |
|
84 |
|
85 $bgcolor = $bgcolor0; |
|
86 foreach $category (@::Categories) { |
|
87 print " <td bgcolor='$bgcolor' align='center' colspan='2'>CPU</td> <td bgcolor='$bgcolor' align='center' colspan='2'>Real</td>\n"; |
|
88 $bgcolor = ($bgcolor eq $bgcolor0) ? $bgcolor1 : $bgcolor0; |
|
89 } |
|
90 print "</tr>\n"; |
|
91 |
|
92 foreach $sitename (sort(keys(%::Sites))) { |
|
93 print "<tr>\n"; |
|
94 |
|
95 my $site = $::Sites{$sitename}; |
|
96 print " <td>$sitename</td>\n"; |
|
97 |
|
98 $bgcolor = $bgcolor0; |
|
99 foreach $category (@::Categories) { |
|
100 my $count = $site->{$category}->{Count}; |
|
101 my $real = $site->{$category}->{Real}; |
|
102 my $cpu = $site->{$category}->{CPU}; |
|
103 my $real2 = $site->{$category}->{Real2}; |
|
104 my $cpu2 = $site->{$category}->{CPU2}; |
|
105 |
|
106 my $realdev = 0; |
|
107 my $cpudev = 0; |
|
108 |
|
109 if ($count) { |
|
110 if ($count > 1) { |
|
111 $realdev = sqrt( ( $real2 * $count - $real * $real ) / ( $count * ( $count - 1 ) ) ); |
|
112 $cpudev = sqrt( ( $cpu2 * $count - $cpu * $cpu ) / ( $count * ( $count - 1 ) ) ); |
|
113 } |
|
114 |
|
115 $real /= $count; |
|
116 $cpu /= $count; |
|
117 } |
|
118 else { |
|
119 $count = 0; |
|
120 $real = 0; |
|
121 $cpu = 0; |
|
122 } |
|
123 |
|
124 printf " <td bgcolor='$bgcolor' align='right'>%0.2lf</td><td bgcolor='$bgcolor' align='left'>±%0.2lf</td>\n", $cpu, $cpudev; |
|
125 printf " <td bgcolor='$bgcolor' align='right'>%0.2lf</td><td bgcolor='$bgcolor' align='left'>±%0.2lf</td>", $real, $realdev; |
|
126 |
|
127 $bgcolor = ($bgcolor eq $bgcolor0) ? $bgcolor1 : $bgcolor0; |
|
128 } |
|
129 |
|
130 print "</tr>\n"; |
|
131 } |
|
132 |
|
133 print "</table>\n"; |
|
134 |