Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Space Efficiency of Hashes

by Stevie-O (Friar)
on Mar 16, 2005 at 00:52 UTC ( [id://439830] : note . print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
    
    my $count = scalar keys %hash;
    print commas($count), " elements: ", commas(total_size\%hash), " bytes
    +\n";
    
  2. or download this
    1 elements: 176 bytes
    10 elements: 1,171 bytes
    ...
    10,000 elements: 1,135,573 bytes
    100,000 elements: 11,224,325 bytes
    1,000,000 elements: 111,194,341 bytes
    
  3. or download this
    $"=$,,$_=q>|\p4<6 8p<M/_|<('=>
    .q>.<4-KI<l|2$<6%s!<qn#F<>;$,
    .=pack'N*',"@{[unpack'C*',$_]
    }"for split/</;$_=$,,y[A-Z a-z]
             {}cd;print lc