| Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/Method/Destructor.pm |
| Statements | Executed 448 statements in 2.97ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 16 | 1 | 1 | 961µs | 7.29ms | Moose::Meta::Method::Destructor::new |
| 16 | 1 | 1 | 645µs | 6.31ms | Moose::Meta::Method::Destructor::_initialize_body |
| 16 | 1 | 1 | 197µs | 1.60ms | Moose::Meta::Method::Destructor::is_needed |
| 16 | 1 | 1 | 142µs | 1.96ms | Moose::Meta::Method::Destructor::_generate_DEMOLISHALL |
| 16 | 1 | 1 | 58µs | 58µs | Moose::Meta::Method::Destructor::_generate_fallback_destructor |
| 16 | 1 | 1 | 35µs | 35µs | Moose::Meta::Method::Destructor::options |
| 1 | 1 | 1 | 31µs | 49µs | Moose::Meta::Method::Destructor::BEGIN@4 |
| 1 | 1 | 1 | 16µs | 22µs | Moose::Meta::Method::Destructor::BEGIN@5 |
| 1 | 1 | 1 | 14µs | 62µs | Moose::Meta::Method::Destructor::BEGIN@9 |
| 1 | 1 | 1 | 12µs | 65µs | Moose::Meta::Method::Destructor::BEGIN@11 |
| 1 | 1 | 1 | 12µs | 54µs | Moose::Meta::Method::Destructor::BEGIN@8 |
| 1 | 1 | 1 | 11µs | 212µs | Moose::Meta::Method::Destructor::BEGIN@14 |
| 1 | 1 | 1 | 5µs | 5µs | Moose::Meta::Method::Destructor::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Destructor::__ANON__[:100] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Destructor::__ANON__[:93] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Method::Destructor; | ||||
| 2 | 1 | 700ns | our $VERSION = '2.1403'; | ||
| 3 | |||||
| 4 | 2 | 37µs | 2 | 68µs | # spent 49µs (31+19) within Moose::Meta::Method::Destructor::BEGIN@4 which was called:
# once (31µs+19µs) by Moose::Meta::Class::BEGIN@17 at line 4 # spent 49µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@4
# spent 19µs making 1 call to strict::import |
| 5 | 2 | 36µs | 2 | 28µs | # spent 22µs (16+6) within Moose::Meta::Method::Destructor::BEGIN@5 which was called:
# once (16µs+6µs) by Moose::Meta::Class::BEGIN@17 at line 5 # spent 22µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@5
# spent 6µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 35µs | 1 | 5µs | # spent 5µs within Moose::Meta::Method::Destructor::BEGIN@7 which was called:
# once (5µs+0s) by Moose::Meta::Class::BEGIN@17 at line 7 # spent 5µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@7 |
| 8 | 2 | 37µs | 2 | 96µs | # spent 54µs (12+42) within Moose::Meta::Method::Destructor::BEGIN@8 which was called:
# once (12µs+42µs) by Moose::Meta::Class::BEGIN@17 at line 8 # spent 54µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@8
# spent 42µs making 1 call to Exporter::import |
| 9 | 2 | 49µs | 2 | 110µs | # spent 62µs (14+48) within Moose::Meta::Method::Destructor::BEGIN@9 which was called:
# once (14µs+48µs) by Moose::Meta::Class::BEGIN@17 at line 9 # spent 62µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@9
# spent 48µs making 1 call to Exporter::import |
| 10 | |||||
| 11 | 1 | 500ns | # spent 65µs (12+53) within Moose::Meta::Method::Destructor::BEGIN@11 which was called:
# once (12µs+53µs) by Moose::Meta::Class::BEGIN@17 at line 12 | ||
| 12 | 1 | 40µs | 2 | 118µs | 'Class::MOP::Method::Inlined'; # spent 65µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@11
# spent 53µs making 1 call to parent::import |
| 13 | |||||
| 14 | 2 | 690µs | 2 | 412µs | # spent 212µs (11+200) within Moose::Meta::Method::Destructor::BEGIN@14 which was called:
# once (11µs+200µs) by Moose::Meta::Class::BEGIN@17 at line 14 # spent 212µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@14
# spent 200µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 15 | |||||
| 16 | # spent 7.29ms (961µs+6.33) within Moose::Meta::Method::Destructor::new which was called 16 times, avg 456µs/call:
# 16 times (961µs+6.33ms) by Class::MOP::Class::_inline_destructor at line 1496 of Class/MOP/Class.pm, avg 456µs/call | ||||
| 17 | 16 | 10µs | my $class = shift; | ||
| 18 | 16 | 53µs | my %options = @_; | ||
| 19 | |||||
| 20 | 16 | 15µs | (ref $options{options} eq 'HASH') | ||
| 21 | || throw_exception( MustPassAHashOfOptions => params => \%options, | ||||
| 22 | class => $class | ||||
| 23 | ); | ||||
| 24 | |||||
| 25 | 16 | 14µs | ($options{package_name} && $options{name}) | ||
| 26 | || throw_exception( MustSupplyPackageNameAndName => params => \%options, | ||||
| 27 | class => $class | ||||
| 28 | ); | ||||
| 29 | |||||
| 30 | 16 | 703µ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 | 16 | 71µs | 16 | 18µs | weaken($self->{'associated_metaclass'}); # spent 18µs making 16 calls to Scalar::Util::weaken, avg 1µs/call |
| 45 | |||||
| 46 | 16 | 36µs | 16 | 6.31ms | $self->_initialize_body; # spent 6.31ms making 16 calls to Moose::Meta::Method::Destructor::_initialize_body, avg 395µs/call |
| 47 | |||||
| 48 | 16 | 60µs | return $self; | ||
| 49 | } | ||||
| 50 | |||||
| 51 | ## accessors | ||||
| 52 | |||||
| 53 | 16 | 50µs | # spent 35µs within Moose::Meta::Method::Destructor::options which was called 16 times, avg 2µs/call:
# 16 times (35µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 89, avg 2µs/call | ||
| 54 | |||||
| 55 | ## method | ||||
| 56 | |||||
| 57 | # spent 1.60ms (197µs+1.40) within Moose::Meta::Method::Destructor::is_needed which was called 16 times, avg 100µs/call:
# 16 times (197µs+1.40ms) by Class::MOP::Class::_inline_destructor at line 1494 of Class/MOP/Class.pm, avg 100µs/call | ||||
| 58 | 16 | 11µs | my $self = shift; | ||
| 59 | 16 | 5µs | my $metaclass = shift; | ||
| 60 | |||||
| 61 | 16 | 139µs | 32 | 44µs | ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') ) # spent 22µs making 16 calls to Scalar::Util::blessed, avg 1µs/call
# spent 21µs making 16 calls to UNIVERSAL::isa, avg 1µs/call |
| 62 | || throw_exception( MethodExpectedAMetaclassObject => metaclass => $metaclass, | ||||
| 63 | class => $self | ||||
| 64 | ); | ||||
| 65 | |||||
| 66 | 16 | 71µs | 16 | 1.36ms | return $metaclass->find_method_by_name("DEMOLISHALL"); # spent 1.36ms making 16 calls to Class::MOP::Class::find_method_by_name, avg 85µs/call |
| 67 | } | ||||
| 68 | |||||
| 69 | # spent 6.31ms (645µs+5.67) within Moose::Meta::Method::Destructor::_initialize_body which was called 16 times, avg 395µs/call:
# 16 times (645µs+5.67ms) by Moose::Meta::Method::Destructor::new at line 46, avg 395µs/call | ||||
| 70 | 16 | 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 | 16 | 80µs | 32 | 31µs | my $class = $self->associated_metaclass->name; # spent 21µs making 16 calls to Class::MOP::Method::associated_metaclass, avg 1µs/call
# spent 10µs making 16 calls to Class::MOP::Package::name, avg 619ns/call |
| 80 | 16 | 122µs | 32 | 2.02ms | my @source = ( # spent 1.96ms making 16 calls to Moose::Meta::Method::Destructor::_generate_DEMOLISHALL, avg 123µs/call
# spent 58µs making 16 calls to Moose::Meta::Method::Destructor::_generate_fallback_destructor, avg 4µ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 | 16 | 34µs | 16 | 35µs | warn join("\n", @source) if $self->options->{debug}; # spent 35µs making 16 calls to Moose::Meta::Method::Destructor::options, avg 2µs/call |
| 90 | |||||
| 91 | my $code = try { | ||||
| 92 | 16 | 71µs | 16 | 2.96ms | $self->_compile_code(source => \@source); # spent 2.96ms making 16 calls to Class::MOP::Method::Generated::_compile_code, avg 185µ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 | 16 | 222µs | 32 | 3.58ms | }; # spent 3.50ms making 16 calls to Try::Tiny::try, avg 219µs/call
# spent 84µs making 16 calls to Try::Tiny::catch, avg 5µs/call |
| 101 | |||||
| 102 | 16 | 80µs | $self->{'body'} = $code; | ||
| 103 | } | ||||
| 104 | |||||
| 105 | # spent 58µs within Moose::Meta::Method::Destructor::_generate_fallback_destructor which was called 16 times, avg 4µs/call:
# 16 times (58µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 80, avg 4µs/call | ||||
| 106 | 16 | 8µs | my $self = shift; | ||
| 107 | 16 | 10µs | my ($inv) = @_; | ||
| 108 | |||||
| 109 | 16 | 56µs | return $inv . '->Moose::Object::DESTROY(@_)'; | ||
| 110 | } | ||||
| 111 | |||||
| 112 | # spent 1.96ms (142µs+1.82) within Moose::Meta::Method::Destructor::_generate_DEMOLISHALL which was called 16 times, avg 123µs/call:
# 16 times (142µs+1.82ms) by Moose::Meta::Method::Destructor::_initialize_body at line 80, avg 123µs/call | ||||
| 113 | 16 | 6µs | my $self = shift; | ||
| 114 | 16 | 12µs | my ($inv) = @_; | ||
| 115 | |||||
| 116 | 16 | 52µs | 32 | 1.82ms | my @methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH'); # spent 1.81ms making 16 calls to Class::MOP::Class::find_all_methods_by_name, avg 113µs/call
# spent 17µs making 16 calls to Class::MOP::Method::associated_metaclass, avg 1µs/call |
| 117 | 16 | 46µ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 | 3µs | 1; | ||
| 133 | |||||
| 134 | # ABSTRACT: Method Meta Object for destructors | ||||
| 135 | |||||
| 136 | __END__ |