Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

acme (189)

  (email not shown publicly)

Leon Brocard (aka acme) is an orange-loving Perl eurohacker with many varied contributions to the Perl community, including the GraphViz module on the CPAN. YAPC::Europe was all his fault. He is still looking for a Perl Monger group he can start which begins with the letter 'D'.

Journal of acme (189)

Wednesday January 31, 2007
09:42 AM

How big?

[ #32288 ]

Memory is cheap and a common Perl trick is to trade memory for performance - but how do you know how much memory a data structure is using? With Devel::Size and Number::Bytes::Human:

warn '$photos takes up ' . format_bytes( total_size($photos) ) if $DEBUG;

This outputs something like:

$photos takes up 2.3M

2.3M! That's so small, I can easily stick a hundred times more photos in there before worrying about memory usage. I'll go add some more functionality instead of prematurely optimising...

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.