2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # split-profile.pl Documentation:
9 # This script uses jprof's includes (-i) and excludes (-e) options to
10 # split profiles into segments. It takes as input a single text file,
11 # and from that text file creates a series of jprof profiles in the
12 # directory in which it is run. It expects the application binaries
13 # with which the profile was made, including jprof, and the jprof
14 # profile data, to be in a directory called "bin" that is a subdirectory
15 # of the current directory, and it will output the profiles into the
18 # The input file format looks like the following:
21 # GetRuleCascade CSSRuleProcessor::GetRuleCascade(nsPresContext *, nsIAtom *)
22 # RuleProcessorData RuleProcessorData::RuleProcessorData(nsPresContext *, nsIContent *, nsRuleWalker *, nsCompatibility *)
24 # From this input file, the script will construct a profile called
25 # 00.html that contains the whole profile, a profile called 01-poll.html
26 # that includes only stacks with g_main_poll, a profile called
27 # 02-GetRuleCascade.html that includes only stacks that have
28 # GetRuleCascade and do not have g_main_poll, a profile called
29 # 03-RuleProcessorData.html that includes only stacks that have the
30 # RuleProcessorData constructor and do not have GetRuleCascade or
31 # g_main_poll, and a profile called 04.html that includes only stacks
32 # that do not have any of the three functions in them.
34 # This means that all of the segments of the profile, except 00.html,
35 # are mutually exclusive. Thus clever ordering of the functions in the
36 # input file can lead to a logical splitting of the profile into
48 open(INFO
, "<$fname");
53 my $idx = index($line, " ");
54 my $name = substr($line, 0, $idx);
55 my $sig = substr($line, $idx+1);
64 my ($options, $outfile) = @_;
66 print "./jprof$options mozilla-bin jprof-log > ../$outfile.html\n";
67 system "./jprof$options mozilla-bin jprof-log > ../$outfile.html";
71 run_profile
("", "00");
73 for (my $i = 0; $i <= $#names + 1; ++$i) {
75 for (my $j = 0; $j < $i; ++$j) {
76 $options .= " -e\"$sigs[$j]\"";
79 $options .= " -i\"$sigs[$i]\"";
89 run_profile
($options, "$num-$names[$i]");
91 run_profile
($options, "$num");
96 ($#ARGV == 0) || die "Usage: split-profile.pl <info-file>\n";
99 chdir "bin" || die "Can't change directory to bin.";