B::Stats - print optree statistics


  perl -MB::Stats # all
  perl -MO=Stats  # compile-time only
  perl -MB::Stats[,OPTIONS]


Print statistics for all generated ops.

static analysis at compile-time, static analysis at end-time to include all runtime added modules, and dynamic analysis at run-time, as with a profiler.

The purpose is to help you in your goal:

    no bloat;


Options can be bundled: -c,-e,-r eq -cer

-c static

Do static analysis at compile-time. This does not include all run-time require packages. Invocation via -MO=Stats does this automatically.

-e end

Do static analysis at end-time. This is includes all run-time require packages. This calculates the heap space for the optree.

-r run

Do dynamic run-time analysis of all actually visited ops, similar to a profiler. Single ops can be called multiple times.

-a all (default)

Same as -cer: static compile-time, end-time and dynamic run-time.

-t table

Tabular list of -c, -e and -r results.

-u summary

Short summary only, no op class. With -t only the final table(s).

-F Files

Prints included file names

-x fragmentation NOT YET

Calculates the optree fragmentation. 0.0 is perfect, 1.0 is very bad.

A perfect optree has no null ops and every op->next is immediately next to the op.

-f<op,...> filter NOT YET

Filter for op names and classes. Only calculate the given ops, resp. op class.

  perl -MB::Stats,-fLOGOP,-fCOP,-fconcat

Print output only to this file. Default: STDERR

  perl -MB::Stats,-llog



Static -c check at CHECK time. Triggered by -MO=Stats,-OPTS

rcount ($opcode)

Returns run-time count per op type.


Returns an AV ref for all opcounts, indexed by opcode.


Resets to opcount array for all ops to 0

output ($count-hash, $ops, $name)

General formatter


-r formatter.

Prepares count hash from the runtime generated structure in XS and calls output().


-t formatter

Does not work together with -r


This module is available under the same licences as perl, the Artistic license and the GPL.