tools/performance/layout/uncombine.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 ##########################################################################################
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 # uncombine.pl : Break up the combined performance run output file into a file per URL
michael@0 8 #
michael@0 9 # When viewer or mozilla are run and provided a command line argument of '-f urlfile.txt'
michael@0 10 # then the file 'urlfile.txt' is read and each line is expected to be a URL. The browser
michael@0 11 # then cycles through each url and loads it, waiting for the load to end or a safety
michael@0 12 # timeout to occur. In eaiter case the next url is loaded until there are no more and then
michael@0 13 # the browser exits. The output from the run (stdout) is captured to a file which then
michael@0 14 # contains all of the performance output we need to build charts of performance numbers
michael@0 15 # (see average2.pl, along with header.pl and footer.pl).
michael@0 16 #
michael@0 17 # ASSUMES file urls are pathed as: file:///S|/Mozilla/Tools/ProfTools/WebSites/URL/FILE
michael@0 18 # or if an http URL: http://URL/FILE
michael@0 19 # Normally it is expected that local files will be used, however if we should use http
michael@0 20 # URLs they can be processed (have not tested to date...)
michael@0 21 #
michael@0 22 # For file urls, the websites tree is assumed to be the one committed to cvs. Installed
michael@0 23 # files will be at s:\mozilla\tools\perftools\websites\url\file
michael@0 24 # If you have the files in a different location, adjust the part that extracts the url
michael@0 25 # (most likely the index into the tokens will change. Search for SENSITIVE in the script)
michael@0 26
michael@0 27 #------------------------------------------------------------------------------
michael@0 28 sub debug_print {
michael@0 29 foreach $str (@_){
michael@0 30 # print( $str );
michael@0 31 }
michael@0 32 }
michael@0 33 #------------------------------------------------------------------------------
michael@0 34
michael@0 35
michael@0 36 @ARGV;
michael@0 37 $dir="Logs\\";
michael@0 38 $i=0;
michael@0 39 $TimingBlockBegun=0;
michael@0 40 $fileURL=0;
michael@0 41 $httpURL=0;
michael@0 42 $shellID;
michael@0 43 $infileName = $ARGV[0];
michael@0 44 $supportHTTP = 0; # set to 1 if HTTP URLs are to be supported
michael@0 45
michael@0 46 open(COMBINEFILE, "< $infileName") or die "Unable to open $infileName\n";
michael@0 47 while(<COMBINEFILE>){
michael@0 48 $url;
michael@0 49 @tokens = split( / /, $_ );
michael@0 50
michael@0 51 if($TimingBlockBegun == 0) {
michael@0 52 # look for the start of a new block
michael@0 53 if($_ =~ /Timing layout processes on url/){
michael@0 54 debug_print( "Timing begin candidate: $_ \n" );
michael@0 55
michael@0 56 # see if it is a file or http url.
michael@0 57 # If so, we are starting, otherwise it is probably a chrome url so ignore it
michael@0 58 if( $_ =~ /url: \'file:/ ){
michael@0 59 debug_print( " - file URL\n" );
michael@0 60 $url = $tokens[6];
michael@0 61 $TimingBlockBegun=1;
michael@0 62 $httpURL=0;
michael@0 63 $fileURL=1;
michael@0 64 }
michael@0 65 if($supportHTTP > 0) {
michael@0 66 if( $_ =~ /url: \'http:/ ){
michael@0 67 debug_print( "http URL\n" );
michael@0 68 $url = $tokens[6]; ### SENSITIVE to installation path
michael@0 69 $TimingBlockBegun=1;
michael@0 70 $fileURL=0;
michael@0 71 $httpURL=1;
michael@0 72 }
michael@0 73 }
michael@0 74
michael@0 75 # if we got a valid block then extract the WebShellID
michael@0 76 # for matching the end-of-block later
michael@0 77 if($TimingBlockBegun > 0){
michael@0 78 chop($url);
michael@0 79 $shellID = $tokens[8];
michael@0 80 chop( $shellID );
michael@0 81 debug_print( " - WebShellID: $shellID\n");
michael@0 82 @urlParts = split(/\//, $url);
michael@0 83 if($fileURL > 0){
michael@0 84 $urlName = $urlParts[9]; ### SENSITIVE to installation path
michael@0 85 ### eg. 'file:///S|/Mozilla/Tools/performance/layout/WebSites/amazon/index.html'
michael@0 86 } else {
michael@0 87 $urlName = $urlParts[2]; ### http://all.of.this.is.the.url.name/index.html
michael@0 88 }
michael@0 89 open(URLFILE, ">$dir$urlName-log"."\.txt") or die "cannot open file $dir$urlName\n";
michael@0 90 print("Breaking out url $url into "."$dir$urlName-log"."\.txt"."\n");
michael@0 91 }
michael@0 92 }
michael@0 93 }
michael@0 94
michael@0 95 if($TimingBlockBegun > 0){
michael@0 96 $done=0;
michael@0 97 $keepLine=1;
michael@0 98 # Look for end of block:
michael@0 99 # - Find the line with the "Layout + Page Load" in it...
michael@0 100 if( $_ =~ /Layout \+ Page Load/ ){
michael@0 101 # Match the WebShell ID - if it is a match then our block ended,
michael@0 102 # otherwise it is the end of another block within our block
michael@0 103 $webshellID = "\(webBrowserChrome=".$shellID."\)";
michael@0 104 if( $tokens[6] =~ /$webshellID/ ){
michael@0 105 debug_print( "- WebShellID MATCH: $webshellID $tokens[6]\n" );
michael@0 106 $done=1;
michael@0 107 } else {
michael@0 108 $keepLine=0;
michael@0 109 }
michael@0 110 }
michael@0 111 if($keepLine == 1){
michael@0 112 # write the line to the file
michael@0 113 print(URLFILE $_);
michael@0 114 }
michael@0 115 if($done == 1){
michael@0 116 $TimingBlockBegun=0;
michael@0 117 close(URLFILE);
michael@0 118 }
michael@0 119 }
michael@0 120 $i++;
michael@0 121 }

mercurial