1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/performance/layout/uncombine.pl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,121 @@ 1.4 +########################################################################################## 1.5 +# 1.6 +# This Source Code Form is subject to the terms of the Mozilla Public 1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.9 + 1.10 +# uncombine.pl : Break up the combined performance run output file into a file per URL 1.11 +# 1.12 +# When viewer or mozilla are run and provided a command line argument of '-f urlfile.txt' 1.13 +# then the file 'urlfile.txt' is read and each line is expected to be a URL. The browser 1.14 +# then cycles through each url and loads it, waiting for the load to end or a safety 1.15 +# timeout to occur. In eaiter case the next url is loaded until there are no more and then 1.16 +# the browser exits. The output from the run (stdout) is captured to a file which then 1.17 +# contains all of the performance output we need to build charts of performance numbers 1.18 +# (see average2.pl, along with header.pl and footer.pl). 1.19 +# 1.20 +# ASSUMES file urls are pathed as: file:///S|/Mozilla/Tools/ProfTools/WebSites/URL/FILE 1.21 +# or if an http URL: http://URL/FILE 1.22 +# Normally it is expected that local files will be used, however if we should use http 1.23 +# URLs they can be processed (have not tested to date...) 1.24 +# 1.25 +# For file urls, the websites tree is assumed to be the one committed to cvs. Installed 1.26 +# files will be at s:\mozilla\tools\perftools\websites\url\file 1.27 +# If you have the files in a different location, adjust the part that extracts the url 1.28 +# (most likely the index into the tokens will change. Search for SENSITIVE in the script) 1.29 + 1.30 +#------------------------------------------------------------------------------ 1.31 +sub debug_print { 1.32 + foreach $str (@_){ 1.33 +# print( $str ); 1.34 + } 1.35 +} 1.36 +#------------------------------------------------------------------------------ 1.37 + 1.38 + 1.39 +@ARGV; 1.40 +$dir="Logs\\"; 1.41 +$i=0; 1.42 +$TimingBlockBegun=0; 1.43 +$fileURL=0; 1.44 +$httpURL=0; 1.45 +$shellID; 1.46 +$infileName = $ARGV[0]; 1.47 +$supportHTTP = 0; # set to 1 if HTTP URLs are to be supported 1.48 + 1.49 +open(COMBINEFILE, "< $infileName") or die "Unable to open $infileName\n"; 1.50 +while(<COMBINEFILE>){ 1.51 + $url; 1.52 + @tokens = split( / /, $_ ); 1.53 + 1.54 + if($TimingBlockBegun == 0) { 1.55 + # look for the start of a new block 1.56 + if($_ =~ /Timing layout processes on url/){ 1.57 + debug_print( "Timing begin candidate: $_ \n" ); 1.58 + 1.59 + # see if it is a file or http url. 1.60 + # If so, we are starting, otherwise it is probably a chrome url so ignore it 1.61 + if( $_ =~ /url: \'file:/ ){ 1.62 + debug_print( " - file URL\n" ); 1.63 + $url = $tokens[6]; 1.64 + $TimingBlockBegun=1; 1.65 + $httpURL=0; 1.66 + $fileURL=1; 1.67 + } 1.68 + if($supportHTTP > 0) { 1.69 + if( $_ =~ /url: \'http:/ ){ 1.70 + debug_print( "http URL\n" ); 1.71 + $url = $tokens[6]; ### SENSITIVE to installation path 1.72 + $TimingBlockBegun=1; 1.73 + $fileURL=0; 1.74 + $httpURL=1; 1.75 + } 1.76 + } 1.77 + 1.78 + # if we got a valid block then extract the WebShellID 1.79 + # for matching the end-of-block later 1.80 + if($TimingBlockBegun > 0){ 1.81 + chop($url); 1.82 + $shellID = $tokens[8]; 1.83 + chop( $shellID ); 1.84 + debug_print( " - WebShellID: $shellID\n"); 1.85 + @urlParts = split(/\//, $url); 1.86 + if($fileURL > 0){ 1.87 + $urlName = $urlParts[9]; ### SENSITIVE to installation path 1.88 + ### eg. 'file:///S|/Mozilla/Tools/performance/layout/WebSites/amazon/index.html' 1.89 + } else { 1.90 + $urlName = $urlParts[2]; ### http://all.of.this.is.the.url.name/index.html 1.91 + } 1.92 + open(URLFILE, ">$dir$urlName-log"."\.txt") or die "cannot open file $dir$urlName\n"; 1.93 + print("Breaking out url $url into "."$dir$urlName-log"."\.txt"."\n"); 1.94 + } 1.95 + } 1.96 + } 1.97 + 1.98 + if($TimingBlockBegun > 0){ 1.99 + $done=0; 1.100 + $keepLine=1; 1.101 + # Look for end of block: 1.102 + # - Find the line with the "Layout + Page Load" in it... 1.103 + if( $_ =~ /Layout \+ Page Load/ ){ 1.104 + # Match the WebShell ID - if it is a match then our block ended, 1.105 + # otherwise it is the end of another block within our block 1.106 + $webshellID = "\(webBrowserChrome=".$shellID."\)"; 1.107 + if( $tokens[6] =~ /$webshellID/ ){ 1.108 + debug_print( "- WebShellID MATCH: $webshellID $tokens[6]\n" ); 1.109 + $done=1; 1.110 + } else { 1.111 + $keepLine=0; 1.112 + } 1.113 + } 1.114 + if($keepLine == 1){ 1.115 + # write the line to the file 1.116 + print(URLFILE $_); 1.117 + } 1.118 + if($done == 1){ 1.119 + $TimingBlockBegun=0; 1.120 + close(URLFILE); 1.121 + } 1.122 + } 1.123 + $i++; 1.124 +}