Skip to content

Commit

Permalink
color=js for JavaScript
Browse files Browse the repository at this point in the history
  • Loading branch information
brendangregg committed Dec 5, 2014
1 parent bf11320 commit df6c5c3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion flamegraph.pl
Expand Up @@ -133,7 +133,7 @@
--countname # count type label (default "samples")
--nametype # name type label (default "Function:")
--colors # set color palette. choices are: hot (default), mem, io,
# java, red, green, blue, yellow, purple, orange
# java, js, red, green, blue, yellow, purple, orange
--hash # colors are keyed by function name hash
--cp # use consistent palette (palette.map)
--reverse # generate stack-reversed flame graph
Expand Down Expand Up @@ -326,6 +326,20 @@ sub color {
}
# fall-through to color palettes
}
if (defined $type and $type eq "js") {
if ($name =~ /::/) { # C++
$type = "yellow";
} elsif ($name =~ m:/:) { # JavaScript (match "/" in path)
$type = "green"
} elsif ($name =~ m/:/) { # JavaScript (match ":" in builtin)
$type = "aqua"
} elsif ($name =~ m/^ *$/) { # Missing symbol
$type = "green"
} else { # system
$type = "red";
}
# fall-through to color palettes
}

# color palettes
if (defined $type and $type eq "red") {
Expand Down Expand Up @@ -353,6 +367,12 @@ sub color {
my $g = 80 + int(60 * $v1);
return "rgb($x,$g,$x)";
}
if (defined $type and $type eq "aqua") {
my $r = 50 + int(60 * $v1);
my $g = 165 + int(55 * $v1);
my $b = 165 + int(55 * $v1);
return "rgb($r,$g,$b)";
}
if (defined $type and $type eq "orange") {
my $r = 190 + int(65 * $v1);
my $g = 90 + int(65 * $v1);
Expand Down

0 comments on commit df6c5c3

Please sign in to comment.