Memchmark - Check memory consumption


Memchmark documentation  | view source Contained in the Memchmark distribution.

Index


NAME

Top

Memchmark - Check memory consumption

SYNOPSIS

Top

  use Memchmark qw(cmpthese);
  my @data = map { rand($_) } 0..10000;
  cmpthese( -init => sub { my @s =  @data },
            nsort => sub { my @s = sort { $a <=> $b } @data },
            rnsort => sub { my @s = sort { -($a <=> $b) } @data } );

DESCRIPTION

Top

Memchmark is similar to Benchmark but compares memory comsumptions instead of times.

To measure memory comsumption for some subroutine, Memchmark forks a new process to run the sub and then monitors its memory usage every 100ms (aprox.) recording the maximum amount used.

The obtained quantities are only approximate, you can expect errors around 30%.

It is not reliable for small quantities (useles for anything below 1MB).

EXPORT_OK

These are the subroutines available from Memchmark:

cmpthese(foo => sub { ... }, bar => sub { ... }, ...)

prints statistics about the memory comsumption for the different subs.

An entry with the name -init can be used for a do nothing entry which memory comsumption will be substracted to the results from the rest of the tests.

memchmark { &code() };

returns the memory used by &code().

BUGS

Top

This is a very early release, alpha software, expect bugs on it.

The API is not stable. I will change it when required for improvement.

It will not work under Windows (ever).

SEE ALSO

Top

Benchmark, Proc::ProcessTable, Proc::ProcessTable::Process, fork.

AUTHOR

Top

Salvador Fandiño, <sfandino@yahoo.com>

COPYRIGHT AND LICENSE

Top


Memchmark documentation  | view source Contained in the Memchmark distribution.