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