2 # perl file to get a list of files that we load from a timeline log
4 # Usage: perl getlines.pl < timline.log > file.log
6 # Configuration options
8 # Set this option to take all timings only upto the main window being visible
9 # All activity beyond main window being visible is ignored.
10 # default is 0. We take timings upto main1 finish
11 $stopWithVisibleWindow = 0;
15 # Files of a particular extensions
17 # Number of files in a paticular extension. Used to sort them output by order of extension
19 # List of all urls that either exist or are jar. Non dups.
21 # List of nonexistent file urls
22 my @nonexistentfiles = ();
27 # Urls hash to figure out dups
29 # Number of dups per extension
31 # interesting total times
35 # when main window was visible
43 # Computer breakdown of startup cost
45 # This is a cumulative timer. Keep track of it.
46 /^[0-9\.: ]*(.*) total: ([0-9\.]*)/;
49 if (/InitXPCom\.\.\./) {
50 $breakdown{"Before InitXPCom"} = getTimelineStamp
($_);
53 if (/InitXPCOM done/) {
54 $breakdown{"InitXPCom"} = getTimelineStamp
($_) - $breakdown{"Before InitXPCom"};
58 # Find main1's cost to compute percentages
60 $main1 = getTimelineStamp
($_);
62 # find when we showed the window
63 if (/Navigator Window visible now/) {
64 $window = getTimelineStamp
($_);
65 if ($stopWithVisibleWindow) {
71 # Find all files loaded
72 if (/PR_LoadLibrary/) {
78 $url = getfileurl
($_);
81 push @nonexistentfiles, $url;
84 if ($seen{$url} > 1) {
89 if (exists $ext{$e}) {
102 if ($seen{$url} > 1) {
107 if (exists $ext{$e}) {
115 if (/load pref file/) {
123 print "----------------------------------------------------------------------\n";
124 print "Total startup time : $main1 sec\n";
125 printf "Main window visible: $window sec (%5.2f%%)\n", main1Percent
($window);
126 print "dlls loaded : ", $#dlls+1, "\n";
127 print "Total unique: ", $#allurls+1, " [jar $njarurl, file $nfileurl]\n";
128 # print the # of files by extensions sorted
129 my @extsorted = sort { $extnum{$b} <=> $extnum{$a} } keys %extnum;
131 foreach $i (@extsorted)
133 print "$sep.$i $extnum{$i}";
137 # print number of dups per extension
139 foreach $i (@extsorted)
141 next unless exists($extnumdups{$i});
142 print "$sep.$i $extnumdups{$i}";
146 print "Total non existent files : ", $#nonexistentfiles+1, "\n";
149 print "Cost Breakdown\n";
150 print "----------------------------------------------------------------------\n";
151 # sort by descending order of breakdown cost
152 my @breakdownsorted = sort { $breakdown{$b} <=> $breakdown{$a} } keys %breakdown;
153 my $totalAccounted = 0;
154 foreach $e (@breakdownsorted)
156 # ignore these breakdowns as they are already counted otherwise
157 next if ($e =~ /nsNativeComponentLoader::GetFactory/);
158 my $p = main1Percent
($breakdown{$e});
160 printf "%6.2f%% %s\n", $p, $e;
161 $totalAccounted += $p;
163 print "----------------------\n";
164 printf "%6.2f%% Total Accounted\n", $totalAccounted;
167 printf "[%d] List of dlls loaded:\n", $#dlls+1;
168 print "----------------------------------------------------------------------\n";
172 printf "%2d. %s\n", $n++, $e;
176 printf "[%d] List of existing unique files and jar urls by extension:\n", $#allurls+1;
177 print "----------------------------------------------------------------------\n";
178 foreach $e (@extsorted)
181 print "[$extnum{$e}] .$e\n";
182 foreach $i (split("---", $ext{$e})) {
183 printf "%2d. %s", $n++, $i;
185 printf " [%d]", $seen{$i}-1;
191 #foreach $i (@allurls)
193 # printf "%2d. %s\n", $n++, $i;
197 printf "[%d] List of non existent file urls:\n", $#nonexistentfiles+1;
198 print "----------------------------------------------------------------------\n";
200 foreach $i (@nonexistentfiles)
202 printf "%2d. %s\n", $n++, $i;
207 printf "[%d] List of pref files loaded:\n", $#prefurl+1;
208 print "----------------------------------------------------------------------\n";
210 foreach $i (@prefurl)
212 printf "%2d. %s\n", $n++, $i;
216 sub getTimelineStamp
() {
218 $line =~ /^([0-9\.]*)/;
224 $f =~ s/^.*file:\/*(.*)\).*$/\
1/;
233 $f =~ s/^.*(jar:.*)\).*$/\1/;
239 $f =~ s/^.*\((.*)\).*$/\1/;
245 $f =~ s/^.*\.([^\.]*)$/\1/;
251 $f =~ s/^.*\((.*)\)$/\1/;
255 # what % is this of startup
258 return $i/$main1 * 100;