michael@0: ########################################################################################## michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: sub debug_print { michael@0: foreach $str (@_){ michael@0: # print( $str ); michael@0: } michael@0: } michael@0: #------------------------------------------------------------------------------ michael@0: # get the arguments: michael@0: #------------------------------------------------------------------------------ michael@0: @ARGV; michael@0: $UrlName = $ARGV[0]; michael@0: $logFile = $ARGV[1]; michael@0: $NumOfSites = $ARGV[2]; michael@0: $buildRoot = $ARGV[3]; michael@0: $LinkURL = $ARGV[4]; michael@0: $useClockTime = $ARGV[5]; michael@0: #$buildIDFile = '< '.$buildRoot.'\bin\chrome\locales\en-US\navigator\locale\navigator.dtd'; michael@0: #$buildIDFile = ""; michael@0: debug_print( "Arguments:[ $UrlName | $logFile | $NumOfSites | $buildRoot | $LinkURL | $useClockTime]\n"); michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # Open the ID file and get the build ID michael@0: #------------------------------------------------------------------------------ michael@0: michael@0: #open (XUL_FILE, $buildIDFile) or die "Cannot open BuildID file $buildIDFile (AverageTable2.pl)\n"; michael@0: #$BuildNo = ""; michael@0: #$LineList; michael@0: #while () michael@0: #{ michael@0: # $ThisLine = $_; michael@0: # chop ($ThisLine); michael@0: # if (/Build ID/){ michael@0: # @LineList = split (/\"/, $ThisLine); michael@0: # $BuildNo = $LineList[1]; michael@0: # } michael@0: #} michael@0: #@LineList = split (/ /, $BuildNo); michael@0: #$BuildNo = $LineList[2]; michael@0: #$BuildNo =~ s/"//g; michael@0: #$BuildNo =~ s/[>]//g; michael@0: #debug_print ("Build Number: $BuildNo\n"); michael@0: #close( XUL_FILE ); michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # Open the logfile (input) michael@0: # and the deviation file (output,append) michael@0: #------------------------------------------------------------------------------ michael@0: open (LOG_FILE, "< $logFile") or die "Logfile $logFile could not be opened"; michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # Deviation file: michael@0: # Flat file used to calculate and display deviation between latest and michael@0: # week old builds data. michael@0: # michael@0: # Format of flat file is attributes separated by commas with no spaces as follows: michael@0: # BuildNo,date,url,parsingtime,parsingper,contenttime,contentper,frametime, michael@0: # frameper,styletime,styleper,reflowtime,reflowper,totallayouttime,totallayoutper, michael@0: # totalpageloadtime michael@0: ($Second, $Minute, $Hour, $DayOfMonth, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime (time); michael@0: $RealMonth = $Month + 1; michael@0: $Year += 1900; michael@0: $BuildNo = $RealMonth.$DayOfMonth.$Year; michael@0: $file = $BuildNo.".dat"; michael@0: open (DEVIATION, ">> $file") or die "Deviation file could not be opened"; michael@0: michael@0: # add entry to the deviation file michael@0: ($Second, $Minute, $Hour, $DayOfMonth, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime (time); michael@0: $RealMonth = $Month + 1; michael@0: $Year += 1900; michael@0: $date2 = $RealMonth.$DayOfMonth.$Year; michael@0: print (DEVIATION "$BuildNo,$date2,$UrlName,"); michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # local variables michael@0: #------------------------------------------------------------------------------ michael@0: @List; michael@0: $Content_Time = 0; michael@0: $Reflow_Time = 0; michael@0: $FrameAndStyle_Time = 0; michael@0: $Frame_Time = 0; michael@0: $Style_Time = 0; michael@0: $Parse_Time = 0; michael@0: $TotalPageLoad_Time = 0; michael@0: $TotalLayout_Time = 0; michael@0: $Avg_Content_Time = 0; michael@0: $Avg_Reflow_Time = 0; michael@0: $Avg_FrameAndStyle_Time = 0; michael@0: $Avg_Frame_Time = 0; michael@0: $Avg_Style_Time = 0; michael@0: $Avg_Parse_Time = 0; michael@0: $Avg_TotalPageLoad_Time = 0; michael@0: $Avg_TotalLayout_Time = 0; michael@0: $Content_Time_Percentage = 0; michael@0: $Reflow_Time_Percentage = 0; michael@0: $FrameAndStyle_Time_Percentage = 0; michael@0: $Frame_Time_Percentage = 0; michael@0: $Style_Time_Percentage = 0; michael@0: $Parse_Time_Percentage = 0; michael@0: $TotalLayout_Time_Percentage = 0; michael@0: $Avg_Content_Time_Percentage = 0; michael@0: $Avg_Reflow_Time_Percentage = 0; michael@0: $Avg_FrameAndStyle_Time_Percentage = 0; michael@0: $Avg_Frame_Time_Percentage = 0; michael@0: $Avg_Style_Time_Percentage = 0; michael@0: $Avg_Parse_Time_Percentage = 0; michael@0: $Avg_TotalLayout_Time_Percentage = 0; michael@0: $Num_Entries = 0; michael@0: $valid = 0; michael@0: # $WebShell; michael@0: $temp; michael@0: $url; michael@0: $Content_Flag = 0; michael@0: $Reflow_Flag = 0; michael@0: $Style_Flag = 0; michael@0: $Parse_Flag = 0; michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # Management of averages via average.txt file michael@0: # NOTE: the averag.txt file is used to accumulate all performance times michael@0: # and keep track of the number of entries. When completed, the footer.pl michael@0: # script does the averaging by dividing the accumulated times by the michael@0: # number of entries michael@0: #------------------------------------------------------------------------------ michael@0: michael@0: # if first site, delete any old Average file (in case the caller did not) michael@0: # michael@0: if ( $NumOfSites == 1 ){ michael@0: unlink( "Average.txt" ); michael@0: debug_print( "Deleting file Average.txt\n" ); michael@0: } michael@0: # load the averages data so we can accumulate it michael@0: # michael@0: if ( -r "Average.txt" ) { michael@0: open (AVERAGE, "< Average.txt"); michael@0: while( ){ michael@0: $ThisLine = $_; michael@0: chop ($ThisLine); michael@0: michael@0: if( /Num Entries:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Num_Entries = $list[2]; michael@0: debug_print( "Num Entries: $Num_Entries\n" ); michael@0: } michael@0: if( /Avg Parse:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Parse_Time = $list[2]; michael@0: debug_print( "Avg Parse: $Avg_Parse_Time\n" ); michael@0: } michael@0: if( /Per Parse:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Parse_Time_Percentage = $list[2]; michael@0: debug_print( "Per Parse: $Avg_Parse_Time_Percentage\n" ); michael@0: } michael@0: if( /Avg Content:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Content_Time = $list[2]; michael@0: debug_print( "Avg Content: $Avg_Content_Time\n" ); michael@0: } michael@0: if( /Per Content:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Content_Time_Percentage = $list[2]; michael@0: debug_print( "Per Content: $Avg_Content_Time_Percentage\n" ); michael@0: } michael@0: if( /Avg Frame:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Frame_Time = $list[2]; michael@0: debug_print( "Avg Frame: $Avg_Frame_Time\n" ); michael@0: } michael@0: if( /Per Frame:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Frame_Time_Percentage = $list[2]; michael@0: debug_print( "Per Frame: $Avg_Frame_Time_Percentage\n" ); michael@0: } michael@0: if( /Avg Style:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Style_Time = $list[2]; michael@0: debug_print( "Avg Style: $Avg_Style_Time\n" ); michael@0: } michael@0: if( /Per Style:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Style_Time_Percentage = $list[2]; michael@0: debug_print( "Per Style: $Avg_Style_Time_Percentage\n" ); michael@0: } michael@0: if( /Avg Reflow:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Reflow_Time = $list[2]; michael@0: debug_print( "Avg Reflow: $Avg_Reflow_Time\n" ); michael@0: } michael@0: if( /Per Reflow:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_Reflow_Time_Percentage = $list[2]; michael@0: debug_print( "Per Reflow: $Avg_Reflow_Time_Percentage\n" ); michael@0: } michael@0: if( /Avg TotalLayout:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_TotalLayout_Time = $list[2]; michael@0: debug_print( "Avg TotalLayout: $Avg_TotalLayout_Time\n" ); michael@0: } michael@0: if( /Per Layout:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_TotalLayout_Time_Percentage = $list[2]; michael@0: debug_print( "Per Layout: $Avg_TotalLayout_Time_Percentage\n" ); michael@0: } michael@0: if( /Avg PageLoad:/ ){ michael@0: @list = split( / /, $ThisLine ); michael@0: $Avg_TotalPageLoad_Time = $list[2]; michael@0: debug_print( "Avg PageLoad: $Avg_TotalPageLoad_Time\n" ); michael@0: } michael@0: } michael@0: print (AVERAGE "Avg PageLoad: $Avg_TotalPageLoad_Time\n"); michael@0: close (AVERAGE); michael@0: } michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # now run through the log file and process the performance data michael@0: #------------------------------------------------------------------------------ michael@0: $IsValidURL = 0; michael@0: while () michael@0: { michael@0: $ThisLine = $_; michael@0: chop ($ThisLine); michael@0: michael@0: if (/Timing layout/) michael@0: { michael@0: # @List = split (/webshell: /, $ThisLine); michael@0: # $WebShell = $List[1]; michael@0: # $WebShell = "(webBrowserChrome=".$WebShell; michael@0: # $WebShell = $WebShell."):"; michael@0: # debug_print( "$WebShell\n" ); michael@0: michael@0: @List = split (/'/, $ThisLine); michael@0: $url = $List[1]; michael@0: debug_print( "(URI: $url) " ); michael@0: if( $url =~ /$LinkURL/ ){ michael@0: debug_print( "$url is the one!\n" ); michael@0: $IsValidURL = 1; michael@0: } else { michael@0: debug_print( "Skipping URL $url\n" ); michael@0: $IsValidURL = 0; michael@0: } michael@0: } michael@0: if (/Content/){ michael@0: if ($IsValidURL == 1){ michael@0: @List = split (/ /, $ThisLine); michael@0: if($useClockTime){ michael@0: @clockTimeList = split(/:/, $List[6]); michael@0: $Content_Time += $clockTimeList[2]; michael@0: } else { michael@0: $Content_Time += $List[9]; michael@0: } michael@0: $Content_Flag = 1; michael@0: debug_print( "Content Time: $Content_Time\n" ); michael@0: } michael@0: } michael@0: if (/Reflow/){ michael@0: if ($IsValidURL == 1){ michael@0: @List = split (/ /, $ThisLine); michael@0: if($useClockTime){ michael@0: @clockTimeList = split(/:/, $List[5]); michael@0: $Reflow_Time += $clockTimeList[2]; michael@0: } else { michael@0: $Reflow_Time += $List[8]; michael@0: } michael@0: $Reflow_Flag = 1; michael@0: debug_print( "Reflow Time: $Reflow_Time\n" ); michael@0: } michael@0: } michael@0: if (/Frame construction plus/){ michael@0: if ($IsValidURL == 1){ michael@0: @List = split (/ /, $ThisLine); michael@0: if($useClockTime){ michael@0: @clockTimeList = split(/:/, $List[9]); michael@0: $FrameAndStyle_Time += $clockTimeList[2]; michael@0: } else { michael@0: $FrameAndStyle_Time += $List[12]; michael@0: } michael@0: debug_print( "Frame and Style Time: $FrameAndStyle_Time\n" ); michael@0: } michael@0: } michael@0: if (/Style/){ michael@0: if ($IsValidURL == 1){ michael@0: @List = split (/ /, $ThisLine); michael@0: if($useClockTime){ michael@0: @clockTimeList = split(/:/, $List[6]); michael@0: $Style_Time += $clockTimeList[2]; michael@0: } else { michael@0: $Style_Time += $List[9]; michael@0: } michael@0: $Style_Flag = 1; michael@0: debug_print( "Style Time: $Style_Time\n" ); michael@0: } michael@0: } michael@0: if (/Parse/){ michael@0: if ($IsValidURL == 1){ michael@0: @List = split (/ /, $ThisLine); michael@0: if($useClockTime){ michael@0: @clockTimeList = split(/:/, $List[5]); michael@0: $Parse_Time += $clockTimeList[2]; michael@0: } else { michael@0: $Parse_Time += $List[8]; michael@0: } michael@0: $Parse_Flag = 1; michael@0: debug_print( "Parse Time: $Parse_Time\n" ); michael@0: } michael@0: } michael@0: if (/Total/){ michael@0: if ($IsValidURL == 1){ michael@0: @List = split (/ /, $ThisLine); michael@0: $temp = $List[6]; michael@0: if ( michael@0: # ($temp == $WebShell) && michael@0: ($Parse_Flag == 1) && michael@0: ($Content_Flag == 1) && michael@0: ($Reflow_Flag == 1) && michael@0: ($Style_Flag == 1)){ michael@0: $TotalPageLoad_Time = $List[12]; michael@0: debug_print( "Total Page Load_Time Time: $TotalPageLoad_Time\n" ); michael@0: $Content_Flag = 0; michael@0: $Reflow_Flag = 0; michael@0: $Style_Flag = 0; michael@0: $Parse_Flag = 0; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # Calculate the significant time values michael@0: #------------------------------------------------------------------------------ michael@0: $Frame_Time = $FrameAndStyle_Time - $Style_Time; michael@0: if($Frame_Time < 0.0){ michael@0: print( "\n***** ERROR: negative FrameTime *****\n"); michael@0: $Frame_Time = 0; michael@0: } michael@0: $TotalLayout_Time = $Content_Time + $Reflow_Time + $Frame_Time + $Style_Time + $Parse_Time; michael@0: $Avg_Time = $Avg_Time + $TotalLayoutTime + $TotalPageLoad_Time; michael@0: michael@0: if( $TotalLayout_Time > 0 ){ michael@0: if ($Content_Time != 0) michael@0: { michael@0: $Content_Time_Percentage = ($Content_Time / $TotalLayout_Time) * 100; michael@0: } michael@0: if ($Reflow_Time != 0) michael@0: { michael@0: $Reflow_Time_Percentage = ($Reflow_Time / $TotalLayout_Time) * 100; michael@0: } michael@0: if ($Frame_Time != 0) michael@0: { michael@0: $Frame_Time_Percentage = ($Frame_Time / $TotalLayout_Time) * 100; michael@0: } michael@0: if ($Style_Time != 0) michael@0: { michael@0: $Style_Time_Percentage = ($Style_Time / $TotalLayout_Time) * 100; michael@0: } michael@0: if ($Parse_Time != 0) michael@0: { michael@0: $Parse_Time_Percentage = ($Parse_Time / $TotalLayout_Time) * 100; michael@0: } michael@0: if( $TotalPageLoad_Time > 0 ){ michael@0: $TotalLayout_Time_Percentage = ($TotalLayout_Time / $TotalPageLoad_Time) * 100; michael@0: } else { michael@0: $TotalLayout_Time_Percentage = 100; michael@0: } michael@0: } michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # Add current values to those in the averages-fields michael@0: #------------------------------------------------------------------------------ michael@0: $Avg_Content_Time += $Content_Time; michael@0: $Avg_Reflow_Time += $Reflow_Time; michael@0: $Avg_Frame_Time += $Frame_Time; michael@0: $Avg_Style_Time += $Style_Time; michael@0: $Avg_Parse_Time += $Parse_Time; michael@0: $Avg_TotalPageLoad_Time += $TotalPageLoad_Time; michael@0: $Avg_TotalLayout_Time += $TotalLayout_Time; michael@0: michael@0: $Avg_Content_Time_Percentage += $Content_Time_Percentage; michael@0: $Avg_Reflow_Time_Percentage += $Reflow_Time_Percentage; michael@0: $Avg_Frame_Time_Percentage += $Frame_Time_Percentage; michael@0: $Avg_Style_Time_Percentage += $Style_Time_Percentage; michael@0: $Avg_Parse_Time_Percentage += $Parse_Time_Percentage; michael@0: $Avg_TotalLayout_Time_Percentage += $TotalLayout_Time_Percentage; michael@0: michael@0: $Num_Entries += 1; michael@0: michael@0: #------------------------------------------------------------------------------ michael@0: # Now write this site's data to the table michael@0: #------------------------------------------------------------------------------ michael@0: open (TABLE_FILE, ">>table.html"); michael@0: michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: print (TABLE_FILE "
$UrlName
"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Parse_Time); michael@0: print (DEVIATION "$Parse_Time,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Parse_Time_Percentage); michael@0: print (DEVIATION "$Parse_Time_Percentage,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Content_Time); michael@0: print (DEVIATION "$Content_Time,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Content_Time_Percentage); michael@0: print (DEVIATION "$Content_Time_Percentage,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Frame_Time); michael@0: print (DEVIATION "$Frame_Time,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Frame_Time_Percentage); michael@0: print (DEVIATION "$Frame_Time_Percentage,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Style_Time); michael@0: print (DEVIATION "$Style_Time,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Style_Time_Percentage); michael@0: print (DEVIATION "$Style_Time_Percentage,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Reflow_Time); michael@0: print (DEVIATION "$Reflow_Time,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$Reflow_Time_Percentage); michael@0: print (DEVIATION "$Reflow_Time_Percentage,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$TotalLayout_Time); michael@0: print (DEVIATION "$TotalLayout_Time,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$TotalLayout_Time_Percentage); michael@0: print (DEVIATION "$TotalLayout_Time_Percentage,"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE ""); michael@0: printf (TABLE_FILE "
%4.2f
",$TotalPageLoad_Time); michael@0: print (DEVIATION "$TotalPageLoad_Time\n"); michael@0: print (TABLE_FILE ""); michael@0: michael@0: print (TABLE_FILE "\n"); michael@0: michael@0: close (LOG_FILE); michael@0: michael@0: open (AVERAGE, "> Average.txt"); michael@0: print (AVERAGE "Num Entries: $Num_Entries\n"); michael@0: print (AVERAGE "Avg Parse: $Avg_Parse_Time\n"); michael@0: print (AVERAGE "Per Parse: $Avg_Parse_Time_Percentage\n"); michael@0: print (AVERAGE "Avg Content: $Avg_Content_Time\n"); michael@0: print (AVERAGE "Per Content: $Avg_Content_Time_Percentage\n"); michael@0: print (AVERAGE "Avg Frame: $Avg_Frame_Time\n"); michael@0: print (AVERAGE "Per Frame: $Avg_Frame_Time_Percentage\n"); michael@0: print (AVERAGE "Avg Style: $Avg_Style_Time\n"); michael@0: print (AVERAGE "Per Style: $Avg_Style_Time_Percentage\n"); michael@0: print (AVERAGE "Avg Reflow: $Avg_Reflow_Time\n"); michael@0: print (AVERAGE "Per Reflow: $Avg_Reflow_Time_Percentage\n"); michael@0: print (AVERAGE "Avg TotalLayout: $Avg_TotalLayout_Time\n"); michael@0: print (AVERAGE "Per Layout: $Avg_TotalLayout_Time_Percentage\n"); michael@0: print (AVERAGE "Avg PageLoad: $Avg_TotalPageLoad_Time\n"); michael@0: close (AVERAGE);