| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Method/Destructor.pm |
| Statements | Executed 1091 statements in 19.3ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 39 | 1 | 1 | 6.18ms | 79.2ms | Moose::Meta::Method::Destructor::_initialize_body |
| 39 | 1 | 1 | 3.99ms | 83.5ms | Moose::Meta::Method::Destructor::new |
| 43 | 1 | 1 | 2.30ms | 38.7ms | Moose::Meta::Method::Destructor::is_needed |
| 39 | 1 | 1 | 1.65ms | 29.2ms | Moose::Meta::Method::Destructor::_generate_DEMOLISHALL |
| 39 | 1 | 1 | 926µs | 37.5ms | Moose::Meta::Method::Destructor::__ANON__[:94] |
| 39 | 1 | 1 | 712µs | 712µs | Moose::Meta::Method::Destructor::_generate_fallback_destructor |
| 39 | 1 | 1 | 381µs | 381µs | Moose::Meta::Method::Destructor::options |
| 1 | 1 | 1 | 96µs | 116µs | Moose::Meta::Method::Destructor::BEGIN@4 |
| 1 | 1 | 1 | 42µs | 460µs | Moose::Meta::Method::Destructor::BEGIN@15 |
| 1 | 1 | 1 | 39µs | 229µs | Moose::Meta::Method::Destructor::BEGIN@8 |
| 1 | 1 | 1 | 38µs | 108µs | Moose::Meta::Method::Destructor::BEGIN@5 |
| 1 | 1 | 1 | 38µs | 212µs | Moose::Meta::Method::Destructor::BEGIN@9 |
| 1 | 1 | 1 | 28µs | 28µs | Moose::Meta::Method::Destructor::BEGIN@7 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Destructor::__ANON__[:102] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Method::Destructor::initialize_body |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | package Moose::Meta::Method::Destructor; | ||||
| 3 | |||||
| 4 | 3 | 103µs | 2 | 135µs | # spent 116µs (96+19) within Moose::Meta::Method::Destructor::BEGIN@4 which was called:
# once (96µs+19µs) by Moose::Meta::Class::BEGIN@24 at line 4 # spent 116µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@4
# spent 19µs making 1 call to strict::import |
| 5 | 3 | 119µs | 2 | 177µs | # spent 108µs (38+69) within Moose::Meta::Method::Destructor::BEGIN@5 which was called:
# once (38µs+69µs) by Moose::Meta::Class::BEGIN@24 at line 5 # spent 108µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@5
# spent 69µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 107µs | 1 | 28µs | # spent 28µs within Moose::Meta::Method::Destructor::BEGIN@7 which was called:
# once (28µs+0s) by Moose::Meta::Class::BEGIN@24 at line 7 # spent 28µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@7 |
| 8 | 3 | 100µs | 2 | 419µs | # spent 229µs (39+190) within Moose::Meta::Method::Destructor::BEGIN@8 which was called:
# once (39µs+190µs) by Moose::Meta::Class::BEGIN@24 at line 8 # spent 229µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@8
# spent 190µs making 1 call to Exporter::import |
| 9 | 3 | 329µs | 2 | 387µs | # spent 212µs (38+175) within Moose::Meta::Method::Destructor::BEGIN@9 which was called:
# once (38µs+175µs) by Moose::Meta::Class::BEGIN@24 at line 9 # spent 212µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@9
# spent 175µs making 1 call to Exporter::import |
| 10 | |||||
| 11 | 1 | 4µs | our $VERSION = '1.19'; | ||
| 12 | 1 | 59µs | $VERSION = eval $VERSION; # spent 10µs executing statements in string eval | ||
| 13 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 14 | |||||
| 15 | 1 | 418µs | # spent 460µs (42+418) within Moose::Meta::Method::Destructor::BEGIN@15 which was called:
# once (42µs+418µs) by Moose::Meta::Class::BEGIN@24 at line 16 # spent 418µs making 1 call to base::import | ||
| 16 | 3 | 1.82ms | 1 | 460µs | 'Class::MOP::Method::Inlined'; # spent 460µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@15 |
| 17 | |||||
| 18 | # spent 83.5ms (3.99+79.5) within Moose::Meta::Method::Destructor::new which was called 39 times, avg 2.14ms/call:
# 39 times (3.99ms+79.5ms) by Class::MOP::Class::_inline_destructor at line 1505 of Class/MOP/Class.pm, avg 2.14ms/call | ||||
| 19 | 312 | 4.25ms | my $class = shift; | ||
| 20 | my %options = @_; | ||||
| 21 | |||||
| 22 | (ref $options{options} eq 'HASH') | ||||
| 23 | || $class->throw_error("You must pass a hash of options", data => $options{options}); | ||||
| 24 | |||||
| 25 | ($options{package_name} && $options{name}) | ||||
| 26 | || $class->throw_error("You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT"); | ||||
| 27 | |||||
| 28 | my $self = bless { | ||||
| 29 | # from our superclass | ||||
| 30 | 'body' => undef, | ||||
| 31 | 'package_name' => $options{package_name}, | ||||
| 32 | 'name' => $options{name}, | ||||
| 33 | # ... | ||||
| 34 | 'options' => $options{options}, | ||||
| 35 | 'associated_metaclass' => $options{metaclass}, | ||||
| 36 | } => $class; | ||||
| 37 | |||||
| 38 | # we don't want this creating | ||||
| 39 | # a cycle in the code, if not | ||||
| 40 | # needed | ||||
| 41 | 39 | 310µs | weaken($self->{'associated_metaclass'}); # spent 310µs making 39 calls to Scalar::Util::weaken, avg 8µs/call | ||
| 42 | |||||
| 43 | 39 | 79.2ms | $self->_initialize_body; # spent 79.2ms making 39 calls to Moose::Meta::Method::Destructor::_initialize_body, avg 2.03ms/call | ||
| 44 | |||||
| 45 | return $self; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | ## accessors | ||||
| 49 | |||||
| 50 | 39 | 523µs | # spent 381µs within Moose::Meta::Method::Destructor::options which was called 39 times, avg 10µs/call:
# 39 times (381µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 90, avg 10µs/call | ||
| 51 | |||||
| 52 | ## method | ||||
| 53 | |||||
| 54 | # spent 38.7ms (2.30+36.4) within Moose::Meta::Method::Destructor::is_needed which was called 43 times, avg 900µs/call:
# 43 times (2.30ms+36.4ms) by Class::MOP::Class::_inline_destructor at line 1503 of Class/MOP/Class.pm, avg 900µs/call | ||||
| 55 | 172 | 2.89ms | my $self = shift; | ||
| 56 | my $metaclass = shift; | ||||
| 57 | |||||
| 58 | 86 | 639µs | ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') ) # spent 339µs making 43 calls to Scalar::Util::blessed, avg 8µs/call
# spent 300µs making 43 calls to UNIVERSAL::isa, avg 7µs/call | ||
| 59 | || $self->throw_error( | ||||
| 60 | "The is_needed method expected a metaclass object as its arugment"); | ||||
| 61 | |||||
| 62 | 43 | 35.8ms | return $metaclass->find_method_by_name("DEMOLISHALL"); # spent 35.8ms making 43 calls to Class::MOP::Class::find_method_by_name, avg 832µs/call | ||
| 63 | } | ||||
| 64 | |||||
| 65 | sub initialize_body { | ||||
| 66 | Carp::cluck('The initialize_body method has been made private.' | ||||
| 67 | . " The public version is deprecated and will be removed in a future release.\n"); | ||||
| 68 | shift->_initialize_body; | ||||
| 69 | } | ||||
| 70 | |||||
| 71 | # spent 79.2ms (6.18+73.0) within Moose::Meta::Method::Destructor::_initialize_body which was called 39 times, avg 2.03ms/call:
# 39 times (6.18ms+73.0ms) by Moose::Meta::Method::Destructor::new at line 43, avg 2.03ms/call | ||||
| 72 | 234 | 5.70ms | my $self = shift; | ||
| 73 | # TODO: | ||||
| 74 | # the %options should also include a both | ||||
| 75 | # a call 'initializer' and call 'SUPER::' | ||||
| 76 | # options, which should cover approx 90% | ||||
| 77 | # of the possible use cases (even if it | ||||
| 78 | # requires some adaption on the part of | ||||
| 79 | # the author, after all, nothing is free) | ||||
| 80 | |||||
| 81 | 78 | 587µs | my $class = $self->associated_metaclass->name; # spent 385µs making 39 calls to Class::MOP::Method::associated_metaclass, avg 10µs/call
# spent 203µs making 39 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 82 | 78 | 30.0ms | my @source = ( # spent 29.2ms making 39 calls to Moose::Meta::Method::Destructor::_generate_DEMOLISHALL, avg 750µs/call
# spent 712µs making 39 calls to Moose::Meta::Method::Destructor::_generate_fallback_destructor, avg 18µs/call | ||
| 83 | 'sub {', | ||||
| 84 | 'my $self = shift;', | ||||
| 85 | 'return ' . $self->_generate_fallback_destructor('$self'), | ||||
| 86 | 'if Scalar::Util::blessed($self) ne \'' . $class . '\';', | ||||
| 87 | $self->_generate_DEMOLISHALL('$self'), | ||||
| 88 | '}', | ||||
| 89 | ); | ||||
| 90 | 39 | 381µs | warn join("\n", @source) if $self->options->{debug}; # spent 381µs making 39 calls to Moose::Meta::Method::Destructor::options, avg 10µs/call | ||
| 91 | |||||
| 92 | # spent 37.5ms (926µs+36.6) within Moose::Meta::Method::Destructor::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Method/Destructor.pm:94] which was called 39 times, avg 961µs/call:
# 39 times (926µs+36.6ms) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 961µs/call | ||||
| 93 | 39 | 930µs | 39 | 36.6ms | $self->_compile_code(source => \@source); # spent 36.6ms making 39 calls to Class::MOP::Method::Generated::_compile_code, avg 937µs/call |
| 94 | } | ||||
| 95 | catch { | ||||
| 96 | my $source = join("\n", @source); | ||||
| 97 | $self->throw_error( | ||||
| 98 | "Could not eval the destructor :\n\n$source\n\nbecause :\n\n$_", | ||||
| 99 | error => $_, | ||||
| 100 | data => $source, | ||||
| 101 | ); | ||||
| 102 | 78 | 41.1ms | }; # spent 41.3ms making 39 calls to Try::Tiny::try, avg 1.06ms/call, recursion: max depth 2, sum of overlapping time 1.05ms
# spent 829µs making 39 calls to Try::Tiny::catch, avg 21µs/call | ||
| 103 | |||||
| 104 | $self->{'body'} = $code; | ||||
| 105 | } | ||||
| 106 | |||||
| 107 | # spent 712µs within Moose::Meta::Method::Destructor::_generate_fallback_destructor which was called 39 times, avg 18µs/call:
# 39 times (712µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 82, avg 18µs/call | ||||
| 108 | 117 | 833µs | my $self = shift; | ||
| 109 | my ($inv) = @_; | ||||
| 110 | |||||
| 111 | return $inv . '->Moose::Object::DESTROY(@_)'; | ||||
| 112 | } | ||||
| 113 | |||||
| 114 | # spent 29.2ms (1.65+27.6) within Moose::Meta::Method::Destructor::_generate_DEMOLISHALL which was called 39 times, avg 750µs/call:
# 39 times (1.65ms+27.6ms) by Moose::Meta::Method::Destructor::_initialize_body at line 82, avg 750µs/call | ||||
| 115 | 156 | 1.49ms | my $self = shift; | ||
| 116 | my ($inv) = @_; | ||||
| 117 | |||||
| 118 | 78 | 27.6ms | my @methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH'); # spent 27.3ms making 39 calls to Class::MOP::Class::find_all_methods_by_name, avg 699µs/call
# spent 320µs making 39 calls to Class::MOP::Method::associated_metaclass, avg 8µs/call | ||
| 119 | return unless @methods; | ||||
| 120 | |||||
| 121 | return ( | ||||
| 122 | 'local $?;', | ||||
| 123 | 'my $igd = Devel::GlobalDestruction::in_global_destruction;', | ||||
| 124 | 'Try::Tiny::try {', | ||||
| 125 | (map { $inv . '->' . $_->{class} . '::DEMOLISH($igd);' } @methods), | ||||
| 126 | '}', | ||||
| 127 | 'Try::Tiny::catch {', | ||||
| 128 | 'no warnings \'misc\';', | ||||
| 129 | 'die $_;', | ||||
| 130 | '};', | ||||
| 131 | 'return;', | ||||
| 132 | ); | ||||
| 133 | } | ||||
| 134 | |||||
| 135 | |||||
| 136 | 1 | 11µs | 1; | ||
| 137 | |||||
| 138 | __END__ |