Timer.pm

filter: Statementstmt 95.4% 42 / 44 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 2 totaltotal 90.3% 56 / 62 CC 4 SCAR 5.3
CC
4
Cov
94%
__ANON__
3.0
get_advice
2.0
handler
2.0
CRAP 1.7
« ZoneTimer.pm ↑ Summary
1 package Aspect::Library::Timer;
2  
3 2 ▶use 5.008002;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Aspect::Modular 1.00 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Time::HiRes 1.9718 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use vars qw{$VERSION @ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 $VERSION = '1.10';
12 2 @ISA = 'Aspect::Modular';
13 }
14  
15 1 ▶sub get_advice {
Subroutine get_advice: called CC=2 SCAR=6.9
Pod undocumented
16 1 my $self = shift;
17 1 my $pointcut = shift;
18 1 ▶ my $handler = @_ ? shift : \&handler;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 0 1
19 1 my $DISABLE = 0;
20 Aspect::Advice::Around->new(
21 lexical => $self->lexical,
22 pointcut => $pointcut,
23 6 ▶ code => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
24 # Prevent recursion in the report handler
25 6 ▶ if ( $DISABLE ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($DISABLE) 3 3 6
26 3 $_->proceed;
27 3 return;
28 }
29  
30 # Capture the time
31 3 my $error = '';
32 SCOPE: {
33 3 local $@;
34 3 my @start = Time::HiRes::gettimeofday();
35 3 eval {
36 3 $_->proceed;
37 };
38 3 $error = $@;
39 3 my @stop = Time::HiRes::gettimeofday();
40  
41 # Process the time
42 3 $DISABLE++;
43 3 eval {
44 3 $handler->(
45 $_->sub_name,
46 \@start,
47 \@stop,
48 Time::HiRes::tv_interval(
49 \@start,
50 \@stop,
51 )
52 );
53 };
54 3 $DISABLE--;
55 }
56  
57 3 ▶ die $error if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 1 2 3
58 2 return;
59 },
60 1 );
61 }
62  
63 0 ▶sub handler {
Subroutine handler: not called CC=1 SCAR=6.9
Pod undocumented
64 0 my ( $name, $start, $stop, $interval ) = @_;
65 0 printf STDERR "%s - %s\n", $interval, $name;
66 }
67  
68 2 1;
69  
70 __END__
« ZoneTimer.pm ↑ Summary