Stefan O'Rear


Devel::CountOps - precise timing for Perl 5 code


version 0.01


    perl -MDevel::CountOps


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


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.


Stefan O'Rear <>

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