| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Method.pm |
| Statements | Executed 9404 statements in 15.0ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 383 | 5 | 5 | 5.26ms | 22.5ms | Class::MOP::Method::wrap |
| 481 | 3 | 3 | 4.34ms | 5.34ms | Class::MOP::Method::clone |
| 890 | 1 | 1 | 2.31ms | 2.83ms | Class::MOP::Method::attach_to_class |
| 95 | 1 | 1 | 359µs | 6.50ms | Class::MOP::Method::_new |
| 1 | 1 | 1 | 9µs | 30µs | Class::MOP::Method::BEGIN@21 |
| 1 | 1 | 1 | 7µs | 7µs | Class::MOP::Method::BEGIN@3 |
| 1 | 1 | 1 | 6µs | 616µs | Class::MOP::Method::BEGIN@16 |
| 1 | 1 | 1 | 5µs | 29µs | Class::MOP::Method::BEGIN@14 |
| 1 | 1 | 1 | 5µs | 8µs | Class::MOP::Method::BEGIN@11 |
| 1 | 1 | 1 | 5µs | 24µs | Class::MOP::Method::BEGIN@13 |
| 1 | 1 | 1 | 5µs | 15µs | Class::MOP::Method::BEGIN@10 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::__ANON__[:21] |
| 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 | |||||
| 2 | package Class::MOP::Method; | ||||
| 3 | # spent 7µs within Class::MOP::Method::BEGIN@3 which was called:
# once (7µs+0s) by base::import at line 5 | ||||
| 4 | 1 | 4µs | $Class::MOP::Method::AUTHORITY = 'cpan:STEVAN'; | ||
| 5 | 1 | 25µs | 1 | 7µs | } # spent 7µs making 1 call to Class::MOP::Method::BEGIN@3 |
| 6 | { | ||||
| 7 | 2 | 900ns | $Class::MOP::Method::VERSION = '2.1005'; | ||
| 8 | } | ||||
| 9 | |||||
| 10 | 2 | 21µs | 2 | 24µs | # spent 15µs (5+10) within Class::MOP::Method::BEGIN@10 which was called:
# once (5µs+10µs) by base::import at line 10 # spent 15µs making 1 call to Class::MOP::Method::BEGIN@10
# spent 10µs making 1 call to strict::import |
| 11 | 2 | 19µs | 2 | 11µs | # spent 8µs (5+3) within Class::MOP::Method::BEGIN@11 which was called:
# once (5µs+3µs) by base::import at line 11 # spent 8µs making 1 call to Class::MOP::Method::BEGIN@11
# spent 3µs making 1 call to warnings::import |
| 12 | |||||
| 13 | 2 | 22µs | 2 | 44µs | # spent 24µs (5+19) within Class::MOP::Method::BEGIN@13 which was called:
# once (5µs+19µs) by base::import at line 13 # spent 24µs making 1 call to Class::MOP::Method::BEGIN@13
# spent 19µs making 1 call to Exporter::import |
| 14 | 2 | 21µs | 2 | 53µs | # spent 29µs (5+24) within Class::MOP::Method::BEGIN@14 which was called:
# once (5µs+24µs) by base::import at line 14 # spent 29µs making 1 call to Class::MOP::Method::BEGIN@14
# spent 24µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 2 | 46µs | 2 | 616µs | # spent 616µs (6+610) within Class::MOP::Method::BEGIN@16 which was called:
# once (6µs+610µs) by base::import at line 16 # spent 616µs making 1 call to Class::MOP::Method::BEGIN@16
# spent 610µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 610µs |
| 17 | |||||
| 18 | # NOTE: | ||||
| 19 | # if poked in the right way, | ||||
| 20 | # they should act like CODE refs. | ||||
| 21 | 2 | 487µs | 2 | 51µs | # spent 30µs (9+21) within Class::MOP::Method::BEGIN@21 which was called:
# once (9µs+21µs) by base::import at line 21 # spent 30µs making 1 call to Class::MOP::Method::BEGIN@21
# spent 21µs making 1 call to overload::import |
| 22 | |||||
| 23 | # construction | ||||
| 24 | |||||
| 25 | # spent 22.5ms (5.26+17.2) within Class::MOP::Method::wrap which was called 383 times, avg 59µs/call:
# 183 times (2.10ms+1.41ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 48 of Class/MOP/Mixin/HasMethods.pm, avg 19µs/call
# 67 times (823µs+368µs) by Class::MOP::Method::Wrapped::wrap at line 94 of Class/MOP/Method/Wrapped.pm, avg 18µs/call
# 57 times (1.45ms+404µs) by Class::MOP::Attribute::_process_accessors at line 372 of Class/MOP/Attribute.pm, avg 32µs/call
# 55 times (667µs+14.8ms) by Class::MOP::Method::Meta::wrap at line 62 of Class/MOP/Method/Meta.pm, avg 281µs/call
# 21 times (218µs+236µs) by Moose::Meta::Method::Overridden::new at line 45 of Moose/Meta/Method/Overridden.pm, avg 22µs/call | ||||
| 26 | 383 | 423µs | my ( $class, @args ) = @_; | ||
| 27 | |||||
| 28 | 383 | 191µs | unshift @args, 'body' if @args % 2 == 1; | ||
| 29 | |||||
| 30 | 383 | 398µs | my %params = @args; | ||
| 31 | 383 | 62µs | my $code = $params{body}; | ||
| 32 | |||||
| 33 | 383 | 1.39ms | 766 | 305µs | if (blessed($code) && $code->isa(__PACKAGE__)) { # spent 158µs making 383 calls to Scalar::Util::blessed, avg 413ns/call
# spent 147µs making 383 calls to Scalar::Util::reftype, avg 383ns/call |
| 34 | my $method = $code->clone; | ||||
| 35 | delete $params{body}; | ||||
| 36 | Class::MOP::class_of($class)->rebless_instance($method, %params); | ||||
| 37 | return $method; | ||||
| 38 | } | ||||
| 39 | elsif (!ref $code || 'CODE' ne reftype($code)) { | ||||
| 40 | confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")"; | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | 383 | 82µs | ($params{package_name} && $params{name}) | ||
| 44 | || confess "You must supply the package_name and name parameters"; | ||||
| 45 | |||||
| 46 | 383 | 425µs | 383 | 16.7ms | my $self = $class->_new(\%params); # spent 8.60ms making 47 calls to Moose::Meta::Method::_new, avg 183µs/call
# spent 6.50ms making 95 calls to Class::MOP::Method::_new, avg 68µs/call
# spent 734µs making 96 calls to Moose::Meta::Role::Method::_new, avg 8µs/call
# spent 313µs making 67 calls to Class::MOP::Method::Wrapped::_new, avg 5µs/call
# spent 305µs making 57 calls to Class::MOP::Method::Accessor::_new, avg 5µs/call
# spent 210µs making 21 calls to Moose::Meta::Method::Overridden::_new, avg 10µs/call |
| 47 | |||||
| 48 | 383 | 1.50ms | 295 | 243µs | weaken($self->{associated_metaclass}) if $self->{associated_metaclass}; # spent 243µs making 295 calls to Scalar::Util::weaken, avg 822ns/call |
| 49 | |||||
| 50 | 383 | 962µs | return $self; | ||
| 51 | } | ||||
| 52 | |||||
| 53 | # spent 6.50ms (359µs+6.14) within Class::MOP::Method::_new which was called 95 times, avg 68µs/call:
# 95 times (359µs+6.14ms) by Class::MOP::Method::wrap at line 46, avg 68µs/call | ||||
| 54 | 95 | 16µs | my $class = shift; | ||
| 55 | |||||
| 56 | 95 | 81µs | 48 | 6.14ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 5.52ms making 24 calls to Class::MOP::Class::new_object, avg 230µs/call
# spent 621µs making 24 calls to Class::MOP::Class::initialize, avg 26µs/call |
| 57 | if $class ne __PACKAGE__; | ||||
| 58 | |||||
| 59 | 71 | 18µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 60 | |||||
| 61 | 71 | 257µs | return bless { | ||
| 62 | 'body' => $params->{body}, | ||||
| 63 | 'associated_metaclass' => $params->{associated_metaclass}, | ||||
| 64 | 'package_name' => $params->{package_name}, | ||||
| 65 | 'name' => $params->{name}, | ||||
| 66 | 'original_method' => $params->{original_method}, | ||||
| 67 | } => $class; | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | ## accessors | ||||
| 71 | |||||
| 72 | 53 | 90µs | sub associated_metaclass { shift->{'associated_metaclass'} } | ||
| 73 | |||||
| 74 | # spent 2.83ms (2.31+517µs) within Class::MOP::Method::attach_to_class which was called 890 times, avg 3µs/call:
# 890 times (2.31ms+517µs) by Class::MOP::Mixin::HasMethods::add_method at line 71 of Class/MOP/Mixin/HasMethods.pm, avg 3µs/call | ||||
| 75 | 890 | 161µs | my ( $self, $class ) = @_; | ||
| 76 | 890 | 302µs | $self->{associated_metaclass} = $class; | ||
| 77 | 890 | 2.64ms | 890 | 517µs | weaken($self->{associated_metaclass}); # spent 517µs making 890 calls to Scalar::Util::weaken, avg 581ns/call |
| 78 | } | ||||
| 79 | |||||
| 80 | sub detach_from_class { | ||||
| 81 | my $self = shift; | ||||
| 82 | delete $self->{associated_metaclass}; | ||||
| 83 | } | ||||
| 84 | |||||
| 85 | sub fully_qualified_name { | ||||
| 86 | my $self = shift; | ||||
| 87 | $self->package_name . '::' . $self->name; | ||||
| 88 | } | ||||
| 89 | |||||
| 90 | sub original_method { (shift)->{'original_method'} } | ||||
| 91 | |||||
| 92 | 481 | 819µs | sub _set_original_method { $_[0]->{'original_method'} = $_[1] } | ||
| 93 | |||||
| 94 | # It's possible that this could cause a loop if there is a circular | ||||
| 95 | # reference in here. That shouldn't ever happen in normal | ||||
| 96 | # circumstances, since original method only gets set when clone is | ||||
| 97 | # called. We _could_ check for such a loop, but it'd involve some sort | ||||
| 98 | # of package-lexical variable, and wouldn't be terribly subclassable. | ||||
| 99 | sub original_package_name { | ||||
| 100 | my $self = shift; | ||||
| 101 | |||||
| 102 | $self->original_method | ||||
| 103 | ? $self->original_method->original_package_name | ||||
| 104 | : $self->package_name; | ||||
| 105 | } | ||||
| 106 | |||||
| 107 | sub original_name { | ||||
| 108 | my $self = shift; | ||||
| 109 | |||||
| 110 | $self->original_method | ||||
| 111 | ? $self->original_method->original_name | ||||
| 112 | : $self->name; | ||||
| 113 | } | ||||
| 114 | |||||
| 115 | sub original_fully_qualified_name { | ||||
| 116 | my $self = shift; | ||||
| 117 | |||||
| 118 | $self->original_method | ||||
| 119 | ? $self->original_method->original_fully_qualified_name | ||||
| 120 | : $self->fully_qualified_name; | ||||
| 121 | } | ||||
| 122 | |||||
| 123 | sub execute { | ||||
| 124 | my $self = shift; | ||||
| 125 | $self->body->(@_); | ||||
| 126 | } | ||||
| 127 | |||||
| 128 | # We used to go through use Class::MOP::Class->clone_instance to do this, but | ||||
| 129 | # this was awfully slow. This method may be called a number of times when | ||||
| 130 | # classes are loaded (especially during Moose role application), so it is | ||||
| 131 | # worth optimizing. - DR | ||||
| 132 | # spent 5.34ms (4.34+1000µs) within Class::MOP::Method::clone which was called 481 times, avg 11µs/call:
# 408 times (3.70ms+838µs) by Class::MOP::Mixin::HasMethods::add_method at line 64 of Class/MOP/Mixin/HasMethods.pm, avg 11µs/call
# 59 times (500µs+127µs) by Moose::Meta::Role::Composite::add_method at line 91 of Moose/Meta/Role/Composite.pm, avg 11µs/call
# 14 times (145µs+35µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 13µs/call | ||||
| 133 | 481 | 50µs | my $self = shift; | ||
| 134 | |||||
| 135 | 481 | 2.50ms | 481 | 266µs | my $clone = bless { %{$self}, @_ }, blessed($self); # spent 266µs making 481 calls to Scalar::Util::blessed, avg 553ns/call |
| 136 | 481 | 1.00ms | 481 | 260µs | weaken($clone->{associated_metaclass}) if $clone->{associated_metaclass}; # spent 260µs making 481 calls to Scalar::Util::weaken, avg 541ns/call |
| 137 | |||||
| 138 | 481 | 299µs | 481 | 474µs | $clone->_set_original_method($self); # spent 474µs making 481 calls to Class::MOP::Method::_set_original_method, avg 985ns/call |
| 139 | |||||
| 140 | 481 | 649µs | return $clone; | ||
| 141 | } | ||||
| 142 | |||||
| 143 | 1 | 2µs | 1; | ||
| 144 | |||||
| 145 | # ABSTRACT: Method Meta Object | ||||
| 146 | |||||
| 147 | __END__ |