← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 22:00:36 2010
Reported on Wed Nov 17 22:10:04 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Method/Destructor.pm
StatementsExecuted 1091 statements in 19.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
39116.18ms79.2msMoose::Meta::Method::Destructor::::_initialize_bodyMoose::Meta::Method::Destructor::_initialize_body
39113.99ms83.5msMoose::Meta::Method::Destructor::::newMoose::Meta::Method::Destructor::new
43112.30ms38.7msMoose::Meta::Method::Destructor::::is_neededMoose::Meta::Method::Destructor::is_needed
39111.65ms29.2msMoose::Meta::Method::Destructor::::_generate_DEMOLISHALLMoose::Meta::Method::Destructor::_generate_DEMOLISHALL
3911926µs37.5msMoose::Meta::Method::Destructor::::__ANON__[:94]Moose::Meta::Method::Destructor::__ANON__[:94]
3911712µs712µsMoose::Meta::Method::Destructor::::_generate_fallback_destructorMoose::Meta::Method::Destructor::_generate_fallback_destructor
3911381µs381µsMoose::Meta::Method::Destructor::::optionsMoose::Meta::Method::Destructor::options
11196µs116µsMoose::Meta::Method::Destructor::::BEGIN@4Moose::Meta::Method::Destructor::BEGIN@4
11142µs460µsMoose::Meta::Method::Destructor::::BEGIN@15Moose::Meta::Method::Destructor::BEGIN@15
11139µs229µsMoose::Meta::Method::Destructor::::BEGIN@8Moose::Meta::Method::Destructor::BEGIN@8
11138µs108µsMoose::Meta::Method::Destructor::::BEGIN@5Moose::Meta::Method::Destructor::BEGIN@5
11138µs212µsMoose::Meta::Method::Destructor::::BEGIN@9Moose::Meta::Method::Destructor::BEGIN@9
11128µs28µsMoose::Meta::Method::Destructor::::BEGIN@7Moose::Meta::Method::Destructor::BEGIN@7
0000s0sMoose::Meta::Method::Destructor::::__ANON__[:102]Moose::Meta::Method::Destructor::__ANON__[:102]
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µs2135µs
# spent 116µs (96+19) within Moose::Meta::Method::Destructor::BEGIN@4 which was called: # once (96µs+19µs) by Moose::Meta::Class::BEGIN@24 at line 4
use strict;
# spent 116µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@4 # spent 19µs making 1 call to strict::import
53119µs2177µs
# spent 108µs (38+69) within Moose::Meta::Method::Destructor::BEGIN@5 which was called: # once (38µ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 69µs making 1 call to warnings::import
6
73107µs128µs
# spent 28µs within Moose::Meta::Method::Destructor::BEGIN@7 which was called: # once (28µs+0s) by Moose::Meta::Class::BEGIN@24 at line 7
use Devel::GlobalDestruction ();
# spent 28µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@7
83100µs2419µs
# spent 229µs (39+190) within Moose::Meta::Method::Destructor::BEGIN@8 which was called: # once (39µs+190µs) by Moose::Meta::Class::BEGIN@24 at line 8
use Scalar::Util 'blessed', 'weaken';
# spent 229µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@8 # spent 190µs making 1 call to Exporter::import
93329µs2387µs
# spent 212µs (38+175) within Moose::Meta::Method::Destructor::BEGIN@9 which was called: # once (38µs+175µs) by Moose::Meta::Class::BEGIN@24 at line 9
use Try::Tiny;
# spent 212µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@9 # spent 175µs making 1 call to Exporter::import
10
1114µsour $VERSION = '1.19';
12159µs$VERSION = eval $VERSION;
# spent 10µs executing statements in string eval
1314µsour $AUTHORITY = 'cpan:STEVAN';
14
151418µs
# spent 460µs (42+418) within Moose::Meta::Method::Destructor::BEGIN@15 which was called: # once (42µs+418µs) by Moose::Meta::Class::BEGIN@24 at line 16
use base 'Moose::Meta::Method',
# spent 418µs making 1 call to base::import
1631.82ms1460µs 'Class::MOP::Method::Inlined';
# spent 460µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@15
17
18
# spent 83.5ms (3.99+79.5) within Moose::Meta::Method::Destructor::new which was called 39 times, avg 2.14ms/call: # 39 times (3.99ms+79.5ms) by Class::MOP::Class::_inline_destructor at line 1505 of Class/MOP/Class.pm, avg 2.14ms/call
sub new {
193124.25ms 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
4139310µs weaken($self->{'associated_metaclass'});
# spent 310µs making 39 calls to Scalar::Util::weaken, avg 8µs/call
42
433979.2ms $self->_initialize_body;
# spent 79.2ms making 39 calls to Moose::Meta::Method::Destructor::_initialize_body, avg 2.03ms/call
44
45 return $self;
46}
47
48## accessors
49
5039523µs
# spent 381µs within Moose::Meta::Method::Destructor::options which was called 39 times, avg 10µs/call: # 39 times (381µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 90, avg 10µs/call
sub options { (shift)->{'options'} }
51
52## method
53
54
# spent 38.7ms (2.30+36.4) within Moose::Meta::Method::Destructor::is_needed which was called 43 times, avg 900µs/call: # 43 times (2.30ms+36.4ms) by Class::MOP::Class::_inline_destructor at line 1503 of Class/MOP/Class.pm, avg 900µs/call
sub is_needed {
551722.89ms my $self = shift;
56 my $metaclass = shift;
57
5886639µs ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') )
# spent 339µs making 43 calls to Scalar::Util::blessed, avg 8µs/call # spent 300µs making 43 calls to UNIVERSAL::isa, avg 7µs/call
59 || $self->throw_error(
60 "The is_needed method expected a metaclass object as its arugment");
61
624335.8ms return $metaclass->find_method_by_name("DEMOLISHALL");
# spent 35.8ms making 43 calls to Class::MOP::Class::find_method_by_name, avg 832µs/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 79.2ms (6.18+73.0) within Moose::Meta::Method::Destructor::_initialize_body which was called 39 times, avg 2.03ms/call: # 39 times (6.18ms+73.0ms) by Moose::Meta::Method::Destructor::new at line 43, avg 2.03ms/call
sub _initialize_body {
722345.70ms 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
8178587µs my $class = $self->associated_metaclass->name;
# spent 385µs making 39 calls to Class::MOP::Method::associated_metaclass, avg 10µs/call # spent 203µs making 39 calls to Class::MOP::Package::name, avg 5µs/call
827830.0ms my @source = (
# spent 29.2ms making 39 calls to Moose::Meta::Method::Destructor::_generate_DEMOLISHALL, avg 750µs/call # spent 712µs making 39 calls to Moose::Meta::Method::Destructor::_generate_fallback_destructor, avg 18µs/call
83 'sub {',
84 'my $self = shift;',
85 'return ' . $self->_generate_fallback_destructor('$self'),
86 'if Scalar::Util::blessed($self) ne \'' . $class . '\';',
87 $self->_generate_DEMOLISHALL('$self'),
88 '}',
89 );
9039381µs warn join("\n", @source) if $self->options->{debug};
# spent 381µs making 39 calls to Moose::Meta::Method::Destructor::options, avg 10µs/call
91
92
# spent 37.5ms (926µs+36.6) within Moose::Meta::Method::Destructor::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Method/Destructor.pm:94] which was called 39 times, avg 961µs/call: # 39 times (926µs+36.6ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 961µs/call
my $code = try {
9339930µs3936.6ms $self->_compile_code(source => \@source);
# spent 36.6ms making 39 calls to Class::MOP::Method::Generated::_compile_code, avg 937µs/call
94 }
95 catch {
96 my $source = join("\n", @source);
97 $self->throw_error(
98 "Could not eval the destructor :\n\n$source\n\nbecause :\n\n$_",
99 error => $_,
100 data => $source,
101 );
1027841.1ms };
# spent 41.3ms making 39 calls to Try::Tiny::try, avg 1.06ms/call, recursion: max depth 2, sum of overlapping time 1.05ms # spent 829µs making 39 calls to Try::Tiny::catch, avg 21µs/call
103
104 $self->{'body'} = $code;
105}
106
107
# spent 712µs within Moose::Meta::Method::Destructor::_generate_fallback_destructor which was called 39 times, avg 18µs/call: # 39 times (712µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 82, avg 18µs/call
sub _generate_fallback_destructor {
108117833µs my $self = shift;
109 my ($inv) = @_;
110
111 return $inv . '->Moose::Object::DESTROY(@_)';
112}
113
114
# spent 29.2ms (1.65+27.6) within Moose::Meta::Method::Destructor::_generate_DEMOLISHALL which was called 39 times, avg 750µs/call: # 39 times (1.65ms+27.6ms) by Moose::Meta::Method::Destructor::_initialize_body at line 82, avg 750µs/call
sub _generate_DEMOLISHALL {
1151561.49ms my $self = shift;
116 my ($inv) = @_;
117
1187827.6ms my @methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH');
# spent 27.3ms making 39 calls to Class::MOP::Class::find_all_methods_by_name, avg 699µs/call # spent 320µs making 39 calls to Class::MOP::Method::associated_metaclass, avg 8µs/call
119 return unless @methods;
120
121 return (
122 'local $?;',
123 'my $igd = Devel::GlobalDestruction::in_global_destruction;',
124 'Try::Tiny::try {',
125 (map { $inv . '->' . $_->{class} . '::DEMOLISH($igd);' } @methods),
126 '}',
127 'Try::Tiny::catch {',
128 'no warnings \'misc\';',
129 'die $_;',
130 '};',
131 'return;',
132 );
133}
134
135
136111µs1;
137
138__END__