Ran Eilam > Aspect-0.12 > Aspect::Library::Profiler

Download:
Aspect-0.12.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Source  

NAME ^

Aspect::Library::Profiler - reusable method call profiling aspect

SYNOPSIS ^

  # profile all subs on SlowObject
  aspect Profiler => call qr/^SlowObject::/;

  # will be profiled
  SlowObject->foo;

  # will not
  FastObject->bar;

SUPER ^

Aspect::Modular

DESCRIPTION ^

This class implements a reusable aspect that profiles subroutine calls. It uses Benchmark::Timer to profile elapsed times for your calls to the affected methods. The profiling report will be printed to STDERR at the end of program execution.

The design comes from Attribute::Profiled by Tatsuhiko Miyagawa.

WHY ^

  +-------------+
  |      A      |
  +-------------+
  | X -> Y <- Z |
  +-^-----------+

Suppose you want to profile some code, call it X, part of a larger program, called A. So you run your program under a profiler, and notice most of the time is spent not in X, but in Y. X uses Y, but so does Z. You only want to profile how X uses Y, not how Z uses Y. This is where this aspect can help- you can install a profiling aspect with a cflow() pointcut, to profile only usage of Y by code in the call flow of X.

SEE ALSO ^

See the Aspect pods for a guide to the Aspect module.

You can find an example of using this aspect in the examples/ directory of the distribution.

syntax highlighting: