NAME

Aspect::Profiled - Modular aspect to profile subroutine calls

SYNOPSIS

use Aspect::Profiled;
my $prof = Aspect::Profiled->new(qr/^main::(foo|bar)$/);
foo(7);

DESCRIPTION

This class implements a modular 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.

It uses an idea first implemented by Tatsuhiko Miyagawa in Attribute::Profiled.

METHODS

This class inherits from Aspect::Modular. In addition, it implements and/or overrides the following methods:

define(STRING)

Creates and enables advice that implements the profiling behavior for the given subroutines. The specification can be a string, regular expression or a coderef, as described in the PointCut manpage.

spec([spec])

Gets, if called without an argument, or sets, if called with an argument, the aspect's pointcut specification. It is set automatically by define(); setting it afterwards has no effect.

INTERNALS

This aspect consists of two pieces of advice for each affected subroutine:

  • When calling a subroutine affected by the aspect's pointcut, the a timer associated with the aspect's specifier is started.

  • When returning from the subroutine the associated timer is stopped.

BUGS

None known so far. If you find any bugs or oddities, please do inform the author.

AUTHOR

Marcel Grünauer <marcel@cpan.org>

COPYRIGHT

Copyright 2001-2002 Marcel Grünauer. All rights reserved.

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

SEE ALSO

perl(1), Aspect::Intro(3pm), Aspect::Overview(3pm), Benchmark::Timer(3pm).