Skip to content

Commit

Permalink
tidy a horrid javascript frame
Browse files Browse the repository at this point in the history
  • Loading branch information
brendangregg committed Dec 5, 2014
1 parent 6468e8b commit 817c6ea
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions stackcollapse-perf.pl
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ sub remember_stack {
my $pname;
my $include_pname = 1; # include process names in stacks
my $tidy_java = 1; # condense Java signatures
my $tidy_generic = 1; # clean up function names a little

foreach (<>) {
next if m/^#/;
chomp;

if (m/^$/) {
if ($include_pname) { unshift @stack, $pname; }
if ($include_pname) {
if (defined $pname) {
unshift @stack, $pname;
} else {
unshift @stack, "";
}
}
remember_stack(join(";", @stack), 1) if @stack;
undef @stack;
undef $pname;
Expand All @@ -84,18 +91,24 @@ sub remember_stack {
} elsif (/^\s*\w+\s*(.+) (\S+)/) {
my ($func, $mod) = ($1, $2);
next if $func =~ /^\(/; # skip process names
if ($tidy_generic) {
$func =~ s/;/:/g;
$func =~ tr/<>//d;
$func =~ s/\(.*//;
# now tidy this horrible thing:
# 13a80b608e0a RegExp:[&<>\"\'] (/tmp/perf-7539.map)
$func =~ tr/"\'//d;
# fall through to $tidy_java
}
if ($tidy_java and $pname eq "java") {
# eg, convert the following:
# along with $tidy_generic, converts the following:
# Lorg/mozilla/javascript/ContextFactory;.call(Lorg/mozilla/javascript/ContextAction;)Ljava/lang/Object;
# Lorg/mozilla/javascript/ContextFactory;.call(Lorg/mozilla/javascript/C
# Lorg/mozilla/javascript/MemberBox;.<init>(Ljava/lang/reflect/Method;)V
# into:
# org/mozilla/javascript/ContextFactory:.call
# org/mozilla/javascript/ContextFactory:.call
# org/mozilla/javascript/MemberBox:.init
$func =~ s/;/:/g;
$func =~ tr/<>//d;
$func =~ s/\(.*//;
$func =~ s/^L// if $func =~ m:/:;
}
unshift @stack, $func;
Expand Down

0 comments on commit 817c6ea

Please sign in to comment.