Help-Site Computer Manuals
  Algorithms & Data Structures   Programming Languages   Revision Control
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

About the forking benchmarks distribution

Benchmark::Forking::ReadMe - About the forking benchmarks distribution


Benchmark::Forking::ReadMe - About the forking benchmarks distribution


The standard Benchmark module can sometimes report inaccurate or misleading results, in part because it doesn't isolate its test cases from one another. This means that the order that cases are run in can influence the results, because side effects, either obvious or obscure, can accumulate and affect later tests.

Data in global variables is an obvious source of side effects; in the below example, the grep takes longer as more items are pushed onto the array, so the test functions that run later will be reported by Benchmark as being slower:

  cmpthese( 1000, {

    "test_1" => sub { push @global, scalar grep 1, @global },

    "test_2" => sub { push @global, scalar grep 1, @global },

    "test_3" => sub { push @global, scalar grep 1, @global },

  } );

More cryptic sources of side effects can include cache priming, idiosyncrasies of the underlying Perl implementation, or the state of the operating system and environment. For example, if the code to be benchmarked require a lot of in-process RAM, earlier tests may be slowed down by having to allocate the memory the first time, or later tests may be slowed down by having to pick through the heap looking for free space. These effects are difficult to predict and can be laborious to identify and compensate for.

This module provides a solution to most aspects of this problem. Once you use Benchmark::Forking, the example benchmark above will report the correct conclusion that the three identical tests run at approximately the same speed.


This is version 0.99 of Benchmark::Forking.

This release has been tested succesfully on the following platforms: 5.6.1 on darwin

This module is new and being distributed for the first time. An initial discussion was held at the Perl Monks community (

This module's CPAN registration should read:

  Name            DSLIP  Description

  --------------  -----  ---------------------------------------------

  Benchmark::     Grp 3  Development Support

  ::Forking       Rdphp  Run benchmarks in separate processes


First version written September 3.

Expanded documentation and packaged for distribution September 5.


This module should work with any version of Perl 5, without platform dependencies or additional modules beyond the core distribution.

You should be able to install this module using the CPAN shell interface:

  perl -MCPAN -e 'install Benchmark::Forking'

Alternately, you may retrieve this package from CPAN ( or from the author's site (

After downloading the distribution, follow the normal procedure to unpack and install it, using the commands shown below or their local equivalents on your system:

  tar xzf Benchmark-Forking-*.tar.gz

  cd Benchmark-Forking-*

  perl Makefile.PL

  make test && sudo make install


If you have questions or feedback about this module, please feel free to contact the author at the below address. Although there is no formal support program, I do attempt to answer email promptly.

Bug reports that contain a failing test case are greatly appreciated, and suggested patches will be promptly considered for inclusion in future releases.

To report bugs via the CPAN web tracking system, go to or send mail to, replacing # with @.

If you've found this module useful or have feedback about your experience with it, consider sharing your opinion with other Perl users by posting your comment to CPAN's ratings system (

For more general discussion, you may wish to post a message on PerlMonks ( or on the comp.lang.perl.misc newsgroup (


Developed by Matthew Simon Cavalletto at Evolution Softworks. You may contact the author directly at or

Custom development and technical consulting are available at More free Perl software is available at

Inspired by a discussion with Jim Keenan in the Perl Monks community. My thanks also to other members of the community for feedback on this module, in particular to graff, tachyon, Aristotle, and pbeckingham.


Copyright 2004 Matthew Simon Cavalletto.

You may use, modify, and distribute this software under the same terms as Perl.