Devel-DumpSizes

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.

WriteMakefile(
    NAME              => 'Devel::DumpSizes',
    VERSION_FROM      => 'lib/Devel/DumpSizes.pm', # finds $VERSION
    PREREQ_PM         => {
		Devel::Size => 0.64,
		PadWalker => 1.0,
		Devel::Symdump => 2.0601,
	},
    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
      (ABSTRACT_FROM  => 'lib/Devel/DumpSizes.pm', # retrieve abstract from module
       AUTHOR         => 'Gautam Chekuri <gautam.chekuri@gmail.com>') : ()),
);

README  view on Meta::CPAN


   perl Makefile.PL
   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

  PadWalker
  Devel::Size
  Devel::Symdump

COPYRIGHT AND LICENCE

Copyright (C) 2006 by Gautam Chekuri (gautam.chekuri@gmail.com)

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.6 or,
at your option, any later version of Perl 5 you may have available.

lib/Devel/DumpSizes.pm  view on Meta::CPAN

use strict;
use warnings;

package Devel::DumpSizes;

use PadWalker;
use Devel::Size;
use Devel::Symdump;

require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw (dump_sizes);
our %EXPORT_TAGS = (all => \@EXPORT_OK);

our $VERSION = "0.01";

sub dump_sizes {

	my $dump_file_prefix = shift || "";
	my $ref_of_mys = PadWalker::peek_my(1);
	my %var_sizes;
	my @sorted_vars;

	if ( $dump_file_prefix ) {
		open(DUMP, ">>$dump_file_prefix.my") or warn "Unable to open file to dump sizes\n";
	} else {
		open(DUMP, ">&STDOUT") or warn "ould not dup STDOUT\n";
	}
	
	print DUMP "Variable name -> Size in bytes\n";

lib/Devel/DumpSizes.pm  view on Meta::CPAN


Exports one subroutine by default:

dump_sizes

=head1 DESCRIPTION

This module allows us to print the names and sizes of variables that are available at a give point in a script.

This module was written while debugging a huge long running script. The main use being to understand how variable sizes were fluctuating
during script execution. It uses PadWalker and Devel::Symdump to get the variables. It uses Devel::Size to report the size of each variable.

=head1 METHODS

=head2 dump_sizes

Usage: &Devel::DumpSizes::dump_sizes();

Or

Usage: &Devel::DumpSizes::dump_sizes("/path/of/filename-to-dump-output");



( run in 0.653 second using v1.01-cache-2.11-cpan-05444aca049 )