flamegraph

Fork of flamegraph without J***S*****.
git clone git://git.laack.co/flamegraph.git
Log | Files | Refs | README

commit 4c821b895ff33fd51137df4d3eb94958eaa3615b
parent 71e5a78e835a59b4b0f2f5c6ce6fa34f22c10f77
Author: Brendan Gregg <brendan.d.gregg@gmail.com>
Date:   Thu,  6 Aug 2015 12:29:53 -0700

improve code, reduce SVG size

Diffstat:
Mflamegraph.pl | 29+++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/flamegraph.pl b/flamegraph.pl @@ -601,8 +601,13 @@ my $inc = <<INC; } // mouse-over for info - function s(info) { details.nodeValue = "$nametype " + info; } - function c() { details.nodeValue = ' '; } + function s(node) { // show + info = g_to_text(node); + details.nodeValue = "$nametype " + info; + } + function c() { // clear + details.nodeValue = ' '; + } // functions function find_child(parent, name, attr) { @@ -624,6 +629,16 @@ my $inc = <<INC; e.attributes[attr].value = e.attributes["_orig_"+attr].value; e.removeAttribute("_orig_"+attr); } + function g_to_text(e) { + var text = find_child(e, "title").firstChild.nodeValue; + return (text) + } + function g_to_func(e) { + var func = g_to_text(e); + if (func != null) + func = func.replace(/ .*/, ""); + return (func); + } function update_text(e) { var r = find_child(e, "rect"); var t = find_child(e, "text"); @@ -789,12 +804,8 @@ my $inc = <<INC; for (var i=0; i < el.length; i++){ var e = el[i]; if (e.attributes["class"].value == "func_g") { - // Scrape the function name from the onmouseover - // callback text. This is a little dirty. - var func = e.attributes["onmouseover"].value; + var func = g_to_func(e); if (func != null) { - func = func.substr(3); - func = func.replace(/ .*/, ""); var r = find_child(e, "rect"); if (r == null) { // the rect might be wrapped in an anchor @@ -897,10 +908,8 @@ while (my ($id, $node) = each %Node) { } my $nameattr = { %{ $nameattr{$func}||{} } }; # shallow clone - my $jsinfo = $info; - $jsinfo =~ s/'/\\'/g; $nameattr->{class} ||= "func_g"; - $nameattr->{onmouseover} ||= "s('".$jsinfo."')"; + $nameattr->{onmouseover} ||= "s(this)"; $nameattr->{onmouseout} ||= "c()"; $nameattr->{onclick} ||= "zoom(this)"; $nameattr->{title} ||= $info;