tools/performance/layout/collect.pl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial