package MemImpact::GTop; use strict; use GTop; my @meths = qw(size vsize rss share); my $before = GTop->new->proc_mem($$); my $after = my $now = $before; printf "%-60s % 10d Bytes\n", "$_ initial memory:" , $before->$_ for @meths; print "-" x 77, $/; sub import { my $pack = shift; my $meth = shift; for (@_) { eval "use $_;"; die "Can't load $_:\n$@\n" if $@; $after = GTop->new->proc_mem($$); printf "%-60s % 10d Bytes\n", "$meth after loading $_:" , $after->$meth; printf "%-60s % 10d Bytes\n", "$meth impact of $_:" , $after->$meth - $now->$meth; $now = $after; } } END { print "-" x 77, $/; printf "%-60s % 10d Bytes\n", "$_ total impact:" , $after->$_ - $before->$_ for @meths; } 1; #### qwurx [shmem] ~ > perl -e 'use MemImpact::GTop qw(rss Moose); use MemImpact::GTop qw(rss MooseX::AttributeHelpers)' size initial memory: 9347072 Bytes vsize initial memory: 9347072 Bytes rss initial memory: 3461120 Bytes share initial memory: 2502656 Bytes ----------------------------------------------------------------------------- rss after loading Moose: 8974336 Bytes rss impact of Moose: 5513216 Bytes rss after loading MooseX::AttributeHelpers: 10436608 Bytes rss impact of MooseX::AttributeHelpers: 1462272 Bytes ----------------------------------------------------------------------------- size total impact: 7110656 Bytes vsize total impact: 7110656 Bytes rss total impact: 6975488 Bytes share total impact: 352256 Bytes