http://qs1969.pair.com?node_id=1216051

perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:

I added some testing routines in a prog I have, and added code to disable them unless I select the tests from the command line.
if (DEBUG_ENABLED) { ... 54 lines of somewhat dense code (1.7k chars). }

What I want to find out is if disabling it really reduces memory size. FWIW, DEBUG_ENABLED is optimized to a constant, so theoretically, perl should be able to throw away anything in the braces and I should see a smaller package size. Am trying to find out if theory matches reality. :-)

The memory routines I've seen don't seem to allow inspecting the size of a package, especially w/r/t breaking down:
code 47.5KB
data 30KB

Of course ideally it would be something like this FF extension (showing memory related to this page):
(about:memory shows the usage for the entire browser, and the detail view shows that sources are stored where in memory).

│ ├──19.49 MB (04.40%) -- top(http://perlmonks.org/?node=Seekers of Perl Wisdom, id=9)
│ │ ├──12.25 MB (02.77%) -- cached
│ │ │ ├───6.31 MB (01.42%) -- window(http://perlmonks.org/?node_id=6364;user=438862)
│ │ │ │ ├──5.44 MB (01.23%) -- layout
│ │ │ │ │ ├──4.94 MB (01.12%) ── style-sets
│ │ │ │ │ └──0.51 MB (00.11%) ++ (6 tiny)
│ │ │ │ └──0.86 MB (00.20%) ++ (4 tiny)
│ │ │ └───5.95 MB (01.34%) -- window(http://perlmonks.org/?node_id=438862)
│ │ │ ├──5.26 MB (01.19%) -- layout
│ │ │ │ ├──4.94 MB (01.12%) ── style-sets
│ │ │ │ └──0.33 MB (00.07%) ++ (6 tiny)
│ │ │ └──0.68 MB (00.15%) ++ (4 tiny)
│ │ ├───6.71 MB (01.52%) -- active/window(http://perlmonks.org/?node=Seekers of Perl Wisdom)
│ │ │ ├──5.76 MB (01.30%) -- layout
│ │ │ │ ├──4.94 MB (01.12%) ── style-sets
│ │ │ │ └──0.82 MB (00.19%) ++ (6 tiny)
│ │ │ └──0.95 MB (00.22%) ++ (4 tiny)
│ │ └───0.52 MB (00.12%) ++ js-zone(0x1c187000)
│ ├──11.51 MB (02.60%) -- top(none)
│ │ ├───7.24 MB (01.63%) -- ghost
│ │ │ ├──4.78 MB (01.08%) -- window(https://log.perl.org/2018/05/goodbye-search-dot-cpan-dot-org.html)
│ │ │ │ ├──4.78 MB (01.08%) ++ js-compartment(https://log.perl.org/2018/05/goodbye-search-dot-cpan-dot-org.html)
│ │ │ │ └──0.00 MB (00.00%) ++ dom
│ │ │ └──2.46 MB (00.56%) ++ window(https://log.perl.org/2018/03/goodbye-bitcard.html#comment-form)
│ │ └───4.27 MB (00.96%) ++ detached/window(system)

Anyway, just the code amount is really what I'm interested in, since there aren't any permanent vars in that section, the other vars should just be on the stack.

Seems like there are several related to showing data sizes, and there fairly good tools for measuring cpu usage, but not so much when it comes to code usage...

Ideals? Suggestions?