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: # uncombine.pl : Break up the combined performance run output file into a file per URL michael@0: # michael@0: # When viewer or mozilla are run and provided a command line argument of '-f urlfile.txt' michael@0: # then the file 'urlfile.txt' is read and each line is expected to be a URL. The browser michael@0: # then cycles through each url and loads it, waiting for the load to end or a safety michael@0: # timeout to occur. In eaiter case the next url is loaded until there are no more and then michael@0: # the browser exits. The output from the run (stdout) is captured to a file which then michael@0: # contains all of the performance output we need to build charts of performance numbers michael@0: # (see average2.pl, along with header.pl and footer.pl). michael@0: # michael@0: # ASSUMES file urls are pathed as: file:///S|/Mozilla/Tools/ProfTools/WebSites/URL/FILE michael@0: # or if an http URL: http://URL/FILE michael@0: # Normally it is expected that local files will be used, however if we should use http michael@0: # URLs they can be processed (have not tested to date...) michael@0: # michael@0: # For file urls, the websites tree is assumed to be the one committed to cvs. Installed michael@0: # files will be at s:\mozilla\tools\perftools\websites\url\file michael@0: # If you have the files in a different location, adjust the part that extracts the url michael@0: # (most likely the index into the tokens will change. Search for SENSITIVE in the script) 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: michael@0: michael@0: @ARGV; michael@0: $dir="Logs\\"; michael@0: $i=0; michael@0: $TimingBlockBegun=0; michael@0: $fileURL=0; michael@0: $httpURL=0; michael@0: $shellID; michael@0: $infileName = $ARGV[0]; michael@0: $supportHTTP = 0; # set to 1 if HTTP URLs are to be supported michael@0: michael@0: open(COMBINEFILE, "< $infileName") or die "Unable to open $infileName\n"; michael@0: while(){ michael@0: $url; michael@0: @tokens = split( / /, $_ ); michael@0: michael@0: if($TimingBlockBegun == 0) { michael@0: # look for the start of a new block michael@0: if($_ =~ /Timing layout processes on url/){ michael@0: debug_print( "Timing begin candidate: $_ \n" ); michael@0: michael@0: # see if it is a file or http url. michael@0: # If so, we are starting, otherwise it is probably a chrome url so ignore it michael@0: if( $_ =~ /url: \'file:/ ){ michael@0: debug_print( " - file URL\n" ); michael@0: $url = $tokens[6]; michael@0: $TimingBlockBegun=1; michael@0: $httpURL=0; michael@0: $fileURL=1; michael@0: } michael@0: if($supportHTTP > 0) { michael@0: if( $_ =~ /url: \'http:/ ){ michael@0: debug_print( "http URL\n" ); michael@0: $url = $tokens[6]; ### SENSITIVE to installation path michael@0: $TimingBlockBegun=1; michael@0: $fileURL=0; michael@0: $httpURL=1; michael@0: } michael@0: } michael@0: michael@0: # if we got a valid block then extract the WebShellID michael@0: # for matching the end-of-block later michael@0: if($TimingBlockBegun > 0){ michael@0: chop($url); michael@0: $shellID = $tokens[8]; michael@0: chop( $shellID ); michael@0: debug_print( " - WebShellID: $shellID\n"); michael@0: @urlParts = split(/\//, $url); michael@0: if($fileURL > 0){ michael@0: $urlName = $urlParts[9]; ### SENSITIVE to installation path michael@0: ### eg. 'file:///S|/Mozilla/Tools/performance/layout/WebSites/amazon/index.html' michael@0: } else { michael@0: $urlName = $urlParts[2]; ### http://all.of.this.is.the.url.name/index.html michael@0: } michael@0: open(URLFILE, ">$dir$urlName-log"."\.txt") or die "cannot open file $dir$urlName\n"; michael@0: print("Breaking out url $url into "."$dir$urlName-log"."\.txt"."\n"); michael@0: } michael@0: } michael@0: } michael@0: michael@0: if($TimingBlockBegun > 0){ michael@0: $done=0; michael@0: $keepLine=1; michael@0: # Look for end of block: michael@0: # - Find the line with the "Layout + Page Load" in it... michael@0: if( $_ =~ /Layout \+ Page Load/ ){ michael@0: # Match the WebShell ID - if it is a match then our block ended, michael@0: # otherwise it is the end of another block within our block michael@0: $webshellID = "\(webBrowserChrome=".$shellID."\)"; michael@0: if( $tokens[6] =~ /$webshellID/ ){ michael@0: debug_print( "- WebShellID MATCH: $webshellID $tokens[6]\n" ); michael@0: $done=1; michael@0: } else { michael@0: $keepLine=0; michael@0: } michael@0: } michael@0: if($keepLine == 1){ michael@0: # write the line to the file michael@0: print(URLFILE $_); michael@0: } michael@0: if($done == 1){ michael@0: $TimingBlockBegun=0; michael@0: close(URLFILE); michael@0: } michael@0: } michael@0: $i++; michael@0: }