← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:42:38 2010
Reported on Wed Nov 17 22:08:04 2010

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/Scope/Guard.pm
StatementsExecuted 16 statements in 1.18ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11169µs87µsScope::Guard::::BEGIN@3Scope::Guard::BEGIN@3
11137µs196µsScope::Guard::::BEGIN@6Scope::Guard::BEGIN@6
11137µs103µsScope::Guard::::BEGIN@4Scope::Guard::BEGIN@4
11120µs20µsScope::Guard::::BEGIN@7Scope::Guard::BEGIN@7
0000s0sScope::Guard::::DESTROYScope::Guard::DESTROY
0000s0sScope::Guard::::dismissScope::Guard::dismiss
0000s0sScope::Guard::::guardScope::Guard::guard
0000s0sScope::Guard::::newScope::Guard::new
0000s0sScope::Guard::::scope_guardScope::Guard::scope_guard
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Scope::Guard;
2
3395µs2105µs
# spent 87µs (69+18) within Scope::Guard::BEGIN@3 which was called: # once (69µs+18µs) by KiokuDB::Collapser::BEGIN@8 at line 3
use strict;
# spent 87µs making 1 call to Scope::Guard::BEGIN@3 # spent 18µs making 1 call to strict::import
43113µs2169µs
# spent 103µs (37+66) within Scope::Guard::BEGIN@4 which was called: # once (37µs+66µs) by KiokuDB::Collapser::BEGIN@8 at line 4
use warnings;
# spent 103µs making 1 call to Scope::Guard::BEGIN@4 # spent 66µs making 1 call to warnings::import
5
6396µs2355µs
# spent 196µs (37+159) within Scope::Guard::BEGIN@6 which was called: # once (37µs+159µs) by KiokuDB::Collapser::BEGIN@8 at line 6
use Carp qw(confess);
# spent 196µs making 1 call to Scope::Guard::BEGIN@6 # spent 159µs making 1 call to Exporter::import
73825µs120µs
# spent 20µs within Scope::Guard::BEGIN@7 which was called: # once (20µs+0s) by KiokuDB::Collapser::BEGIN@8 at line 7
use Exporter ();
# spent 20µs making 1 call to Scope::Guard::BEGIN@7
8
9131µsour @ISA = qw(Exporter);
1014µsour @EXPORT_OK = qw(guard scope_guard);
1113µsour $VERSION = '0.20';
12
13sub new {
14 confess "Can't create a Scope::Guard in void context" unless (defined wantarray);
15
16 my $class = shift;
17 my $handler = shift() || die 'Scope::Guard::new: no handler supplied';
18 my $ref = ref $handler || '';
19
20 die "Scope::Guard::new: invalid handler - expected CODE ref, got: '$ref'"
21 unless (UNIVERSAL::isa($handler, 'CODE'));
22
23 bless [ 0, $handler ], ref $class || $class;
24}
25
26sub dismiss {
27 my $self = shift;
28 my $dismiss = @_ ? shift : 1;
29
30 $self->[0] = $dismiss;
31}
32
33sub guard(&) { __PACKAGE__->new(shift) }
34sub scope_guard($) { __PACKAGE__->new(shift) }
35
36sub DESTROY {
37 my $self = shift;
38 my ($dismiss, $handler) = @$self;
39
40 $handler->() unless ($dismiss);
41}
42
43115µs1;
44
45__END__