Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: How to create a compact data structure?

by bart (Canon)
on Dec 20, 2006 at 11:47 UTC ( [id://590892]=note: print w/replies, xml ) Need Help??


in reply to Re: How to create a compact data structure?
in thread How to create a compact data structure?

This is pretty clever, especially since more recent perls allegedly store common keys for different hashes in one, single place.

I wonder if (and how) you can reliably use Devel::Size to measure how much memory is used by both hashes...?

  • Comment on Re^2: How to create a compact data structure?

Replies are listed 'Best First'.
Re^3: How to create a compact data structure?
by Hofmator (Curate) on Dec 20, 2006 at 11:57 UTC
    I don't know about 'reliable' but 'how' should work like this:
    use Devel::Size qw(total_size); # code by perrin my $size_rec_hash = total_size(\%record); my $size_flag_hash = total_size(\%flag); print "Total size: $size_rec_hash + $size_flag_hash =", $size_rec_hash + $size_flag_hash, "\n";
    Update: I missed the point, please ignore.

    -- Hofmator

    Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      You are totally ignoring the fact that these hashes have many keys in common, as every single key in %flag is also a key in %record. And that was precisely the point I was asking about.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://590892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found