Aspect-Library-Timer

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

1.05 Thu 22 Jul 2010
	- Everything looks good, switching to a production version.
	- All totals are now calculated and reported in integer
	  microseconds to prevent floating point corruption.

0.04 Thu 22 Jul 2010
	- Downgrading to Module::Install 1.00 to get a working abstract

0.03 Wed 21 Jul 2010
	- Upgrading to Module::Install::DSL 1.00
	- Adding a new timer aspect Aspect::Library::ZoneTimer
	- Updated advice code slightly to the newer Aspect 0.90 API

0.02 Tue 19 Jan 2010
	- Fixing some typos

0.01 Tue 19 Jan 2010
	- Creating initial release

MANIFEST  view on Meta::CPAN

inc/Module/Install/WriteAll.pm
lib/Aspect/Library/Timer.pm
lib/Aspect/Library/ZoneTimer.pm
LICENSE
Makefile.PL
MANIFEST			This list of files
META.yml
MYMETA.json
README
t/01_compile.t
t/02_timer.t
t/03_zone.t
t/04_exception.t
xt/meta.t
xt/pmv.t
xt/pod.t

README  view on Meta::CPAN

NAME
    Aspect::Library::Timer - Predefined timer pointcut

SYNOPSIS
      use Aspect;
      
  aspect Timer => call qr/^Foo::/;

      Foo::bar();
      
  package Foo;
      
  sub bar {
          sleep 1;
      }

DESCRIPTION
    "Aspect::Library::Timer" provides support for simple timers aspects.

SUPPORT
    Bugs should be reported via the CPAN bug tracker at

    <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Aspect-Library-Timer>

    For other issues, contact the author.

AUTHOR
    Adam Kennedy <adamk@cpan.org>

lib/Aspect/Library/Timer.pm  view on Meta::CPAN

}

1;

__END__

=pod

=head1 NAME

Aspect::Library::Timer - Predefined timer pointcut

=head1 SYNOPSIS

  use Aspect;
  
  aspect Timer => call qr/^Foo::/;

  Foo::bar();
  
  package Foo;
  
  sub bar {
      sleep 1;
  }

=head1 DESCRIPTION

C<Aspect::Library::Timer> provides support for simple timers aspects.

=head1 SUPPORT

Bugs should be reported via the CPAN bug tracker at

L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Aspect-Library-Timer>

For other issues, contact the author.

=head1 AUTHOR

lib/Aspect/Library/ZoneTimer.pm  view on Meta::CPAN

For maximum accuracy, the start/stop times and the exclusive totals are
provided in two different formats.

Start and stop times are provided as a reference to a two-element C<ARRAY>
exactly as returned by L<Time::HiRes|Time::HiRes::gettimeofday()>.

The profile totals are provided as a reference to a C<HASH> where the keys
are the zone names, and the values are the exclusive wallclock time for the
zone in microseconds.

All timer math is done internally with these integer microseconds to prevent
floating point bugs creeping into the results, and ZoneTimer will avoid
manipulating these 

=head1 SUPPORT

Bugs should be reported via the CPAN bug tracker at

L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Aspect-Library-Timer>

For other issues, contact the author.

t/02_timer.t  view on Meta::CPAN

use Time::HiRes ();
use Aspect;

my $RECURSION = 0;

# Set up the aspect
my @TIMING   = ();
my $pointcut = call qr/^Foo::/;
my $handler  = sub {
	if ( $RECURSION++ ) {
		die "Recursion in timer handler";
	}
	Foo::bar();
	push @TIMING, [ @_ ];
	$RECURSION--;
};
aspect Timer => $pointcut, $handler;

Foo::bar();
eval {
	Foo::foo();

t/04_exception.t  view on Meta::CPAN

#!/usr/bin/perl

# Test that zone timing capture is still correct when an exception
# fires inside a zone timer.

use strict;
BEGIN {
	$|  = 1;
	$^W = 1;
}

use Test::More tests => 5;
use Time::HiRes ();
use Aspect;



( run in 1.209 second using v1.01-cache-2.11-cpan-49f99fa48dc )