Profile of Moose/Meta/Method/Destructor.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/Method/Destructor.pm
Statements | Executed 772 statements in 2.50ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
28 | 1 | 1 | 830µs | 18.1ms | Moose::Meta::Method::Destructor::::_initialize_bodyMoose::Meta::Method::Destructor::_initialize_body
28 | 1 | 1 | 581µs | 18.7ms | Moose::Meta::Method::Destructor::::newMoose::Meta::Method::Destructor::new
28 | 1 | 1 | 253µs | 7.51ms | Moose::Meta::Method::Destructor::::is_neededMoose::Meta::Method::Destructor::is_needed
28 | 1 | 1 | 182µs | 2.62ms | Moose::Meta::Method::Destructor::::_generate_DEMOLISHALLMoose::Meta::Method::Destructor::_generate_DEMOLISHALL
28 | 1 | 1 | 65µs | 65µs | Moose::Meta::Method::Destructor::::_generate_fallback_destructorMoose::Meta::Method::Destructor::_generate_fallback_destructor
28 | 1 | 1 | 40µs | 40µs | Moose::Meta::Method::Destructor::::optionsMoose::Meta::Method::Destructor::options
1 | 1 | 1 | 10µs | 19µs | Moose::Meta::Method::Destructor::::BEGIN@4Moose::Meta::Method::Destructor::BEGIN@4
1 | 1 | 1 | 6µs | 35µs | Moose::Meta::Method::Destructor::::BEGIN@9Moose::Meta::Method::Destructor::BEGIN@9
1 | 1 | 1 | 6µs | 9µs | Moose::Meta::Method::Destructor::::BEGIN@5Moose::Meta::Method::Destructor::BEGIN@5
1 | 1 | 1 | 6µs | 100µs | Moose::Meta::Method::Destructor::::BEGIN@14Moose::Meta::Method::Destructor::BEGIN@14
1 | 1 | 1 | 6µs | 29µs | Moose::Meta::Method::Destructor::::BEGIN@11Moose::Meta::Method::Destructor::BEGIN@11
1 | 1 | 1 | 5µs | 27µs | Moose::Meta::Method::Destructor::::BEGIN@8Moose::Meta::Method::Destructor::BEGIN@8
1 | 1 | 1 | 3µs | 3µs | Moose::Meta::Method::Destructor::::BEGIN@7Moose::Meta::Method::Destructor::BEGIN@7
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Destructor::::__ANON__[:100]Moose::Meta::Method::Destructor::__ANON__[:100]
0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Destructor::::__ANON__[:93]Moose::Meta::Method::Destructor::__ANON__[:93]

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose::Meta::Method::Destructor;
2 | 1 | 600ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 19µs | 2 | 28µs | # spent 19µs (10+9) within Moose::Meta::Method::Destructor::BEGIN@4 which was called: # once (10µs+9µs) by Moose::Meta::Class::BEGIN@17 at line 4 use strict; # spent 19µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@4 # spent 9µs making 1 call to strict::import
5 | 2 | 18µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Method::Destructor::BEGIN@5 which was called: # once (6µs+3µs) by Moose::Meta::Class::BEGIN@17 at line 5 use warnings; # spent 9µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@5 # spent 3µs making 1 call to warnings::import
6 |  |  |  |  |
7 | 2 | 18µs | 1 | 3µs | # spent 3µs within Moose::Meta::Method::Destructor::BEGIN@7 which was called: # once (3µs+0s) by Moose::Meta::Class::BEGIN@17 at line 7 use Devel::GlobalDestruction (); # spent 3µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@7
8 | 2 | 18µs | 2 | 49µs | # spent 27µs (5+22) within Moose::Meta::Method::Destructor::BEGIN@8 which was called: # once (5µs+22µs) by Moose::Meta::Class::BEGIN@17 at line 8 use Scalar::Util 'blessed', 'weaken'; # spent 27µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@8 # spent 22µs making 1 call to Exporter::import
9 | 2 | 26µs | 2 | 63µs | # spent 35µs (6+28) within Moose::Meta::Method::Destructor::BEGIN@9 which was called: # once (6µs+28µs) by Moose::Meta::Class::BEGIN@17 at line 9 use Try::Tiny; # spent 35µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@9 # spent 28µs making 1 call to Exporter::import
10 |  |  |  |  |
11 | 1 | 3µs | 1 | 23µs | # spent 29µs (6+23) within Moose::Meta::Method::Destructor::BEGIN@11 which was called: # once (6µs+23µs) by Moose::Meta::Class::BEGIN@17 at line 12 use parent 'Moose::Meta::Method', # spent 23µs making 1 call to parent::import
12 | 1 | 18µs | 1 | 29µs | 'Class::MOP::Method::Inlined'; # spent 29µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@11
13 |  |  |  |  |
14 | 2 | 383µs | 2 | 194µs | # spent 100µs (6+94) within Moose::Meta::Method::Destructor::BEGIN@14 which was called: # once (6µs+94µs) by Moose::Meta::Class::BEGIN@17 at line 14 use Moose::Util 'throw_exception'; # spent 100µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@14 # spent 94µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
15 |  |  |  |  |
16 |  |  |  |  | # spent 18.7ms (581µs+18.1) within Moose::Meta::Method::Destructor::new which was called 28 times, avg 668µs/call: # 28 times (581µs+18.1ms) by Class::MOP::Class::_inline_destructor at line 1496 of Class/MOP/Class.pm, avg 668µs/call sub new {
17 | 28 | 13µs |  |  | my $class = shift;
18 | 28 | 61µs |  |  | my %options = @_;
19 |  |  |  |  |
20 | 28 | 29µs |  |  | (ref $options{options} eq 'HASH')
21 |  |  |  |  | || throw_exception( MustPassAHashOfOptions => params => \%options,
22 |  |  |  |  | class => $class
23 |  |  |  |  | );
24 |  |  |  |  |
25 | 28 | 19µs |  |  | ($options{package_name} && $options{name})
26 |  |  |  |  | || throw_exception( MustSupplyPackageNameAndName => params => \%options,
27 |  |  |  |  | class => $class
28 |  |  |  |  | );
29 |  |  |  |  |
30 | 28 | 119µs |  |  | 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
44 | 28 | 220µs | 28 | 24µs | weaken($self->{'associated_metaclass'}); # spent 24µs making 28 calls to Scalar::Util::weaken, avg 839ns/call
45 |  |  |  |  |
46 | 28 | 51µs | 28 | 18.1ms | $self->_initialize_body; # spent 18.1ms making 28 calls to Moose::Meta::Method::Destructor::_initialize_body, avg 646µs/call
47 |  |  |  |  |
48 | 28 | 88µs |  |  | return $self;
49 |  |  |  |  | }
50 |  |  |  |  |
51 |  |  |  |  | ## accessors
52 |  |  |  |  |
53 | 28 | 60µs |  |  | # spent 40µs within Moose::Meta::Method::Destructor::options which was called 28 times, avg 1µs/call: # 28 times (40µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 89, avg 1µs/call sub options { (shift)->{'options'} }
54 |  |  |  |  |
55 |  |  |  |  | ## method
56 |  |  |  |  |
57 |  |  |  |  | # spent 7.51ms (253µs+7.26) within Moose::Meta::Method::Destructor::is_needed which was called 28 times, avg 268µs/call: # 28 times (253µs+7.26ms) by Class::MOP::Class::_inline_destructor at line 1494 of Class/MOP/Class.pm, avg 268µs/call sub is_needed {
58 | 28 | 11µs |  |  | my $self = shift;
59 | 28 | 11µs |  |  | my $metaclass = shift;
60 |  |  |  |  |
61 | 28 | 178µs | 56 | 60µs | ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') ) # spent 30µs making 28 calls to UNIVERSAL::isa, avg 1µs/call # spent 30µs making 28 calls to Scalar::Util::blessed, avg 1µs/call
62 |  |  |  |  | || throw_exception( MethodExpectedAMetaclassObject => metaclass => $metaclass,
63 |  |  |  |  | class => $self
64 |  |  |  |  | );
65 |  |  |  |  |
66 | 28 | 90µs | 28 | 7.20ms | return $metaclass->find_method_by_name("DEMOLISHALL"); # spent 7.20ms making 28 calls to Class::MOP::Class::find_method_by_name, avg 257µs/call
67 |  |  |  |  | }
68 |  |  |  |  |
69 |  |  |  |  | # spent 18.1ms (830µs+17.3) within Moose::Meta::Method::Destructor::_initialize_body which was called 28 times, avg 646µs/call: # 28 times (830µs+17.3ms) by Moose::Meta::Method::Destructor::new at line 46, avg 646µs/call sub _initialize_body {
70 | 28 | 8µs |  |  | my $self = shift;
71 |  |  |  |  | # TODO:
72 |  |  |  |  | # the %options should also include a both
73 |  |  |  |  | # a call 'initializer' and call 'SUPER::'
74 |  |  |  |  | # options, which should cover approx 90%
75 |  |  |  |  | # of the possible use cases (even if it
76 |  |  |  |  | # requires some adaption on the part of
77 |  |  |  |  | # the author, after all, nothing is free)
78 |  |  |  |  |
79 | 28 | 102µs | 56 | 31µs | my $class = $self->associated_metaclass->name; # spent 21µs making 28 calls to Class::MOP::Method::associated_metaclass, avg 746ns/call # spent 10µs making 28 calls to Class::MOP::Package::name, avg 364ns/call
80 | 28 | 143µs | 56 | 2.69ms | my @source = ( # spent 2.62ms making 28 calls to Moose::Meta::Method::Destructor::_generate_DEMOLISHALL, avg 94µs/call # spent 65µs making 28 calls to Moose::Meta::Method::Destructor::_generate_fallback_destructor, avg 2µs/call
81 |  |  |  |  | 'sub {',
82 |  |  |  |  | 'my $self = shift;',
83 |  |  |  |  | 'return ' . $self->_generate_fallback_destructor('$self'),
84 |  |  |  |  | 'if Scalar::Util::blessed($self) ne \'' . $class . '\';',
85 |  |  |  |  | $self->_generate_DEMOLISHALL('$self'),
86 |  |  |  |  | 'return;',
87 |  |  |  |  | '}',
88 |  |  |  |  | );
89 | 28 | 54µs | 28 | 40µs | warn join("\n", @source) if $self->options->{debug}; # spent 40µs making 28 calls to Moose::Meta::Method::Destructor::options, avg 1µs/call
90 |  |  |  |  |
91 |  |  |  |  | my $code = try {
92 | 28 | 90µs | 28 | 8.37ms | $self->_compile_code(source => \@source); # spent 8.37ms making 28 calls to Class::MOP::Method::Generated::_compile_code, avg 299µs/call
93 |  |  |  |  | }
94 |  |  |  |  | catch {
95 |  |  |  |  | my $source = join("\n", @source);
96 |  |  |  |  | throw_exception( CouldNotEvalDestructor => method_destructor_object => $self,
97 |  |  |  |  | source => $source,
98 |  |  |  |  | error => $_
99 |  |  |  |  | );
100 | 28 | 311µs | 56 | 14.5ms | }; # spent 14.4ms making 28 calls to Try::Tiny::try, avg 514µs/call # spent 97µs making 28 calls to Try::Tiny::catch, avg 3µs/call
101 |  |  |  |  |
102 | 28 | 97µs |  |  | $self->{'body'} = $code;
103 |  |  |  |  | }
104 |  |  |  |  |
105 |  |  |  |  | # spent 65µs within Moose::Meta::Method::Destructor::_generate_fallback_destructor which was called 28 times, avg 2µs/call: # 28 times (65µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 80, avg 2µs/call sub _generate_fallback_destructor {
106 | 28 | 9µs |  |  | my $self = shift;
107 | 28 | 11µs |  |  | my ($inv) = @_;
108 |  |  |  |  |
109 | 28 | 77µs |  |  | return $inv . '->Moose::Object::DESTROY(@_)';
110 |  |  |  |  | }
111 |  |  |  |  |
112 |  |  |  |  | # spent 2.62ms (182µs+2.44) within Moose::Meta::Method::Destructor::_generate_DEMOLISHALL which was called 28 times, avg 94µs/call: # 28 times (182µs+2.44ms) by Moose::Meta::Method::Destructor::_initialize_body at line 80, avg 94µs/call sub _generate_DEMOLISHALL {
113 | 28 | 10µs |  |  | my $self = shift;
114 | 28 | 7µs |  |  | my ($inv) = @_;
115 |  |  |  |  |
116 | 28 | 66µs | 56 | 2.44ms | my @methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH'); # spent 2.43ms making 28 calls to Class::MOP::Class::find_all_methods_by_name, avg 87µs/call # spent 15µs making 28 calls to Class::MOP::Method::associated_metaclass, avg 529ns/call
117 | 28 | 59µs |  |  | return unless @methods;
118 |  |  |  |  |
119 |  |  |  |  | return (
120 |  |  |  |  | 'local $?;',
121 |  |  |  |  | 'my $igd = Devel::GlobalDestruction::in_global_destruction;',
122 |  |  |  |  | 'Try::Tiny::try {',
123 |  |  |  |  | (map { $inv . '->' . $_->{class} . '::DEMOLISH($igd);' } @methods),
124 |  |  |  |  | '}',
125 |  |  |  |  | 'Try::Tiny::catch {',
126 |  |  |  |  | 'die $_;',
127 |  |  |  |  | '};',
128 |  |  |  |  | );
129 |  |  |  |  | }
130 |  |  |  |  |
131 |  |  |  |  |
132 | 1 | 2µs |  |  | 1;
133 |  |  |  |  |
134 |  |  |  |  | # ABSTRACT: Method Meta Object for destructors
135 |  |  |  |  |
136 |  |  |  |  | __END__