From: Tim Bunce Date: Wed, 19 Sep 2012 10:30:57 +0000 (+0100) Subject: A little polish X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5a78486c45f5fbebbc7caa1459a685eca635a48f;p=p5sagit%2FDevel-Size.git A little polish --- diff --git a/memnodes.pl b/memnodes.pl index 94198ea..0ac6617 100644 --- a/memnodes.pl +++ b/memnodes.pl @@ -23,12 +23,12 @@ $dbh->do(q{ id integer primary key, name text, depth integer, - parent_seqn integer, + parent_id integer, self_size integer, kids_size integer, kids_node_count integer, - child_seqns text + child_ids text ) }); my $node_ins_sth = $dbh->prepare(q{ @@ -54,11 +54,11 @@ sub leave_node { $x->{self_size} = $self_size; if (my $parent = $stack[-1]) { # link to parent - $x->{parent_seqn} = $parent->{id}; + $x->{parent_id} = $parent->{id}; # accumulate into parent $parent->{kids_node_count} += 1 + ($x->{kids_node_count}||0); $parent->{kids_size} += $self_size + $x->{kids_size}; - push @{$parent->{child_seqn}}, $x->{id}; + push @{$parent->{child_id}}, $x->{id}; } # output # ... @@ -69,9 +69,9 @@ sub leave_node { } if ($dbh) { $node_ins_sth->execute( - $x->{id}, $x->{name}, $x->{depth}, $x->{parent_seqn}, + $x->{id}, $x->{name}, $x->{depth}, $x->{parent_id}, $x->{self_size}, $x->{kids_size}, $x->{kids_node_count}, - $x->{child_seqn} ? join(",", @{$x->{child_seqn}}) : undef + $x->{child_id} ? join(",", @{$x->{child_id}}) : undef ); # XXX attribs } diff --git a/static/MemView.pl b/static/MemView.pl index 204853a..2133621 100755 --- a/static/MemView.pl +++ b/static/MemView.pl @@ -52,21 +52,26 @@ sub _fetch_node_tree { my ($id, $depth) = @_; my $node = MemView->selectrow_hashref("select * from node where id = ?", undef, $id) or die "Node '$id' not found"; - if ($node->{child_seqns}) { - my @child_seqns = split /,/, $node->{child_seqns}; + if ($node->{child_ids}) { + my @child_ids = split /,/, $node->{child_ids}; my $children; - if (@child_seqns == 1) { - my $child = _fetch_node_tree($child_seqns[0], $depth); # same depth + if (@child_ids == 1) { + my $child = _fetch_node_tree($child_ids[0], $depth); # same depth # merge node into child - # XXX id, depth, parent_seqn + # XXX id, depth, parent_id warn "Merged $node->{name} #$node->{id} with only child $child->{name} #$child->{id}\n"; $child->{name} = "$node->{name} + $child->{name}"; $child->{$_} += $node->{$_} for (qw(self_size)); - $child->{$_} = $node->{$_} for (qw(parent_seqn)); + $child->{$_} = $node->{$_} for (qw(parent_id)); + + $child->{_ids_merged} .= ",$node->{id}"; + my @child_ids = split /,/, $node->{child_ids}; + $child->{child_count} = @child_ids; + $node = $child; } elsif ($depth) { - $children = [ map { _fetch_node_tree($_, $depth-1) } @child_seqns ]; + $children = [ map { _fetch_node_tree($_, $depth-1) } @child_ids ]; $node->{children} = $children; $node->{child_count} = @$children; } diff --git a/static/public/.tm.js.swp b/static/public/.tm.js.swp index d77f1b1..b590f45 100644 Binary files a/static/public/.tm.js.swp and b/static/public/.tm.js.swp differ diff --git a/static/public/tm.js b/static/public/tm.js index 0bb0dd8..44230ee 100644 --- a/static/public/tm.js +++ b/static/public/tm.js @@ -34,9 +34,9 @@ function init(){ //where to inject the visualization injectInto: 'infovis', //show only one tree level - levelsToShow: 2, + levelsToShow: 1, //parent box title heights - titleHeight: 10, + titleHeight: 11, //enable animations animate: animate, //box offsets @@ -84,7 +84,7 @@ function init(){ } }, //duration of the animations - duration: 1000, + duration: 500, //Enable tips Tips: { enable: true, @@ -100,21 +100,14 @@ function init(){ + "
"; var data = node.data; - //"child_seqns" => 4, - //"depth" => 2, - //"id" => 3, - //"kids_node_count" => 4426, - //"kids_size" => 560058, - //"name" => "SV(PVHV)", - //"parent_seqn" => 2, - //"self_size" => 1080, - - html += sprintf("Name: %s
\n", data.name); html += sprintf("Size: %d (%d + %d)
", data.self_size+data.kids_size, data.self_size, data.kids_size); if (data.child_count) { html += sprintf("Children: %d of %d
", data.child_count, data.kids_node_count); } - html += JSON.stringify(data, undefined, 4); + html += sprintf("Depth: %d
", data.depth); + html += sprintf("Parent: %d
", data.parent_id); + html += sprintf("Id: %s%s
", node.id, data._ids_merged ? data._ids_merged : ""); + //html += JSON.stringify(data, undefined, 4); tip.innerHTML = html; }