Devel::OpProf - Profile the internals of a Perl program
use Devel::OpProf qw(profile print_stats); ... profile(1); # turn on profiling ... # code to be profiled profile(0); # turn off profiling ... print_stats; # print out operator statistics
This module lets perl keep a count of each internal operation in a program so that you can profile your Perl code. The following functions are exported.
Turns profiling on if FLAG is non-zero, off if FLAG is zero. The operator profile counts are only incremented whilst profiling is on.
Returns a reference to a hash containing the current profile counts. Each key in the hash is an operator description (e.g. "constant item", "addition" or "string comparison") and the corresponding value is the associated count.
Prints a formatted, sorted list of all operators with non-zero counts to stdout.
Zeroes the profile counts of all operators.
Returns an array of the raw profiling counts (indexed by opcode). This is mainly for internal use but may be useful for internals hackers: functions in the Opcode module may be helpful here.
Part of the internal operations involved in statements such as profile(1) and profile(0) affect the profiling counts themselves. This should be unimportant if the code being profiled is non-trivial.
profile(1)
profile(0)
Malcolm Beattie, mbeattie@sable.ox.ac.uk.
To install Devel::OpProf, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::OpProf
CPAN shell
perl -MCPAN -e shell install Devel::OpProf
For more information on module installation, please visit the detailed CPAN module installation guide.