Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Method/Destructor.pm |
Statements | Executed 43 statements in 830µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 110µs | 409µs | new | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 39µs | 298µs | _initialize_body | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 11µs | 111µs | is_needed | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 10µs | 10µs | BEGIN@3 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 9µs | 84µs | _generate_DEMOLISHALL | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 6µs | 32µs | BEGIN@15 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 6µs | 9µs | BEGIN@11 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 6µs | 85µs | BEGIN@17 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 6µs | 16µs | BEGIN@10 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 6µs | 28µs | BEGIN@14 | Moose::Meta::Method::Destructor::
1 | 1 | 1 | 3µs | 3µs | BEGIN@13 | 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 | options | Moose::Meta::Method::Destructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:106] | Moose::Meta::Method::Destructor::
0 | 0 | 0 | 0s | 0s | __ANON__[:98] | Moose::Meta::Method::Destructor::
0 | 0 | 0 | 0s | 0s | initialize_body | Moose::Meta::Method::Destructor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Moose::Meta::Method::Destructor; | ||||
3 | # spent 10µs within Moose::Meta::Method::Destructor::BEGIN@3 which was called:
# once (10µs+0s) by Moose::Meta::Class::BEGIN@26 at line 5 | ||||
4 | 1 | 4µs | $Moose::Meta::Method::Destructor::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 29µs | 1 | 10µs | } # spent 10µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@3 |
6 | { | ||||
7 | 2 | 800ns | $Moose::Meta::Method::Destructor::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 22µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Meta::Method::Destructor::BEGIN@10 which was called:
# once (6µs+10µs) by Moose::Meta::Class::BEGIN@26 at line 10 # spent 16µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@10
# spent 10µs making 1 call to strict::import |
11 | 2 | 18µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Method::Destructor::BEGIN@11 which was called:
# once (6µs+3µs) by Moose::Meta::Class::BEGIN@26 at line 11 # spent 9µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@11
# spent 3µs making 1 call to warnings::import |
12 | |||||
13 | 2 | 19µs | 1 | 3µ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 # spent 3µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@13 |
14 | 2 | 19µs | 2 | 51µs | # spent 28µs (6+23) within Moose::Meta::Method::Destructor::BEGIN@14 which was called:
# once (6µs+23µs) by Moose::Meta::Class::BEGIN@26 at line 14 # spent 28µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@14
# spent 23µs making 1 call to Exporter::import |
15 | 2 | 23µs | 2 | 58µs | # spent 32µs (6+26) within Moose::Meta::Method::Destructor::BEGIN@15 which was called:
# once (6µs+26µs) by Moose::Meta::Class::BEGIN@26 at line 15 # spent 32µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@15
# spent 26µs making 1 call to Exporter::import |
16 | |||||
17 | 1 | 200ns | # spent 85µs (6+80) within Moose::Meta::Method::Destructor::BEGIN@17 which was called:
# once (6µs+80µs) by Moose::Meta::Class::BEGIN@26 at line 18 | ||
18 | 1 | 521µs | 2 | 165µs | 'Class::MOP::Method::Inlined'; # spent 85µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@17
# spent 80µs making 1 call to base::import |
19 | |||||
20 | # spent 409µs (110+299) within Moose::Meta::Method::Destructor::new which was called:
# once (110µs+299µs) by Class::MOP::Class::_inline_destructor at line 1477 of Class/MOP/Class.pm | ||||
21 | 1 | 400ns | my $class = shift; | ||
22 | 1 | 2µs | my %options = @_; | ||
23 | |||||
24 | 1 | 700ns | (ref $options{options} eq 'HASH') | ||
25 | || $class->throw_error("You must pass a hash of options", data => $options{options}); | ||||
26 | |||||
27 | 1 | 600ns | ($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 | 1 | 3µ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 | 1 | 99µs | 1 | 600ns | weaken($self->{'associated_metaclass'}); # spent 600ns making 1 call to Scalar::Util::weaken |
45 | |||||
46 | 1 | 2µs | 1 | 298µs | $self->_initialize_body; # spent 298µs making 1 call to Moose::Meta::Method::Destructor::_initialize_body |
47 | |||||
48 | 1 | 3µs | return $self; | ||
49 | } | ||||
50 | |||||
51 | ## accessors | ||||
52 | |||||
53 | 1 | 3µs | # spent 2µs within Moose::Meta::Method::Destructor::options which was called:
# once (2µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 94 | ||
54 | |||||
55 | ## method | ||||
56 | |||||
57 | # spent 111µs (11+100) within Moose::Meta::Method::Destructor::is_needed which was called:
# once (11µs+100µs) by Class::MOP::Class::_inline_destructor at line 1475 of Class/MOP/Class.pm | ||||
58 | 1 | 400ns | my $self = shift; | ||
59 | 1 | 300ns | my $metaclass = shift; | ||
60 | |||||
61 | 1 | 7µs | 2 | 2µs | ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') ) # spent 900ns making 1 call to Scalar::Util::blessed
# spent 800ns making 1 call to UNIVERSAL::isa |
62 | || $self->throw_error( | ||||
63 | "The is_needed method expected a metaclass object as its arugment"); | ||||
64 | |||||
65 | 1 | 4µs | 1 | 98µs | return $metaclass->find_method_by_name("DEMOLISHALL"); # spent 98µs making 1 call to Class::MOP::Class::find_method_by_name |
66 | } | ||||
67 | |||||
68 | sub 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 298µs (39+259) within Moose::Meta::Method::Destructor::_initialize_body which was called:
# once (39µs+259µs) by Moose::Meta::Method::Destructor::new at line 46 | ||||
75 | 1 | 300ns | 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 | |||||
84 | 1 | 6µs | 2 | 2µs | my $class = $self->associated_metaclass->name; # spent 900ns making 1 call to Class::MOP::Method::associated_metaclass
# spent 600ns making 1 call to Class::MOP::Package::name |
85 | 1 | 5µs | 2 | 87µs | my @source = ( # spent 84µ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 |
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 | ); | ||||
94 | 1 | 2µs | 1 | 2µs | warn join("\n", @source) if $self->options->{debug}; # spent 2µs making 1 call to Moose::Meta::Method::Destructor::options |
95 | |||||
96 | my $code = try { | ||||
97 | 1 | 7µs | 1 | 141µs | $self->_compile_code(source => \@source); # spent 141µs making 1 call to Class::MOP::Method::Generated::_compile_code |
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 | ); | ||||
106 | 1 | 11µs | 2 | 169µs | }; # spent 167µs making 1 call to Try::Tiny::try
# spent 2µs making 1 call to Try::Tiny::catch |
107 | |||||
108 | 1 | 4µs | $self->{'body'} = $code; | ||
109 | } | ||||
110 | |||||
111 | # 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 85 | ||||
112 | 1 | 200ns | my $self = shift; | ||
113 | 1 | 400ns | my ($inv) = @_; | ||
114 | |||||
115 | 1 | 4µs | return $inv . '->Moose::Object::DESTROY(@_)'; | ||
116 | } | ||||
117 | |||||
118 | # spent 84µs (9+75) within Moose::Meta::Method::Destructor::_generate_DEMOLISHALL which was called:
# once (9µs+75µs) by Moose::Meta::Method::Destructor::_initialize_body at line 85 | ||||
119 | 1 | 400ns | my $self = shift; | ||
120 | 1 | 300ns | my ($inv) = @_; | ||
121 | |||||
122 | 1 | 2µs | 2 | 75µs | my @methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH'); # spent 74µs making 1 call to Class::MOP::Class::find_all_methods_by_name
# spent 700ns making 1 call to Class::MOP::Method::associated_metaclass |
123 | 1 | 4µs | 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 | |||||
138 | 1 | 2µs | 1; | ||
139 | |||||
140 | # ABSTRACT: Method Meta Object for destructors | ||||
141 | |||||
142 | __END__ |