'Devel::Dwarn' => 0,
XSLoader => 0,
},
- EXE_FILES => [ 'bin/dmemtree.pl' ],
+ EXE_FILES => [ 'bin/sizeme_store.pl' ],
(eval $ExtUtils::MakeMaker::VERSION >= 6.47 ? (MIN_PERL_VERSION => '5.005') : ()),
(eval $ExtUtils::MakeMaker::VERSION >= 6.31 ? (LICENSE => 'perl') : ()),
);
#ifdef PATH_TRACKING
/* XXX quick hack */
- st->node_stream_name = getenv("PERL_DMEM");
+ st->node_stream_name = getenv("SIZEME");
if (st->node_stream_name) {
if (*st->node_stream_name) {
if (*st->node_stream_name == '|')
+TODO
+
+ Rename to Devel::SizeMe
+ Devel::SizeMe::Core - loads XS and sets options
+ Devel::SizeMe - loads XS
+ -d:SizeMe=opts
+ Devel::SizeMe::Stream - parse raw stream
+ Devel::SizeMe::Store - db write
+ Devel::SizeMe::Data - db read / orlite?
+ Devel::SizeMe::Graph - data reading/processing for sizeme_graph
+ sizeme_store
+ sizeme_graph
+ tests
+ Add R(un) and E(nd) tokens
+ Support multiple runs
+ Name runs to allow total_size (for example) of multiple data structures
+
+Optimizations:
+ Remove depth from stream?
+Future
+ Add addr to leaf to visualize memory layout
+ Add token for ptr to node already seen (identified by addr I presume)
+ so we can move from a Tree to a DAG and see alternative name paths.
+
+
=pod
Devel::Memory - Perl extension for finding the memory usage of Perl variables
'showid!' => \my $opt_showid,
) or exit 1;
+my $run_size = 0;
+my $total_size = 0;
+
my $j = JSON::XS->new->ascii->pretty(0);
my ($dbh, $node_ins_sth);
elsif ($type eq "L") {
my $node = $seqn2node{$id} || die;
$node->{leaves}{$name} += $val;
- printf "%s+%d %s\n", $indent x ($node->{depth}+1), $val, $name
+ $run_size += $val;
+ printf "%s+%d=%d %s\n", $indent x ($node->{depth}+1), $val, $run_size, $name
if $opt_text;
}
}
my $top = $stack[0]; # grab top node before we pop all the nodes
leave_node(pop @stack) while @stack;
+my $top_size = $top->{self_size}+$top->{kids_size};
+
+printf "Stored %d nodes recording %s (%d)\n",
+ $top->{kids_node_count}, fmt_size($top_size), $top_size;
-if ($opt_verbose) {
+if ($opt_verbose or $run_size != $top_size) {
warn "EOF ends $top->{id} d$top->{depth}: size $top->{self_size}+$top->{kids_size}\n";
warn Dumper($top);
}
--- /dev/null
+package Devel::SizeMe;
+
+require Devel::Memory;
+
+$ENV{SIZEME} = "|sizeme_store.pl --db sizeme.db";
+
+# It's handy to say "perl -d:SizeMe" but has side effects
+# currently we simple disable the debugger (as best we can)
+# otherwise it (or rather some bits of $^P) cause memory bloat.
+# we might want to provide some smarter compatibility in future.
+# We might also want to provide a way to set some bits, such as
+# 0x10 Keep info about source lines on which a sub is defined
+# 0x100 Provide informative "file" names for evals
+# 0x200 Provide informative names to anonymous subroutines
+if ($^P) { # default is 0x73f
+ warn "Note: Devel::SizeMe currently disables perl debugger mode\n";
+ $^P = 0;
+}
+
+END {
+ Devel::Memory::perl_size();
+}
+
+1;