Skip to content

Instantly share code, notes, and snippets.

@DaveMessina
Created June 4, 2010 11:40
Show Gist options
  • Save DaveMessina/425309 to your computer and use it in GitHub Desktop.
Save DaveMessina/425309 to your computer and use it in GitHub Desktop.
get memory size of a data structure
#!/usr/bin/perl
# $Id$
# created by Dave Messina on 2010-04-28
use Modern::Perl;
use Devel::Size qw(total_size);
my %hash;
say "Empty: ", total_size (\%hash), ' bytes';
foreach my $number (1..100000) {
my $key = 1 . $number;
$hash{$key} = 1;
}
say "Full: ", total_size (\%hash), ' bytes';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment