1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/performance/layout/collect.pl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,134 @@ 1.4 +#!/usr/bin/perl -w 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 + 1.10 +%::Sites = (); 1.11 + 1.12 +@::Categories = ( 1.13 + Content, 1.14 + Reflow, 1.15 + Frame, 1.16 + Style, 1.17 + Parse, 1.18 + DTD, 1.19 + Tokenize, 1.20 + Total 1.21 + ); 1.22 + 1.23 +$::CurrentSite = ""; 1.24 + 1.25 +LINE: while (<>) { 1.26 + if (/^\*\*\* Timing layout processes on url: '(.*)'/) { 1.27 + # This will generate a URL that looks something like: 1.28 + # 1.29 + # file:///foo/bar/website/index.html 1.30 + # 1.31 + # So, we'll parse out the ``website'' part... 1.32 + my @parts = split('/', $1); 1.33 + $::CurrentSite = $parts[$#parts - 1]; 1.34 + 1.35 + if (! $::Sites{$::CurrentSite}) { 1.36 + $::Sites{$::CurrentSite} = {}; 1.37 + } 1.38 + next LINE; 1.39 + } 1.40 + 1.41 + next LINE unless $::CurrentSite; 1.42 + 1.43 + CATEGORY: foreach $category (@::Categories) { 1.44 + next CATEGORY unless (/$category/); 1.45 + 1.46 + # The "real time" is indicated in HH:MM:SS.mmmm format 1.47 + my ($h,$m,$s,$ms) = /Real time (..):(..):(..)\.(....)/; 1.48 + my $real = $ms; 1.49 + $real += $s * 1000; 1.50 + $real += $m * 1000 * 60; 1.51 + $real += $h * 1000 * 60 * 60; 1.52 + 1.53 + # The "CPU time" is indicated in m.uuu format 1.54 + my ($cpu) = /CP time (.*\....)/; 1.55 + 1.56 + my $site = $::Sites{$::CurrentSite}; 1.57 + if (! $site->{$category}) { 1.58 + $site->{$category} = { Count => 0, Real => 0, CPU => 0, Real2 => 0, CPU2 => 0 }; 1.59 + } 1.60 + 1.61 + $site->{$category}->{Count} += 1; 1.62 + $site->{$category}->{Real} += $real; 1.63 + $site->{$category}->{CPU} += $cpu; 1.64 + $site->{$category}->{Real2} += $real * $real; 1.65 + $site->{$category}->{CPU2} += $cpu * $cpu; 1.66 + } 1.67 +} 1.68 + 1.69 +my $bgcolor0 = '#999999'; 1.70 +my $bgcolor1 = '#777777'; 1.71 + 1.72 +my $bgcolor; 1.73 + 1.74 +print "<table border='0' cellpadding='2' cellspacing='0'>\n"; 1.75 + 1.76 +print "<tr>\n"; 1.77 +print " <td rowspan='2' valign='bottom'>Site</td>\n"; 1.78 + 1.79 +$bgcolor = $bgcolor0; 1.80 +foreach $category (@::Categories) { 1.81 + print " <td bgcolor='$bgcolor' align='center' colspan='4'>$category</td>\n"; 1.82 + $bgcolor = ($bgcolor eq $bgcolor0) ? $bgcolor1 : $bgcolor0; 1.83 +} 1.84 +print "</tr>\n"; 1.85 + 1.86 +print "<tr>\n"; 1.87 + 1.88 +$bgcolor = $bgcolor0; 1.89 +foreach $category (@::Categories) { 1.90 + print " <td bgcolor='$bgcolor' align='center' colspan='2'>CPU</td> <td bgcolor='$bgcolor' align='center' colspan='2'>Real</td>\n"; 1.91 + $bgcolor = ($bgcolor eq $bgcolor0) ? $bgcolor1 : $bgcolor0; 1.92 +} 1.93 +print "</tr>\n"; 1.94 + 1.95 +foreach $sitename (sort(keys(%::Sites))) { 1.96 + print "<tr>\n"; 1.97 + 1.98 + my $site = $::Sites{$sitename}; 1.99 + print " <td>$sitename</td>\n"; 1.100 + 1.101 + $bgcolor = $bgcolor0; 1.102 + foreach $category (@::Categories) { 1.103 + my $count = $site->{$category}->{Count}; 1.104 + my $real = $site->{$category}->{Real}; 1.105 + my $cpu = $site->{$category}->{CPU}; 1.106 + my $real2 = $site->{$category}->{Real2}; 1.107 + my $cpu2 = $site->{$category}->{CPU2}; 1.108 + 1.109 + my $realdev = 0; 1.110 + my $cpudev = 0; 1.111 + 1.112 + if ($count) { 1.113 + if ($count > 1) { 1.114 + $realdev = sqrt( ( $real2 * $count - $real * $real ) / ( $count * ( $count - 1 ) ) ); 1.115 + $cpudev = sqrt( ( $cpu2 * $count - $cpu * $cpu ) / ( $count * ( $count - 1 ) ) ); 1.116 + } 1.117 + 1.118 + $real /= $count; 1.119 + $cpu /= $count; 1.120 + } 1.121 + else { 1.122 + $count = 0; 1.123 + $real = 0; 1.124 + $cpu = 0; 1.125 + } 1.126 + 1.127 + printf " <td bgcolor='$bgcolor' align='right'>%0.2lf</td><td bgcolor='$bgcolor' align='left'>±%0.2lf</td>\n", $cpu, $cpudev; 1.128 + printf " <td bgcolor='$bgcolor' align='right'>%0.2lf</td><td bgcolor='$bgcolor' align='left'>±%0.2lf</td>", $real, $realdev; 1.129 + 1.130 + $bgcolor = ($bgcolor eq $bgcolor0) ? $bgcolor1 : $bgcolor0; 1.131 + } 1.132 + 1.133 + print "</tr>\n"; 1.134 +} 1.135 + 1.136 +print "</table>\n"; 1.137 +