| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Method.pm |
| Statements | Executed 3621 statements in 4.79ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 205 | 4 | 4 | 2.34ms | 11.4ms | Class::MOP::Method::wrap |
| 378 | 1 | 1 | 750µs | 891µs | Class::MOP::Method::attach_to_class |
| 87 | 1 | 1 | 263µs | 8.22ms | Class::MOP::Method::_new |
| 26 | 2 | 2 | 186µs | 225µs | Class::MOP::Method::clone |
| 168 | 9 | 6 | 87µs | 87µs | Class::MOP::Method::__ANON__[:16] |
| 1 | 1 | 1 | 12µs | 56µs | Class::MOP::Method::BEGIN@15 |
| 1 | 1 | 1 | 8µs | 10µs | Class::MOP::Method::BEGIN@4 |
| 1 | 1 | 1 | 8µs | 444µs | Class::MOP::Method::BEGIN@9 |
| 1 | 1 | 1 | 7µs | 10µs | Class::MOP::Method::BEGIN@5 |
| 1 | 1 | 1 | 5µs | 28µs | Class::MOP::Method::BEGIN@7 |
| 1 | 1 | 1 | 600ns | 600ns | Class::MOP::Method::is_stub (xsub) |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::__ANON__[:15] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::__ANON__[:17] |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::detach_from_class |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::execute |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::fully_qualified_name |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::original_fully_qualified_name |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::original_name |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::original_package_name |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::Method; | ||||
| 2 | 1 | 200ns | our $VERSION = '2.1605'; | ||
| 3 | |||||
| 4 | 2 | 14µs | 2 | 11µs | # spent 10µs (8+1) within Class::MOP::Method::BEGIN@4 which was called:
# once (8µs+1µs) by parent::import at line 4 # spent 10µs making 1 call to Class::MOP::Method::BEGIN@4
# spent 1µs making 1 call to strict::import |
| 5 | 2 | 18µs | 2 | 13µs | # spent 10µs (7+3) within Class::MOP::Method::BEGIN@5 which was called:
# once (7µs+3µs) by parent::import at line 5 # spent 10µs making 1 call to Class::MOP::Method::BEGIN@5
# spent 3µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 2 | 32µs | 2 | 51µs | # spent 28µs (5+23) within Class::MOP::Method::BEGIN@7 which was called:
# once (5µs+23µs) by parent::import at line 7 # spent 28µs making 1 call to Class::MOP::Method::BEGIN@7
# spent 23µs making 1 call to Exporter::import |
| 8 | |||||
| 9 | 2 | 67µs | 2 | 444µs | # spent 444µs (8+437) within Class::MOP::Method::BEGIN@9 which was called:
# once (8µs+437µs) by parent::import at line 9 # spent 444µs making 1 call to Class::MOP::Method::BEGIN@9
# spent 436µs making 1 call to parent::import, recursion: max depth 1, sum of overlapping time 436µs |
| 10 | |||||
| 11 | # NOTE: | ||||
| 12 | # if poked in the right way, | ||||
| 13 | # they should act like CODE refs. | ||||
| 14 | use overload | ||||
| 15 | # spent 56µs (12+44) within Class::MOP::Method::BEGIN@15 which was called:
# once (12µs+44µs) by parent::import at line 18 | ||||
| 16 | 168 | 204µs | # spent 87µs within Class::MOP::Method::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Method.pm:16] which was called 168 times, avg 515ns/call:
# 88 times (48µs+0s) by Class::MOP::Mixin::HasMethods::get_method at line 112 of Class/MOP/Mixin/HasMethods.pm, avg 544ns/call
# 43 times (21µs+0s) by Class::MOP::MiniTrait::apply at line 21 of Class/MOP/MiniTrait.pm, avg 479ns/call
# 30 times (15µs+0s) by Class::MOP::Method::Inlined::can_be_inlined at line 37 of Class/MOP/Method/Inlined.pm, avg 490ns/call
# 2 times (1µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 22 of Class/MOP/Mixin/HasMethods.pm, avg 650ns/call
# once (1µs+0s) by Moose::Meta::Class::_inline_BUILDARGS at line 327 of Moose/Meta/Class.pm
# once (600ns+0s) by Class::MOP::Class::_inline_destructor at line 1494 of Class/MOP/Class.pm
# once (200ns+0s) by Class::MOP::Mixin::HasMethods::has_method at line 100 of Class/MOP/Mixin/HasMethods.pm
# once (100ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1035 of Moose/Meta/Attribute.pm
# once (100ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1023 of Moose/Meta/Attribute.pm | ||
| 17 | '""' => sub { overload::StrVal($_[0]) }, | ||||
| 18 | 2 | 346µs | 2 | 100µs | fallback => 1; # spent 56µs making 1 call to Class::MOP::Method::BEGIN@15
# spent 44µs making 1 call to overload::import |
| 19 | |||||
| 20 | # construction | ||||
| 21 | |||||
| 22 | # spent 11.4ms (2.34+9.06) within Class::MOP::Method::wrap which was called 205 times, avg 56µs/call:
# 70 times (1.05ms+357µs) by Class::MOP::Attribute::_process_accessors at line 390 of Class/MOP/Attribute.pm, avg 20µs/call
# 67 times (595µs+262µs) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 40 of Class/MOP/Mixin/HasMethods.pm, avg 13µs/call
# 43 times (383µs+155µs) by Class::MOP::Method::Wrapped::wrap at line 97 of Class/MOP/Method/Wrapped.pm, avg 12µs/call
# 25 times (312µs+8.29ms) by Class::MOP::Method::Meta::wrap at line 58 of Class/MOP/Method/Meta.pm, avg 344µs/call | ||||
| 23 | 205 | 158µs | my ( $class, @args ) = @_; | ||
| 24 | |||||
| 25 | 205 | 103µs | unshift @args, 'body' if @args % 2 == 1; | ||
| 26 | |||||
| 27 | 205 | 192µs | my %params = @args; | ||
| 28 | 205 | 42µs | my $code = $params{body}; | ||
| 29 | |||||
| 30 | 205 | 573µs | 410 | 105µs | if (blessed($code) && $code->isa(__PACKAGE__)) { # spent 55µs making 205 calls to Scalar::Util::reftype, avg 268ns/call
# spent 50µs making 205 calls to Scalar::Util::blessed, avg 244ns/call |
| 31 | my $method = $code->clone; | ||||
| 32 | delete $params{body}; | ||||
| 33 | Class::MOP::class_of($class)->rebless_instance($method, %params); | ||||
| 34 | return $method; | ||||
| 35 | } | ||||
| 36 | elsif (!ref $code || 'CODE' ne reftype($code)) { | ||||
| 37 | $class->_throw_exception( WrapTakesACodeRefToBless => params => \%params, | ||||
| 38 | class => $class, | ||||
| 39 | code => $code | ||||
| 40 | ); | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | ($params{package_name} && $params{name}) | ||||
| 44 | 205 | 53µs | || $class->_throw_exception( PackageNameAndNameParamsNotGivenToWrap => params => \%params, | ||
| 45 | class => $class, | ||||
| 46 | code => $code | ||||
| 47 | ); | ||||
| 48 | |||||
| 49 | 205 | 217µs | 205 | 8.88ms | my $self = $class->_new(\%params); # spent 8.22ms making 87 calls to Class::MOP::Method::_new, avg 94µs/call
# spent 274µs making 70 calls to Class::MOP::Method::Accessor::_new, avg 4µs/call
# spent 249µs making 5 calls to Moose::Meta::Method::_new, avg 50µs/call
# spent 136µs making 43 calls to Class::MOP::Method::Wrapped::_new, avg 3µs/call |
| 50 | |||||
| 51 | 205 | 761µs | 162 | 84µs | weaken($self->{associated_metaclass}) if $self->{associated_metaclass}; # spent 84µs making 162 calls to Scalar::Util::weaken, avg 519ns/call |
| 52 | |||||
| 53 | 205 | 369µs | return $self; | ||
| 54 | } | ||||
| 55 | |||||
| 56 | # spent 8.22ms (263µs+7.95) within Class::MOP::Method::_new which was called 87 times, avg 94µs/call:
# 87 times (263µs+7.95ms) by Class::MOP::Method::wrap at line 49, avg 94µs/call | ||||
| 57 | 87 | 15µs | my $class = shift; | ||
| 58 | |||||
| 59 | 87 | 112µs | 48 | 7.95ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 5.18ms making 24 calls to Class::MOP::Class::initialize, avg 216µs/call
# spent 2.77ms making 24 calls to Class::MOP::Class::new_object, avg 116µs/call |
| 60 | if $class ne __PACKAGE__; | ||||
| 61 | |||||
| 62 | 63 | 15µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 63 | |||||
| 64 | return bless { | ||||
| 65 | 'body' => $params->{body}, | ||||
| 66 | 'associated_metaclass' => $params->{associated_metaclass}, | ||||
| 67 | 'package_name' => $params->{package_name}, | ||||
| 68 | 'name' => $params->{name}, | ||||
| 69 | 'original_method' => $params->{original_method}, | ||||
| 70 | 63 | 159µs | } => $class; | ||
| 71 | } | ||||
| 72 | |||||
| 73 | ## accessors | ||||
| 74 | |||||
| 75 | 6 | 12µs | sub associated_metaclass { shift->{'associated_metaclass'} } | ||
| 76 | |||||
| 77 | # spent 891µs (750+142) within Class::MOP::Method::attach_to_class which was called 378 times, avg 2µs/call:
# 378 times (750µs+142µs) by Class::MOP::Mixin::HasMethods::add_method at line 63 of Class/MOP/Mixin/HasMethods.pm, avg 2µs/call | ||||
| 78 | 378 | 66µs | my ( $self, $class ) = @_; | ||
| 79 | 378 | 144µs | $self->{associated_metaclass} = $class; | ||
| 80 | 378 | 875µs | 378 | 142µs | weaken($self->{associated_metaclass}); # spent 142µs making 378 calls to Scalar::Util::weaken, avg 375ns/call |
| 81 | } | ||||
| 82 | |||||
| 83 | sub detach_from_class { | ||||
| 84 | my $self = shift; | ||||
| 85 | delete $self->{associated_metaclass}; | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | sub fully_qualified_name { | ||||
| 89 | my $self = shift; | ||||
| 90 | $self->package_name . '::' . $self->name; | ||||
| 91 | } | ||||
| 92 | |||||
| 93 | sub original_method { (shift)->{'original_method'} } | ||||
| 94 | |||||
| 95 | 26 | 32µs | sub _set_original_method { $_[0]->{'original_method'} = $_[1] } | ||
| 96 | |||||
| 97 | # It's possible that this could cause a loop if there is a circular | ||||
| 98 | # reference in here. That shouldn't ever happen in normal | ||||
| 99 | # circumstances, since original method only gets set when clone is | ||||
| 100 | # called. We _could_ check for such a loop, but it'd involve some sort | ||||
| 101 | # of package-lexical variable, and wouldn't be terribly subclassable. | ||||
| 102 | sub original_package_name { | ||||
| 103 | my $self = shift; | ||||
| 104 | |||||
| 105 | $self->original_method | ||||
| 106 | ? $self->original_method->original_package_name | ||||
| 107 | : $self->package_name; | ||||
| 108 | } | ||||
| 109 | |||||
| 110 | sub original_name { | ||||
| 111 | my $self = shift; | ||||
| 112 | |||||
| 113 | $self->original_method | ||||
| 114 | ? $self->original_method->original_name | ||||
| 115 | : $self->name; | ||||
| 116 | } | ||||
| 117 | |||||
| 118 | sub original_fully_qualified_name { | ||||
| 119 | my $self = shift; | ||||
| 120 | |||||
| 121 | $self->original_method | ||||
| 122 | ? $self->original_method->original_fully_qualified_name | ||||
| 123 | : $self->fully_qualified_name; | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | sub execute { | ||||
| 127 | my $self = shift; | ||||
| 128 | $self->body->(@_); | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | # We used to go through use Class::MOP::Class->clone_instance to do this, but | ||||
| 132 | # this was awfully slow. This method may be called a number of times when | ||||
| 133 | # classes are loaded (especially during Moose role application), so it is | ||||
| 134 | # worth optimizing. - DR | ||||
| 135 | # spent 225µs (186+39) within Class::MOP::Method::clone which was called 26 times, avg 9µs/call:
# 13 times (117µs+27µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 11µs/call
# 13 times (69µs+12µs) by Class::MOP::Mixin::HasMethods::add_method at line 56 of Class/MOP/Mixin/HasMethods.pm, avg 6µs/call | ||||
| 136 | 26 | 5µs | my $self = shift; | ||
| 137 | |||||
| 138 | 26 | 98µs | 26 | 10µs | my $clone = bless { %{$self}, @_ }, blessed($self); # spent 10µs making 26 calls to Scalar::Util::blessed, avg 373ns/call |
| 139 | 26 | 50µs | 26 | 9µs | weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass}; # spent 9µs making 26 calls to Scalar::Util::weaken, avg 346ns/call |
| 140 | |||||
| 141 | 26 | 23µs | 26 | 20µs | $clone->_set_original_method($self); # spent 20µs making 26 calls to Class::MOP::Method::_set_original_method, avg 781ns/call |
| 142 | |||||
| 143 | 26 | 31µs | return $clone; | ||
| 144 | } | ||||
| 145 | |||||
| 146 | 1 | 2µs | 1; | ||
| 147 | |||||
| 148 | # ABSTRACT: Method Meta Object | ||||
| 149 | |||||
| 150 | __END__ | ||||
# spent 600ns within Class::MOP::Method::is_stub which was called:
# once (600ns+0s) by Moose::Meta::Attribute::_process_accessors at line 1035 of Moose/Meta/Attribute.pm |