2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is a perl script for splitting jprof profiles into
18 # The Initial Developer of the Original Code is L. David Baron.
19 # Portions created by the Initial Developer are Copyright (C) 2002
20 # the Initial Developer. All Rights Reserved.
23 # L. David Baron <dbaron@dbaron.org> (original author)
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
40 # split-profile.pl Documentation:
42 # This script uses jprof's includes (-i) and excludes (-e) options to
43 # split profiles into segments. It takes as input a single text file,
44 # and from that text file creates a series of jprof profiles in the
45 # directory in which it is run. It expects the application binaries
46 # with which the profile was made, including jprof, and the jprof
47 # profile data, to be in a directory called "bin" that is a subdirectory
48 # of the current directory, and it will output the profiles into the
51 # The input file format looks like the following:
54 # GetRuleCascade CSSRuleProcessor::GetRuleCascade(nsPresContext *, nsIAtom *)
55 # RuleProcessorData RuleProcessorData::RuleProcessorData(nsPresContext *, nsIContent *, nsRuleWalker *, nsCompatibility *)
57 # From this input file, the script will construct a profile called
58 # 00.html that contains the whole profile, a profile called 01-poll.html
59 # that includes only stacks with g_main_poll, a profile called
60 # 02-GetRuleCascade.html that includes only stacks that have
61 # GetRuleCascade and do not have g_main_poll, a profile called
62 # 03-RuleProcessorData.html that includes only stacks that have the
63 # RuleProcessorData constructor and do not have GetRuleCascade or
64 # g_main_poll, and a profile called 04.html that includes only stacks
65 # that do not have any of the three functions in them.
67 # This means that all of the segments of the profile, except 00.html,
68 # are mutually exclusive. Thus clever ordering of the functions in the
69 # input file can lead to a logical splitting of the profile into
81 open(INFO
, "<$fname");
86 my $idx = index($line, " ");
87 my $name = substr($line, 0, $idx);
88 my $sig = substr($line, $idx+1);
97 my ($options, $outfile) = @_;
99 print "./jprof$options mozilla-bin jprof-log > ../$outfile.html\n";
100 system "./jprof$options mozilla-bin jprof-log > ../$outfile.html";
104 run_profile
("", "00");
106 for (my $i = 0; $i <= $#names + 1; ++$i) {
108 for (my $j = 0; $j < $i; ++$j) {
109 $options .= " -e\"$sigs[$j]\"";
112 $options .= " -i\"$sigs[$i]\"";
122 run_profile
($options, "$num-$names[$i]");
124 run_profile
($options, "$num");
129 ($#ARGV == 0) || die "Usage: split-profile.pl <info-file>\n";
132 chdir "bin" || die "Can't change directory to bin.";