View on
MetaCPAN
Stefan O'Rear > Devel-CountOps-0.01 > Devel::CountOps

Download:
Devel-CountOps-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Devel::CountOps - precise timing for Perl 5 code

VERSION ^

version 0.01

SYNOPSIS ^

    perl -MDevel::CountOps foo.pl

    #or

    use Devel::CountOps ();
    my $a = ${^_OPCODES_RUN};
    code();
    say(${^_OPCODES_RUN} - $a);

DESCRIPTION ^

This module allows you to very simply measure the number of ops dispatched in the execution of Perl code. While not perfectly correlated with time, it has the advantage of being infinitely precise - it will come up the same value every time, and can measure changes too small to show up in timings.

The current counter is presented as a magical scalar ${^_OPCODES_RUN}, which, like all control variables, is forced to always be in main so it need not be imported. If Devel::CountOps is default-imported, it installs an END handler which prints the opcode count.

AUTHOR ^

Stefan O'Rear <stefanor@cox.net>

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: