Skip to content

Instantly share code, notes, and snippets.

@reneeb
Last active August 29, 2015 13:56
Show Gist options
  • Save reneeb/9136206 to your computer and use it in GitHub Desktop.
Save reneeb/9136206 to your computer and use it in GitHub Desktop.
authordb@ubuntu:~$ perl community/memory_stats.pl
--- Memory Usage ---
start: 15380480
stop: 25378816 - delta: 9998336 - total: 9998336
--- Memory Usage ---
authordb@ubuntu:~$ cat community/memory_stats.pl
use Memory::Stats;
my $stats = Memory::Stats->new;
$stats->start;
test1();
$stats->stop;
$stats->report;
sub test1 {
my $var = '1' x 10_000_000;
}
authordb@ubuntu:~$ perl community/memory_stats.pl
--- Memory Usage ---
start: 15384576
before 1st test1: 15384576 - delta: 0 - total: 0
before 2nd test1: 25505792 - delta: 10121216 - total: 10121216
after 2nd test1: 35508224 - delta: 10002432 - total: 20123648
stop: 35508224 - delta: 0 - total: 20123648
--- Memory Usage ---
authordb@ubuntu:~$ cat community/memory_stats.pl
use Memory::Stats;
my $stats = Memory::Stats->new;
$stats->start;
$stats->checkpoint( "before 1st test1" );
my $t = test1();
$stats->checkpoint( "before 2nd test1" );
my $u = test1();
$stats->checkpoint( "after 2nd test1" );
$stats->stop;
$stats->report;
sub test1 {
my $var = '1' x 10_000_000;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment