| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Method/Destructor.pm |
| Statements | Executed 1126 statements in 15.2ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 39 | 1 | 1 | 5.11ms | 60.9ms | Moose::Meta::Method::Destructor::_initialize_body |
| 39 | 1 | 1 | 4.00ms | 65.1ms | Moose::Meta::Method::Destructor::new |
| 42 | 1 | 1 | 2.25ms | 52.4ms | Moose::Meta::Method::Destructor::is_needed |
| 39 | 1 | 1 | 369µs | 369µs | Moose::Meta::Method::Destructor::options |
| 1 | 1 | 1 | 75µs | 94µs | Moose::Meta::Method::Destructor::BEGIN@4 |
| 1 | 1 | 1 | 46µs | 618µs | Moose::Meta::Method::Destructor::BEGIN@15 |
| 1 | 1 | 1 | 39µs | 108µs | Moose::Meta::Method::Destructor::BEGIN@5 |
| 1 | 1 | 1 | 38µs | 230µs | Moose::Meta::Method::Destructor::BEGIN@8 |
| 1 | 1 | 1 | 21µs | 21µs | Moose::Meta::Method::Destructor::BEGIN@9 |
| 1 | 1 | 1 | 20µs | 20µs | Moose::Meta::Method::Destructor::BEGIN@7 |
| 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 | 114µs | # spent 94µs (75+19) within Moose::Meta::Method::Destructor::BEGIN@4 which was called:
# once (75µs+19µs) by Moose::Meta::Class::BEGIN@24 at line 4 # spent 94µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@4
# spent 20µs making 1 call to strict::import |
| 5 | 3 | 98µs | 2 | 178µs | # spent 108µs (39+69) within Moose::Meta::Method::Destructor::BEGIN@5 which was called:
# once (39µ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 70µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 92µs | 1 | 20µs | # spent 20µs within Moose::Meta::Method::Destructor::BEGIN@7 which was called:
# once (20µs+0s) by Moose::Meta::Class::BEGIN@24 at line 7 # spent 20µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@7 |
| 8 | 3 | 101µs | 2 | 422µs | # spent 230µs (38+192) within Moose::Meta::Method::Destructor::BEGIN@8 which was called:
# once (38µs+192µs) by Moose::Meta::Class::BEGIN@24 at line 8 # spent 230µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@8
# spent 192µs making 1 call to Exporter::import |
| 9 | 3 | 229µs | 1 | 21µs | # spent 21µs within Moose::Meta::Method::Destructor::BEGIN@9 which was called:
# once (21µs+0s) by Moose::Meta::Class::BEGIN@24 at line 9 # spent 21µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@9 |
| 10 | |||||
| 11 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 12 | 1 | 66µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 13 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 14 | |||||
| 15 | 1 | 571µs | # spent 618µs (46+571) within Moose::Meta::Method::Destructor::BEGIN@15 which was called:
# once (46µs+571µs) by Moose::Meta::Class::BEGIN@24 at line 16 # spent 571µs making 1 call to base::import | ||
| 16 | 3 | 1.91ms | 1 | 618µs | 'Class::MOP::Method::Inlined'; # spent 618µs making 1 call to Moose::Meta::Method::Destructor::BEGIN@15 |
| 17 | |||||
| 18 | # spent 65.1ms (4.00+61.1) within Moose::Meta::Method::Destructor::new which was called 39 times, avg 1.67ms/call:
# 39 times (4.00ms+61.1ms) by Class::MOP::Class::_inline_destructor at line 1364 of Class/MOP/Class.pm, avg 1.67ms/call | ||||
| 19 | 312 | 4.17ms | 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 | 285µs | weaken($self->{'associated_metaclass'}); # spent 285µs making 39 calls to Scalar::Util::weaken, avg 7µs/call | ||
| 42 | |||||
| 43 | 39 | 60.9ms | $self->_initialize_body; # spent 60.9ms making 39 calls to Moose::Meta::Method::Destructor::_initialize_body, avg 1.56ms/call | ||
| 44 | |||||
| 45 | return $self; | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | ## accessors | ||||
| 49 | |||||
| 50 | 39 | 491µs | # spent 369µs within Moose::Meta::Method::Destructor::options which was called 39 times, avg 9µs/call:
# 39 times (369µs+0s) by Moose::Meta::Method::Destructor::_initialize_body at line 109, avg 9µs/call | ||
| 51 | |||||
| 52 | ## method | ||||
| 53 | |||||
| 54 | # spent 52.4ms (2.25+50.1) within Moose::Meta::Method::Destructor::is_needed which was called 42 times, avg 1.25ms/call:
# 42 times (2.25ms+50.1ms) by Class::MOP::Class::_inline_destructor at line 1362 of Class/MOP/Class.pm, avg 1.25ms/call | ||||
| 55 | 168 | 2.90ms | my $self = shift; | ||
| 56 | my $metaclass = shift; | ||||
| 57 | |||||
| 58 | 84 | 598µs | ( blessed $metaclass && $metaclass->isa('Class::MOP::Class') ) # spent 301µs making 42 calls to UNIVERSAL::isa, avg 7µs/call
# spent 297µs making 42 calls to Scalar::Util::blessed, avg 7µs/call | ||
| 59 | || $self->throw_error( | ||||
| 60 | "The is_needed method expected a metaclass object as its arugment"); | ||||
| 61 | |||||
| 62 | 42 | 49.5ms | return $metaclass->find_method_by_name("DEMOLISHALL"); # spent 49.5ms making 42 calls to Class::MOP::Class::find_method_by_name, avg 1.18ms/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 60.9ms (5.11+55.8) within Moose::Meta::Method::Destructor::_initialize_body which was called 39 times, avg 1.56ms/call:
# 39 times (5.11ms+55.8ms) by Moose::Meta::Method::Destructor::new at line 43, avg 1.56ms/call | ||||
| 72 | 585 | 4.98ms | 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 | 37.1ms | my @DEMOLISH_methods = $self->associated_metaclass->find_all_methods_by_name('DEMOLISH'); # spent 36.7ms making 39 calls to Class::MOP::Class::find_all_methods_by_name, avg 941µs/call
# spent 366µs making 39 calls to Class::MOP::Method::associated_metaclass, avg 9µs/call | ||
| 82 | |||||
| 83 | my $source; | ||||
| 84 | $source = 'sub {' . "\n"; | ||||
| 85 | $source .= 'my $self = shift;' . "\n"; | ||||
| 86 | $source .= 'return $self->Moose::Object::DESTROY(@_)' . "\n"; | ||||
| 87 | $source .= ' if Scalar::Util::blessed($self) ne '; | ||||
| 88 | 78 | 657µs | $source .= "'" . $self->associated_metaclass->name . "'"; # spent 406µs making 39 calls to Class::MOP::Method::associated_metaclass, avg 10µs/call
# spent 250µs making 39 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 89 | $source .= ';' . "\n"; | ||||
| 90 | |||||
| 91 | if ( @DEMOLISH_methods ) { | ||||
| 92 | $source .= 'local $?;' . "\n"; | ||||
| 93 | |||||
| 94 | $source .= 'my $in_global_destruction = Devel::GlobalDestruction::in_global_destruction;' . "\n"; | ||||
| 95 | |||||
| 96 | $source .= 'Try::Tiny::try {' . "\n"; | ||||
| 97 | |||||
| 98 | $source .= '$self->' . $_->{class} . '::DEMOLISH($in_global_destruction);' . "\n" | ||||
| 99 | for @DEMOLISH_methods; | ||||
| 100 | |||||
| 101 | $source .= '}'; | ||||
| 102 | $source .= q[ Try::Tiny::catch { no warnings 'misc'; die $_ };] . "\n"; | ||||
| 103 | $source .= 'return;' . "\n"; | ||||
| 104 | |||||
| 105 | } | ||||
| 106 | |||||
| 107 | $source .= '}'; | ||||
| 108 | |||||
| 109 | 39 | 369µs | warn $source if $self->options->{debug}; # spent 369µs making 39 calls to Moose::Meta::Method::Destructor::options, avg 9µs/call | ||
| 110 | |||||
| 111 | 39 | 17.7ms | my ( $code, $e ) = $self->_compile_code( # spent 17.7ms making 39 calls to Class::MOP::Method::Generated::_compile_code, avg 453µs/call | ||
| 112 | environment => {}, | ||||
| 113 | code => $source, | ||||
| 114 | ); | ||||
| 115 | |||||
| 116 | $self->throw_error( | ||||
| 117 | "Could not eval the destructor :\n\n$source\n\nbecause :\n\n$e", | ||||
| 118 | error => $e, data => $source ) | ||||
| 119 | if $e; | ||||
| 120 | |||||
| 121 | $self->{'body'} = $code; | ||||
| 122 | } | ||||
| 123 | |||||
| 124 | |||||
| 125 | 1 | 12µs | 1; | ||
| 126 | |||||
| 127 | __END__ |