Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Space Efficiency of Hashes

by Joost (Canon)
on Mar 16, 2005 at 00:32 UTC ( [id://439828] : note . print w/replies, xml ) Need Help??


in reply to Space Efficiency of Hashes

This all depends on how much you are exactly storing in your hash tables, but this code should give you a hint, just run it and watch top or some other resource monitor:
#!perl -w use strict; $|=1; my (%a,%b,%c); for (0 .. 500_000) { # set higher if you dare $a{$_} = "x" x 60; # 60 character string $b{$_} = "x" x 60; $c{$_} = "x" x 60; print "\rrow $_" unless $_ % 10000; }

note: this goes up to 190 mb for about 500_000 iterations on my machine YMMV.