Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/Method/Destructor.pm |
Statements | Executed 43 statements in 521µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 54µs | 265µs | new | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 27µs | 210µs | _initialize_body | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 9µs | 10µs | BEGIN@4 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 8µs | 74µs | is_needed | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 6µs | 54µs | _generate_DEMOLISHALL | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 5µs | 25µs | BEGIN@9 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 5µs | 106µs | try {...} | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 4µs | 7µs | BEGIN@5 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 4µs | 79µs | BEGIN@14 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 4µs | 22µs | BEGIN@11 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 4µs | 22µs | BEGIN@8 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 3µs | 3µs | _generate_fallback_destructor | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 2µs | 2µs | BEGIN@7 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 1µs | 1µs | options | Moose::Meta::Method::Destructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:100] | Moose::Meta::Method::Destructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:93] | Moose::Meta::Method::Destructor::
0 | 0 | 0 | 0s | 0s | catch {...} | Moose::Meta::Method::Destructor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::Method::Destructor; | ||||
2 | 1 | 300ns | our $VERSION = '2.1605'; | ||
3 | |||||
4 | 2 | 14µs | 2 | 12µs | # spent 10µs (9+1) within Moose::Meta::Method::Destructor::BEGIN@4 which was called:
# once (9µs+1µs) by Moose::Meta::Class::BEGIN@17 at line 4 # spent 10µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@4
# spent 1µs making 1 call to strict::import |
5 | 2 | 12µs | 2 | 10µs | # spent 7µs (4+3) within Moose::Meta::Method::Destructor::BEGIN@5 which was called:
# once (4µs+3µs) by Moose::Meta::Class::BEGIN@17 at line 5 # spent 7µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@5
# spent 3µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 12µs | 1 | 2µs | # spent 2µs within Moose::Meta::Method::Destructor::BEGIN@7 which was called:
# once (2µs+0s) by Moose::Meta::Class::BEGIN@17 at line 7 # spent 2µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@7 |
8 | 2 | 13µs | 2 | 41µs | # spent 22µs (4+19) within Moose::Meta::Method::Destructor::BEGIN@8 which was called:
# once (4µs+19µs) by Moose::Meta::Class::BEGIN@17 at line 8 # spent 22µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@8
# spent 19µs making 1 call to Exporter::import |
9 | 2 | 16µs | 2 | 45µs | # spent 25µs (5+20) within Moose::Meta::Method::Destructor::BEGIN@9 which was called:
# once (5µs+20µs) by Moose::Meta::Class::BEGIN@17 at line 9 # spent 25µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@9
# spent 20µs making 1 call to Exporter::import |
10 | |||||
11 | 1 | 2µs | 1 | 19µs | # spent 22µs (4+19) within Moose::Meta::Method::Destructor::BEGIN@11 which was called:
# once (4µs+19µs) by Moose::Meta::Class::BEGIN@17 at line 12 # spent 19µs making 1 call to parent::import |
12 | 1 | 11µs | 1 | 22µs | 'Class::MOP::Method::Inlined'; # spent 22µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@11 |
13 | |||||
14 | 2 | 338µs | 2 | 154µs | # spent 79µs (4+75) within Moose::Meta::Method::Destructor::BEGIN@14 which was called:
# once (4µs+75µs) by Moose::Meta::Class::BEGIN@17 at line 14 # spent 79µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@14
# spent 75µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
15 | |||||
16 | # spent 265µs (54+211) within Moose::Meta::Method::Destructor::new which was called:
# once (54µs+211µs) by Class::MOP::Class::_inline_destructor at line 1506 of Class/MOP/Class.pm | ||||
17 | 1 | 1µs | my $class = shift; | ||
18 | 1 | 2µs | my %options = @_; | ||
19 | |||||
20 | 1 | 800ns | (ref $options{options} eq 'HASH') | ||
21 | || throw_exception( MustPassAHashOfOptions => params => \%options, | ||||
22 | class => $class | ||||
23 | ); | ||||
24 | |||||
25 | ($options{package_name} && $options{name}) | ||||
26 | 1 | 700ns | || throw_exception( MustSupplyPackageNameAndName => params => \%options, | ||
27 | class => $class | ||||
28 | ); | ||||
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 | 1 | 3µs | } => $class; | ||
40 | |||||
41 | # we don't want this creating | ||||
42 | # a cycle in the code, if not | ||||
43 | # needed | ||||
44 | 1 | 42µs | 1 | 400ns | weaken($self->{'associated_metaclass'}); # spent 400ns making 1 call to Scalar::Util::weaken |
45 | |||||
46 | 1 | 1µs | 1 | 210µs | $self->_initialize_body; # spent 210µs making 1 call to Moose::Meta::Method::Destructor::_initialize_body |
47 | |||||
48 | 1 | 2µs | return $self; | ||
49 | } | ||||
50 | |||||
51 | ## accessors | ||||
52 | |||||
53 | 1 | 2µs | # spent 1µs within Moose::Meta::Method::Destructor::options which was called:
# once (1µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 89 | ||
54 | |||||
55 | ## method | ||||
56 | |||||
57 | # spent 74µs (8+66) within Moose::Meta::Method::Destructor::is_needed which was called:
# once (8µs+66µs) by Class::MOP::Class::_inline_destructor at line 1494 of Class/MOP/Class.pm | ||||
58 | 1 | 400ns | my $self = shift; | ||
59 | 1 | 300ns | my $metaclass = shift; | ||
60 | |||||
61 | 1 | 5µs | 2 | 1µs | ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') ) # spent 600ns making 1 call to Scalar::Util::blessed
# spent 500ns making 1 call to UNIVERSAL::isa |
62 | || throw_exception( MethodExpectedAMetaclassObject => metaclass => $metaclass, | ||||
63 | class => $self | ||||
64 | ); | ||||
65 | |||||
66 | 1 | 4µs | 1 | 65µs | return $metaclass->find_method_by_name("DEMOLISHALL"); # spent 65µs making 1 call to Class::MOP::Class::find_method_by_name |
67 | } | ||||
68 | |||||
69 | # spent 210µs (27+184) within Moose::Meta::Method::Destructor::_initialize_body which was called:
# once (27µs+184µs) by Moose::Meta::Method::Destructor::new at line 46 | ||||
70 | 1 | 300ns | 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 | 1 | 5µs | 2 | 700ns | my $class = $self->associated_metaclass->name; # spent 600ns making 1 call to Class::MOP::Method::associated_metaclass
# spent 100ns making 1 call to Class::MOP::Package::name |
80 | 1 | 5µs | 2 | 57µs | my @source = ( # spent 54µs making 1 call to Moose::Meta::Method::Destructor::_generate_DEMOLISHALL
# spent 3µs making 1 call to Moose::Meta::Method::Destructor::_generate_fallback_destructor |
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 | 1 | 2µs | 1 | 1µs | warn join("\n", @source) if $self->options->{debug}; # spent 1µs making 1 call to Moose::Meta::Method::Destructor::options |
90 | |||||
91 | # spent 106µs (5+102) within Moose::Meta::Method::Destructor::try {...} which was called:
# once (5µs+102µs) by Try::Tiny::try at line 87 of Try/Tiny.pm | ||||
92 | 1 | 4µs | 1 | 102µs | $self->_compile_code(source => \@source); # spent 102µs making 1 call to Class::MOP::Method::Generated::_compile_code |
93 | } | ||||
94 | catch { | ||||
95 | my $source = join("\n", @source); | ||||
96 | throw_exception( CouldNotEvalDestructor => method_destructor_object => $self, | ||||
97 | source => $source, | ||||
98 | error => $_ | ||||
99 | ); | ||||
100 | 1 | 7µs | 2 | 125µs | }; # spent 118µs making 1 call to Try::Tiny::try
# spent 7µs making 1 call to Try::Tiny::catch |
101 | |||||
102 | 1 | 4µs | $self->{'body'} = $code; | ||
103 | } | ||||
104 | |||||
105 | # spent 3µs within Moose::Meta::Method::Destructor::_generate_fallback_destructor which was called:
# once (3µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 80 | ||||
106 | 1 | 1µs | my $self = shift; | ||
107 | 1 | 300ns | my ($inv) = @_; | ||
108 | |||||
109 | 1 | 3µs | return $inv . '->Moose::Object::DESTROY(@_)'; | ||
110 | } | ||||
111 | |||||
112 | # spent 54µs (6+48) within Moose::Meta::Method::Destructor::_generate_DEMOLISHALL which was called:
# once (6µs+48µs) by Moose::Meta::Method::Destructor::_initialize_body at line 80 | ||||
113 | 1 | 200ns | my $self = shift; | ||
114 | 1 | 200ns | my ($inv) = @_; | ||
115 | |||||
116 | 1 | 2µs | 2 | 48µs | my @methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH'); # spent 48µs making 1 call to Class::MOP::Class::find_all_methods_by_name
# spent 300ns making 1 call to Class::MOP::Method::associated_metaclass |
117 | 1 | 3µ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__ |