1 ##########################################################################################
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
16 # The Original Code is mozilla.org code.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1998
21 # the Initial Developer. All Rights Reserved.
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
40 #------------------------------------------------------------------------------
46 #------------------------------------------------------------------------------
48 #------------------------------------------------------------------------------
52 $NumOfSites = $ARGV[2];
53 $buildRoot = $ARGV[3];
55 $useClockTime = $ARGV[5];
56 #$buildIDFile = '< '.$buildRoot.'\bin\chrome\locales\en-US\navigator\locale\navigator.dtd';
58 debug_print
( "Arguments:[ $UrlName | $logFile | $NumOfSites | $buildRoot | $LinkURL | $useClockTime]\n");
60 #------------------------------------------------------------------------------
61 # Open the ID file and get the build ID
62 #------------------------------------------------------------------------------
64 #open (XUL_FILE, $buildIDFile) or die "Cannot open BuildID file $buildIDFile (AverageTable2.pl)\n";
72 # @LineList = split (/\"/, $ThisLine);
73 # $BuildNo = $LineList[1];
76 #@LineList = split (/ /, $BuildNo);
77 #$BuildNo = $LineList[2];
79 #$BuildNo =~ s/[>]//g;
80 #debug_print ("Build Number: $BuildNo\n");
83 #------------------------------------------------------------------------------
84 # Open the logfile (input)
85 # and the deviation file (output,append)
86 #------------------------------------------------------------------------------
87 open (LOG_FILE
, "< $logFile") or die "Logfile $logFile could not be opened";
89 #------------------------------------------------------------------------------
91 # Flat file used to calculate and display deviation between latest and
92 # week old builds data.
94 # Format of flat file is attributes separated by commas with no spaces as follows:
95 # BuildNo,date,url,parsingtime,parsingper,contenttime,contentper,frametime,
96 # frameper,styletime,styleper,reflowtime,reflowper,totallayouttime,totallayoutper,
98 ($Second, $Minute, $Hour, $DayOfMonth, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime (time);
99 $RealMonth = $Month + 1;
101 $BuildNo = $RealMonth.$DayOfMonth.$Year;
102 $file = $BuildNo.".dat";
103 open (DEVIATION
, ">> $file") or die "Deviation file could not be opened";
105 # add entry to the deviation file
106 ($Second, $Minute, $Hour, $DayOfMonth, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime (time);
107 $RealMonth = $Month + 1;
109 $date2 = $RealMonth.$DayOfMonth.$Year;
110 print (DEVIATION
"$BuildNo,$date2,$UrlName,");
112 #------------------------------------------------------------------------------
114 #------------------------------------------------------------------------------
118 $FrameAndStyle_Time = 0;
122 $TotalPageLoad_Time = 0;
123 $TotalLayout_Time = 0;
124 $Avg_Content_Time = 0;
125 $Avg_Reflow_Time = 0;
126 $Avg_FrameAndStyle_Time = 0;
130 $Avg_TotalPageLoad_Time = 0;
131 $Avg_TotalLayout_Time = 0;
132 $Content_Time_Percentage = 0;
133 $Reflow_Time_Percentage = 0;
134 $FrameAndStyle_Time_Percentage = 0;
135 $Frame_Time_Percentage = 0;
136 $Style_Time_Percentage = 0;
137 $Parse_Time_Percentage = 0;
138 $TotalLayout_Time_Percentage = 0;
139 $Avg_Content_Time_Percentage = 0;
140 $Avg_Reflow_Time_Percentage = 0;
141 $Avg_FrameAndStyle_Time_Percentage = 0;
142 $Avg_Frame_Time_Percentage = 0;
143 $Avg_Style_Time_Percentage = 0;
144 $Avg_Parse_Time_Percentage = 0;
145 $Avg_TotalLayout_Time_Percentage = 0;
156 #------------------------------------------------------------------------------
157 # Management of averages via average.txt file
158 # NOTE: the averag.txt file is used to accumulate all performance times
159 # and keep track of the number of entries. When completed, the footer.pl
160 # script does the averaging by dividing the accumulated times by the
162 #------------------------------------------------------------------------------
164 # if first site, delete any old Average file (in case the caller did not)
166 if ( $NumOfSites == 1 ){
167 unlink( "Average.txt" );
168 debug_print
( "Deleting file Average.txt\n" );
170 # load the averages data so we can accumulate it
172 if ( -r
"Average.txt" ) {
173 open (AVERAGE
, "< Average.txt");
178 if( /Num Entries:/ ){
179 @list = split( / /, $ThisLine );
180 $Num_Entries = $list[2];
181 debug_print
( "Num Entries: $Num_Entries\n" );
184 @list = split( / /, $ThisLine );
185 $Avg_Parse_Time = $list[2];
186 debug_print
( "Avg Parse: $Avg_Parse_Time\n" );
189 @list = split( / /, $ThisLine );
190 $Avg_Parse_Time_Percentage = $list[2];
191 debug_print
( "Per Parse: $Avg_Parse_Time_Percentage\n" );
193 if( /Avg Content:/ ){
194 @list = split( / /, $ThisLine );
195 $Avg_Content_Time = $list[2];
196 debug_print
( "Avg Content: $Avg_Content_Time\n" );
198 if( /Per Content:/ ){
199 @list = split( / /, $ThisLine );
200 $Avg_Content_Time_Percentage = $list[2];
201 debug_print
( "Per Content: $Avg_Content_Time_Percentage\n" );
204 @list = split( / /, $ThisLine );
205 $Avg_Frame_Time = $list[2];
206 debug_print
( "Avg Frame: $Avg_Frame_Time\n" );
209 @list = split( / /, $ThisLine );
210 $Avg_Frame_Time_Percentage = $list[2];
211 debug_print
( "Per Frame: $Avg_Frame_Time_Percentage\n" );
214 @list = split( / /, $ThisLine );
215 $Avg_Style_Time = $list[2];
216 debug_print
( "Avg Style: $Avg_Style_Time\n" );
219 @list = split( / /, $ThisLine );
220 $Avg_Style_Time_Percentage = $list[2];
221 debug_print
( "Per Style: $Avg_Style_Time_Percentage\n" );
224 @list = split( / /, $ThisLine );
225 $Avg_Reflow_Time = $list[2];
226 debug_print
( "Avg Reflow: $Avg_Reflow_Time\n" );
229 @list = split( / /, $ThisLine );
230 $Avg_Reflow_Time_Percentage = $list[2];
231 debug_print
( "Per Reflow: $Avg_Reflow_Time_Percentage\n" );
233 if( /Avg TotalLayout:/ ){
234 @list = split( / /, $ThisLine );
235 $Avg_TotalLayout_Time = $list[2];
236 debug_print
( "Avg TotalLayout: $Avg_TotalLayout_Time\n" );
239 @list = split( / /, $ThisLine );
240 $Avg_TotalLayout_Time_Percentage = $list[2];
241 debug_print
( "Per Layout: $Avg_TotalLayout_Time_Percentage\n" );
243 if( /Avg PageLoad:/ ){
244 @list = split( / /, $ThisLine );
245 $Avg_TotalPageLoad_Time = $list[2];
246 debug_print
( "Avg PageLoad: $Avg_TotalPageLoad_Time\n" );
249 print (AVERAGE
"Avg PageLoad: $Avg_TotalPageLoad_Time\n");
253 #------------------------------------------------------------------------------
254 # now run through the log file and process the performance data
255 #------------------------------------------------------------------------------
264 # @List = split (/webshell: /, $ThisLine);
265 # $WebShell = $List[1];
266 # $WebShell = "(webBrowserChrome=".$WebShell;
267 # $WebShell = $WebShell."):";
268 # debug_print( "$WebShell\n" );
270 @List = split (/'/, $ThisLine);
272 debug_print
( "(URI: $url) " );
273 if( $url =~ /$LinkURL/ ){
274 debug_print
( "$url is the one!\n" );
277 debug_print
( "Skipping URL $url\n" );
282 if ($IsValidURL == 1){
283 @List = split (/ /, $ThisLine);
285 @clockTimeList = split(/:/, $List[6]);
286 $Content_Time += $clockTimeList[2];
288 $Content_Time += $List[9];
291 debug_print
( "Content Time: $Content_Time\n" );
295 if ($IsValidURL == 1){
296 @List = split (/ /, $ThisLine);
298 @clockTimeList = split(/:/, $List[5]);
299 $Reflow_Time += $clockTimeList[2];
301 $Reflow_Time += $List[8];
304 debug_print
( "Reflow Time: $Reflow_Time\n" );
307 if (/Frame construction plus/){
308 if ($IsValidURL == 1){
309 @List = split (/ /, $ThisLine);
311 @clockTimeList = split(/:/, $List[9]);
312 $FrameAndStyle_Time += $clockTimeList[2];
314 $FrameAndStyle_Time += $List[12];
316 debug_print
( "Frame and Style Time: $FrameAndStyle_Time\n" );
320 if ($IsValidURL == 1){
321 @List = split (/ /, $ThisLine);
323 @clockTimeList = split(/:/, $List[6]);
324 $Style_Time += $clockTimeList[2];
326 $Style_Time += $List[9];
329 debug_print
( "Style Time: $Style_Time\n" );
333 if ($IsValidURL == 1){
334 @List = split (/ /, $ThisLine);
336 @clockTimeList = split(/:/, $List[5]);
337 $Parse_Time += $clockTimeList[2];
339 $Parse_Time += $List[8];
342 debug_print
( "Parse Time: $Parse_Time\n" );
346 if ($IsValidURL == 1){
347 @List = split (/ /, $ThisLine);
350 # ($temp == $WebShell) &&
351 ($Parse_Flag == 1) &&
352 ($Content_Flag == 1) &&
353 ($Reflow_Flag == 1) &&
355 $TotalPageLoad_Time = $List[12];
356 debug_print
( "Total Page Load_Time Time: $TotalPageLoad_Time\n" );
366 #------------------------------------------------------------------------------
367 # Calculate the significant time values
368 #------------------------------------------------------------------------------
369 $Frame_Time = $FrameAndStyle_Time - $Style_Time;
370 if($Frame_Time < 0.0){
371 print( "\n***** ERROR: negative FrameTime *****\n");
374 $TotalLayout_Time = $Content_Time + $Reflow_Time + $Frame_Time + $Style_Time + $Parse_Time;
375 $Avg_Time = $Avg_Time + $TotalLayoutTime + $TotalPageLoad_Time;
377 if( $TotalLayout_Time > 0 ){
378 if ($Content_Time != 0)
380 $Content_Time_Percentage = ($Content_Time / $TotalLayout_Time) * 100;
382 if ($Reflow_Time != 0)
384 $Reflow_Time_Percentage = ($Reflow_Time / $TotalLayout_Time) * 100;
386 if ($Frame_Time != 0)
388 $Frame_Time_Percentage = ($Frame_Time / $TotalLayout_Time) * 100;
390 if ($Style_Time != 0)
392 $Style_Time_Percentage = ($Style_Time / $TotalLayout_Time) * 100;
394 if ($Parse_Time != 0)
396 $Parse_Time_Percentage = ($Parse_Time / $TotalLayout_Time) * 100;
398 if( $TotalPageLoad_Time > 0 ){
399 $TotalLayout_Time_Percentage = ($TotalLayout_Time / $TotalPageLoad_Time) * 100;
401 $TotalLayout_Time_Percentage = 100;
405 #------------------------------------------------------------------------------
406 # Add current values to those in the averages-fields
407 #------------------------------------------------------------------------------
408 $Avg_Content_Time += $Content_Time;
409 $Avg_Reflow_Time += $Reflow_Time;
410 $Avg_Frame_Time += $Frame_Time;
411 $Avg_Style_Time += $Style_Time;
412 $Avg_Parse_Time += $Parse_Time;
413 $Avg_TotalPageLoad_Time += $TotalPageLoad_Time;
414 $Avg_TotalLayout_Time += $TotalLayout_Time;
416 $Avg_Content_Time_Percentage += $Content_Time_Percentage;
417 $Avg_Reflow_Time_Percentage += $Reflow_Time_Percentage;
418 $Avg_Frame_Time_Percentage += $Frame_Time_Percentage;
419 $Avg_Style_Time_Percentage += $Style_Time_Percentage;
420 $Avg_Parse_Time_Percentage += $Parse_Time_Percentage;
421 $Avg_TotalLayout_Time_Percentage += $TotalLayout_Time_Percentage;
425 #------------------------------------------------------------------------------
426 # Now write this site's data to the table
427 #------------------------------------------------------------------------------
428 open (TABLE_FILE
, ">>table.html");
430 print (TABLE_FILE
"<tr>");
432 print (TABLE_FILE
"<td BGCOLOR='#FFFFFF'>");
433 print (TABLE_FILE
"<center><a href='$LinkURL'>$UrlName</a></center>");
434 print (TABLE_FILE
"</td>");
436 print (TABLE_FILE
"<td BGCOLOR='#FFFFFF'>");
437 printf (TABLE_FILE
"<center>%4.2f</center>",$Parse_Time);
438 print (DEVIATION
"$Parse_Time,");
439 print (TABLE_FILE
"</td>");
441 print (TABLE_FILE
"<td BGCOLOR='#FFFF00'>");
442 printf (TABLE_FILE
"<center>%4.2f</center>",$Parse_Time_Percentage);
443 print (DEVIATION
"$Parse_Time_Percentage,");
444 print (TABLE_FILE
"</td>");
446 print (TABLE_FILE
"<td BGCOLOR='#FFFFFF'>");
447 printf (TABLE_FILE
"<center>%4.2f</center>",$Content_Time);
448 print (DEVIATION
"$Content_Time,");
449 print (TABLE_FILE
"</td>");
451 print (TABLE_FILE
"<td BGCOLOR='#FFFF00'>");
452 printf (TABLE_FILE
"<center>%4.2f</center>",$Content_Time_Percentage);
453 print (DEVIATION
"$Content_Time_Percentage,");
454 print (TABLE_FILE
"</td>");
456 print (TABLE_FILE
"<td BGCOLOR='#FFFFFF'>");
457 printf (TABLE_FILE
"<center>%4.2f</center>",$Frame_Time);
458 print (DEVIATION
"$Frame_Time,");
459 print (TABLE_FILE
"</td>");
461 print (TABLE_FILE
"<td BGCOLOR='#FFFF00'>");
462 printf (TABLE_FILE
"<center>%4.2f</center>",$Frame_Time_Percentage);
463 print (DEVIATION
"$Frame_Time_Percentage,");
464 print (TABLE_FILE
"</td>");
466 print (TABLE_FILE
"<td BGCOLOR='#FFFFFF'>");
467 printf (TABLE_FILE
"<center>%4.2f</center>",$Style_Time);
468 print (DEVIATION
"$Style_Time,");
469 print (TABLE_FILE
"</td>");
471 print (TABLE_FILE
"<td BGCOLOR='#FFFF00'>");
472 printf (TABLE_FILE
"<center>%4.2f</center>",$Style_Time_Percentage);
473 print (DEVIATION
"$Style_Time_Percentage,");
474 print (TABLE_FILE
"</td>");
476 print (TABLE_FILE
"<td BGCOLOR='#FFFFFF'>");
477 printf (TABLE_FILE
"<center>%4.2f</center>",$Reflow_Time);
478 print (DEVIATION
"$Reflow_Time,");
479 print (TABLE_FILE
"</td>");
481 print (TABLE_FILE
"<td BGCOLOR='#FFFF00'>");
482 printf (TABLE_FILE
"<center>%4.2f</center>",$Reflow_Time_Percentage);
483 print (DEVIATION
"$Reflow_Time_Percentage,");
484 print (TABLE_FILE
"</td>");
486 print (TABLE_FILE
"<td BGCOLOR='#FFFFFF'>");
487 printf (TABLE_FILE
"<center>%4.2f</center>",$TotalLayout_Time);
488 print (DEVIATION
"$TotalLayout_Time,");
489 print (TABLE_FILE
"</td>");
491 print (TABLE_FILE
"<td BGCOLOR='#FFFF00'>");
492 printf (TABLE_FILE
"<center>%4.2f</center>",$TotalLayout_Time_Percentage);
493 print (DEVIATION
"$TotalLayout_Time_Percentage,");
494 print (TABLE_FILE
"</td>");
496 print (TABLE_FILE
"<td BGCOLOR='#FFFFFF'>");
497 printf (TABLE_FILE
"<center>%4.2f</center>",$TotalPageLoad_Time);
498 print (DEVIATION
"$TotalPageLoad_Time\n");
499 print (TABLE_FILE
"</td>");
501 print (TABLE_FILE
"</tr>\n");
505 open (AVERAGE
, "> Average.txt");
506 print (AVERAGE
"Num Entries: $Num_Entries\n");
507 print (AVERAGE
"Avg Parse: $Avg_Parse_Time\n");
508 print (AVERAGE
"Per Parse: $Avg_Parse_Time_Percentage\n");
509 print (AVERAGE
"Avg Content: $Avg_Content_Time\n");
510 print (AVERAGE
"Per Content: $Avg_Content_Time_Percentage\n");
511 print (AVERAGE
"Avg Frame: $Avg_Frame_Time\n");
512 print (AVERAGE
"Per Frame: $Avg_Frame_Time_Percentage\n");
513 print (AVERAGE
"Avg Style: $Avg_Style_Time\n");
514 print (AVERAGE
"Per Style: $Avg_Style_Time_Percentage\n");
515 print (AVERAGE
"Avg Reflow: $Avg_Reflow_Time\n");
516 print (AVERAGE
"Per Reflow: $Avg_Reflow_Time_Percentage\n");
517 print (AVERAGE
"Avg TotalLayout: $Avg_TotalLayout_Time\n");
518 print (AVERAGE
"Per Layout: $Avg_TotalLayout_Time_Percentage\n");
519 print (AVERAGE
"Avg PageLoad: $Avg_TotalPageLoad_Time\n");