← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:07 2014

Filename/usr/local/lib/perl/5.14.2/Moose/Meta/Method/Destructor.pm
StatementsExecuted 97 statements in 1.13ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
311323µs1.32msMoose::Meta::Method::Destructor::::newMoose::Meta::Method::Destructor::new
311108µs992µsMoose::Meta::Method::Destructor::::_initialize_bodyMoose::Meta::Method::Destructor::_initialize_body
31125µs232µsMoose::Meta::Method::Destructor::::is_neededMoose::Meta::Method::Destructor::is_needed
31123µs300µsMoose::Meta::Method::Destructor::::_generate_DEMOLISHALLMoose::Meta::Method::Destructor::_generate_DEMOLISHALL
11115µs46µsMoose::Meta::Method::Destructor::::BEGIN@14Moose::Meta::Method::Destructor::BEGIN@14
11111µs14µsMoose::Meta::Method::Destructor::::BEGIN@10Moose::Meta::Method::Destructor::BEGIN@10
1119µs9µsMoose::Meta::Method::Destructor::::BEGIN@3Moose::Meta::Method::Destructor::BEGIN@3
3119µs9µsMoose::Meta::Method::Destructor::::_generate_fallback_destructorMoose::Meta::Method::Destructor::_generate_fallback_destructor
1118µs38µsMoose::Meta::Method::Destructor::::BEGIN@15Moose::Meta::Method::Destructor::BEGIN@15
1117µs74µsMoose::Meta::Method::Destructor::::BEGIN@17Moose::Meta::Method::Destructor::BEGIN@17
1116µs11µsMoose::Meta::Method::Destructor::::BEGIN@11Moose::Meta::Method::Destructor::BEGIN@11
3115µs5µsMoose::Meta::Method::Destructor::::optionsMoose::Meta::Method::Destructor::options
1113µs3µsMoose::Meta::Method::Destructor::::BEGIN@13Moose::Meta::Method::Destructor::BEGIN@13
0000s0sMoose::Meta::Method::Destructor::::__ANON__[:106]Moose::Meta::Method::Destructor::__ANON__[:106]
0000s0sMoose::Meta::Method::Destructor::::__ANON__[:98]Moose::Meta::Method::Destructor::__ANON__[:98]
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
# spent 9µs within Moose::Meta::Method::Destructor::BEGIN@3 which was called: # once (9µs+0s) by Moose::Meta::Class::BEGIN@26 at line 5
BEGIN {
415µs $Moose::Meta::Method::Destructor::AUTHORITY = 'cpan:STEVAN';
5133µs19µs}
# spent 9µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@3
6{
721µs $Moose::Meta::Method::Destructor::VERSION = '2.1005';
8}
9
10221µs217µs
# spent 14µs (11+3) within Moose::Meta::Method::Destructor::BEGIN@10 which was called: # once (11µs+3µs) by Moose::Meta::Class::BEGIN@26 at line 10
use strict;
# spent 14µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@10 # spent 3µs making 1 call to strict::import
11220µs216µs
# spent 11µs (6+5) within Moose::Meta::Method::Destructor::BEGIN@11 which was called: # once (6µs+5µs) by Moose::Meta::Class::BEGIN@26 at line 11
use warnings;
# spent 11µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@11 # spent 5µs making 1 call to warnings::import
12
13221µs13µs
# spent 3µs within Moose::Meta::Method::Destructor::BEGIN@13 which was called: # once (3µs+0s) by Moose::Meta::Class::BEGIN@26 at line 13
use Devel::GlobalDestruction ();
# spent 3µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@13
14227µs276µs
# spent 46µs (15+30) within Moose::Meta::Method::Destructor::BEGIN@14 which was called: # once (15µs+30µs) by Moose::Meta::Class::BEGIN@26 at line 14
use Scalar::Util 'blessed', 'weaken';
# spent 46µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@14 # spent 30µs making 1 call to Exporter::import
15226µs268µs
# spent 38µs (8+30) within Moose::Meta::Method::Destructor::BEGIN@15 which was called: # once (8µs+30µs) by Moose::Meta::Class::BEGIN@26 at line 15
use Try::Tiny;
# spent 38µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@15 # spent 30µs making 1 call to Exporter::import
16
17167µs
# spent 74µs (7+67) within Moose::Meta::Method::Destructor::BEGIN@17 which was called: # once (7µs+67µs) by Moose::Meta::Class::BEGIN@26 at line 18
use base 'Moose::Meta::Method',
# spent 67µs making 1 call to base::import
182469µs174µs 'Class::MOP::Method::Inlined';
# spent 74µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@17
19
20
# spent 1.32ms (323µs+995µs) within Moose::Meta::Method::Destructor::new which was called 3 times, avg 440µs/call: # 3 times (323µs+995µs) by Class::MOP::Class::_inline_destructor at line 1477 of Class/MOP/Class.pm, avg 440µs/call
sub new {
2124325µs my $class = shift;
22 my %options = @_;
23
24 (ref $options{options} eq 'HASH')
25 || $class->throw_error("You must pass a hash of options", data => $options{options});
26
27 ($options{package_name} && $options{name})
28 || $class->throw_error("You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT");
29
30 my $self = bless {
31 # from our superclass
32 'body' => undef,
33 'package_name' => $options{package_name},
34 'name' => $options{name},
35 # ...
36 'options' => $options{options},
37 'definition_context' => $options{definition_context},
38 'associated_metaclass' => $options{metaclass},
39 } => $class;
40
41 # we don't want this creating
42 # a cycle in the code, if not
43 # needed
4434µs weaken($self->{'associated_metaclass'});
# spent 4µs making 3 calls to Scalar::Util::weaken, avg 1µs/call
45
463992µs $self->_initialize_body;
# spent 992µs making 3 calls to Moose::Meta::Method::Destructor::_initialize_body, avg 330µs/call
47
48 return $self;
49}
50
51## accessors
52
5337µs
# spent 5µs within Moose::Meta::Method::Destructor::options which was called 3 times, avg 2µs/call: # 3 times (5µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 94, avg 2µs/call
sub options { (shift)->{'options'} }
54
55## method
56
57
# spent 232µs (25+207) within Moose::Meta::Method::Destructor::is_needed which was called 3 times, avg 77µs/call: # 3 times (25µs+207µs) by Class::MOP::Class::_inline_destructor at line 1475 of Class/MOP/Class.pm, avg 77µs/call
sub is_needed {
581228µs my $self = shift;
59 my $metaclass = shift;
60
6165µs ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') )
# spent 3µs making 3 calls to Scalar::Util::blessed, avg 933ns/call # spent 3µs making 3 calls to UNIVERSAL::isa, avg 867ns/call
62 || $self->throw_error(
63 "The is_needed method expected a metaclass object as its arugment");
64
653202µs return $metaclass->find_method_by_name("DEMOLISHALL");
# spent 202µs making 3 calls to Class::MOP::Class::find_method_by_name, avg 67µs/call
66}
67
68sub initialize_body {
69 Carp::cluck('The initialize_body method has been made private.'
70 . " The public version is deprecated and will be removed in a future release.\n");
71 shift->_initialize_body;
72}
73
74
# spent 992µs (108+884) within Moose::Meta::Method::Destructor::_initialize_body which was called 3 times, avg 330µs/call: # 3 times (108µs+884µs) by Moose::Meta::Method::Destructor::new at line 46, avg 330µs/call
sub _initialize_body {
751895µs my $self = shift;
76 # TODO:
77 # the %options should also include a both
78 # a call 'initializer' and call 'SUPER::'
79 # options, which should cover approx 90%
80 # of the possible use cases (even if it
81 # requires some adaption on the part of
82 # the author, after all, nothing is free)
83
8466µs my $class = $self->associated_metaclass->name;
# spent 3µs making 3 calls to Class::MOP::Method::associated_metaclass, avg 1µs/call # spent 2µs making 3 calls to Class::MOP::Package::name, avg 767ns/call
856309µs my @source = (
# spent 300µs making 3 calls to Moose::Meta::Method::Destructor::_generate_DEMOLISHALL, avg 100µs/call # spent 9µs making 3 calls to Moose::Meta::Method::Destructor::_generate_fallback_destructor, avg 3µs/call
86 'sub {',
87 'my $self = shift;',
88 'return ' . $self->_generate_fallback_destructor('$self'),
89 'if Scalar::Util::blessed($self) ne \'' . $class . '\';',
90 $self->_generate_DEMOLISHALL('$self'),
91 'return;',
92 '}',
93 );
9435µs warn join("\n", @source) if $self->options->{debug};
# spent 5µs making 3 calls to Moose::Meta::Method::Destructor::options, avg 2µs/call
95
96 my $code = try {
97315µs3467µs $self->_compile_code(source => \@source);
# spent 467µs making 3 calls to Class::MOP::Method::Generated::_compile_code, avg 156µs/call
98 }
99 catch {
100 my $source = join("\n", @source);
101 $self->throw_error(
102 "Could not eval the destructor :\n\n$source\n\nbecause :\n\n$_",
103 error => $_,
104 data => $source,
105 );
1066564µs };
# spent 549µs making 3 calls to Try::Tiny::try, avg 183µs/call # spent 15µs making 3 calls to Try::Tiny::catch, avg 5µs/call
107
108 $self->{'body'} = $code;
109}
110
111
# spent 9µs within Moose::Meta::Method::Destructor::_generate_fallback_destructor which was called 3 times, avg 3µs/call: # 3 times (9µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 85, avg 3µs/call
sub _generate_fallback_destructor {
112911µs my $self = shift;
113 my ($inv) = @_;
114
115 return $inv . '->Moose::Object::DESTROY(@_)';
116}
117
118
# spent 300µs (23+277) within Moose::Meta::Method::Destructor::_generate_DEMOLISHALL which was called 3 times, avg 100µs/call: # 3 times (23µs+277µs) by Moose::Meta::Method::Destructor::_initialize_body at line 85, avg 100µs/call
sub _generate_DEMOLISHALL {
1191219µs my $self = shift;
120 my ($inv) = @_;
121
1226277µs my @methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH');
# spent 275µs making 3 calls to Class::MOP::Class::find_all_methods_by_name, avg 92µs/call # spent 2µs making 3 calls to Class::MOP::Method::associated_metaclass, avg 800ns/call
123 return unless @methods;
124
125 return (
126 'local $?;',
127 'my $igd = Devel::GlobalDestruction::in_global_destruction;',
128 'Try::Tiny::try {',
129 (map { $inv . '->' . $_->{class} . '::DEMOLISH($igd);' } @methods),
130 '}',
131 'Try::Tiny::catch {',
132 'die $_;',
133 '};',
134 );
135}
136
137
13813µs1;
139
140# ABSTRACT: Method Meta Object for destructors
141
142__END__