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

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Method/Destructor.pm
StatementsExecuted 1126 statements in 15.2ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
39115.11ms60.9msMoose::Meta::Method::Destructor::::_initialize_bodyMoose::Meta::Method::Destructor::_initialize_body
39114.00ms65.1msMoose::Meta::Method::Destructor::::newMoose::Meta::Method::Destructor::new
42112.25ms52.4msMoose::Meta::Method::Destructor::::is_neededMoose::Meta::Method::Destructor::is_needed
3911369µs369µsMoose::Meta::Method::Destructor::::optionsMoose::Meta::Method::Destructor::options
11175µs94µsMoose::Meta::Method::Destructor::::BEGIN@4Moose::Meta::Method::Destructor::BEGIN@4
11146µs618µsMoose::Meta::Method::Destructor::::BEGIN@15Moose::Meta::Method::Destructor::BEGIN@15
11139µs108µsMoose::Meta::Method::Destructor::::BEGIN@5Moose::Meta::Method::Destructor::BEGIN@5
11138µs230µsMoose::Meta::Method::Destructor::::BEGIN@8Moose::Meta::Method::Destructor::BEGIN@8
11121µs21µsMoose::Meta::Method::Destructor::::BEGIN@9Moose::Meta::Method::Destructor::BEGIN@9
11120µs20µsMoose::Meta::Method::Destructor::::BEGIN@7Moose::Meta::Method::Destructor::BEGIN@7
0000s0sMoose::Meta::Method::Destructor::::initialize_bodyMoose::Meta::Method::Destructor::initialize_body
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::Method::Destructor;
3
43103µs2114µs
# spent 94µs (75+19) within Moose::Meta::Method::Destructor::BEGIN@4 which was called: # once (75µs+19µs) by Moose::Meta::Class::BEGIN@24 at line 4
use strict;
# spent 94µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@4 # spent 20µs making 1 call to strict::import
5398µs2178µs
# spent 108µs (39+69) within Moose::Meta::Method::Destructor::BEGIN@5 which was called: # once (39µs+69µs) by Moose::Meta::Class::BEGIN@24 at line 5
use warnings;
# spent 108µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@5 # spent 70µs making 1 call to warnings::import
6
7392µs120µs
# spent 20µs within Moose::Meta::Method::Destructor::BEGIN@7 which was called: # once (20µs+0s) by Moose::Meta::Class::BEGIN@24 at line 7
use Devel::GlobalDestruction ();
# spent 20µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@7
83101µs2422µs
# spent 230µs (38+192) within Moose::Meta::Method::Destructor::BEGIN@8 which was called: # once (38µs+192µs) by Moose::Meta::Class::BEGIN@24 at line 8
use Scalar::Util 'blessed', 'weaken';
# spent 230µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@8 # spent 192µs making 1 call to Exporter::import
93229µs121µs
# spent 21µs within Moose::Meta::Method::Destructor::BEGIN@9 which was called: # once (21µs+0s) by Moose::Meta::Class::BEGIN@24 at line 9
use Try::Tiny ();
# spent 21µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@9
10
1115µsour $VERSION = '1.19';
12166µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
1313µsour $AUTHORITY = 'cpan:STEVAN';
14
151571µs
# spent 618µs (46+571) within Moose::Meta::Method::Destructor::BEGIN@15 which was called: # once (46µs+571µs) by Moose::Meta::Class::BEGIN@24 at line 16
use base 'Moose::Meta::Method',
# spent 571µs making 1 call to base::import
1631.91ms1618µs 'Class::MOP::Method::Inlined';
# spent 618µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@15
17
18
# spent 65.1ms (4.00+61.1) within Moose::Meta::Method::Destructor::new which was called 39 times, avg 1.67ms/call: # 39 times (4.00ms+61.1ms) by Class::MOP::Class::_inline_destructor at line 1364 of Class/MOP/Class.pm, avg 1.67ms/call
sub new {
193124.17ms my $class = shift;
20 my %options = @_;
21
22 (ref $options{options} eq 'HASH')
23 || $class->throw_error("You must pass a hash of options", data => $options{options});
24
25 ($options{package_name} && $options{name})
26 || $class->throw_error("You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT");
27
28 my $self = bless {
29 # from our superclass
30 'body' => undef,
31 'package_name' => $options{package_name},
32 'name' => $options{name},
33 # ...
34 'options' => $options{options},
35 'associated_metaclass' => $options{metaclass},
36 } => $class;
37
38 # we don't want this creating
39 # a cycle in the code, if not
40 # needed
4139285µs weaken($self->{'associated_metaclass'});
# spent 285µs making 39 calls to Scalar::Util::weaken, avg 7µs/call
42
433960.9ms $self->_initialize_body;
# spent 60.9ms making 39 calls to Moose::Meta::Method::Destructor::_initialize_body, avg 1.56ms/call
44
45 return $self;
46}
47
48## accessors
49
5039491µs
# spent 369µs within Moose::Meta::Method::Destructor::options which was called 39 times, avg 9µs/call: # 39 times (369µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 109, avg 9µs/call
sub options { (shift)->{'options'} }
51
52## method
53
54
# spent 52.4ms (2.25+50.1) within Moose::Meta::Method::Destructor::is_needed which was called 42 times, avg 1.25ms/call: # 42 times (2.25ms+50.1ms) by Class::MOP::Class::_inline_destructor at line 1362 of Class/MOP/Class.pm, avg 1.25ms/call
sub is_needed {
551682.90ms my $self = shift;
56 my $metaclass = shift;
57
5884598µs ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') )
# spent 301µs making 42 calls to UNIVERSAL::isa, avg 7µs/call # spent 297µs making 42 calls to Scalar::Util::blessed, avg 7µs/call
59 || $self->throw_error(
60 "The is_needed method expected a metaclass object as its arugment");
61
624249.5ms return $metaclass->find_method_by_name("DEMOLISHALL");
# spent 49.5ms making 42 calls to Class::MOP::Class::find_method_by_name, avg 1.18ms/call
63}
64
65sub initialize_body {
66 Carp::cluck('The initialize_body method has been made private.'
67 . " The public version is deprecated and will be removed in a future release.\n");
68 shift->_initialize_body;
69}
70
71
# spent 60.9ms (5.11+55.8) within Moose::Meta::Method::Destructor::_initialize_body which was called 39 times, avg 1.56ms/call: # 39 times (5.11ms+55.8ms) by Moose::Meta::Method::Destructor::new at line 43, avg 1.56ms/call
sub _initialize_body {
725854.98ms my $self = shift;
73 # TODO:
74 # the %options should also include a both
75 # a call 'initializer' and call 'SUPER::'
76 # options, which should cover approx 90%
77 # of the possible use cases (even if it
78 # requires some adaption on the part of
79 # the author, after all, nothing is free)
80
817837.1ms my @DEMOLISH_methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH');
# spent 36.7ms making 39 calls to Class::MOP::Class::find_all_methods_by_name, avg 941µs/call # spent 366µs making 39 calls to Class::MOP::Method::associated_metaclass, avg 9µs/call
82
83 my $source;
84 $source = 'sub {' . "\n";
85 $source .= 'my $self = shift;' . "\n";
86 $source .= 'return $self->Moose::Object::DESTROY(@_)' . "\n";
87 $source .= ' if Scalar::Util::blessed($self) ne ';
8878657µs $source .= "'" . $self->associated_metaclass->name . "'";
# spent 406µs making 39 calls to Class::MOP::Method::associated_metaclass, avg 10µs/call # spent 250µs making 39 calls to Class::MOP::Package::name, avg 6µs/call
89 $source .= ';' . "\n";
90
91 if ( @DEMOLISH_methods ) {
92 $source .= 'local $?;' . "\n";
93
94 $source .= 'my $in_global_destruction = Devel::GlobalDestruction::in_global_destruction;' . "\n";
95
96 $source .= 'Try::Tiny::try {' . "\n";
97
98 $source .= '$self->' . $_->{class} . '::DEMOLISH($in_global_destruction);' . "\n"
99 for @DEMOLISH_methods;
100
101 $source .= '}';
102 $source .= q[ Try::Tiny::catch { no warnings 'misc'; die $_ };] . "\n";
103 $source .= 'return;' . "\n";
104
105 }
106
107 $source .= '}';
108
10939369µs warn $source if $self->options->{debug};
# spent 369µs making 39 calls to Moose::Meta::Method::Destructor::options, avg 9µs/call
110
1113917.7ms my ( $code, $e ) = $self->_compile_code(
# spent 17.7ms making 39 calls to Class::MOP::Method::Generated::_compile_code, avg 453µs/call
112 environment => {},
113 code => $source,
114 );
115
116 $self->throw_error(
117 "Could not eval the destructor :\n\n$source\n\nbecause :\n\n$e",
118 error => $e, data => $source )
119 if $e;
120
121 $self->{'body'} = $code;
122}
123
124
125112µs1;
126
127__END__