The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Devel::OpProf - Profile the internals of a Perl program

SYNOPSIS

    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

DESCRIPTION

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.

profile(FLAG)

Turns profiling on if FLAG is non-zero, off if FLAG is zero. The operator profile counts are only incremented whilst profiling is on.

stats

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.

zero_stats

Zeroes the profile counts of all operators.

op_count

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.

BUGS

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.

AUTHOR

Malcolm Beattie, mbeattie@sable.ox.ac.uk.