| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Class/MOP/Method.pm |
| Statements | Executed 15534 statements in 209ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1065 | 3 | 3 | 65.6ms | 83.6ms | Class::MOP::Method::clone |
| 532 | 5 | 5 | 51.7ms | 263ms | Class::MOP::Method::wrap |
| 1619 | 1 | 1 | 42.7ms | 53.0ms | Class::MOP::Method::attach_to_class |
| 94 | 2 | 2 | 3.90ms | 45.5ms | Class::MOP::Method::_new |
| 1 | 1 | 1 | 68µs | 85µs | Class::MOP::Method::BEGIN@4 |
| 1 | 1 | 1 | 54µs | 242µs | Class::MOP::Method::BEGIN@8 |
| 1 | 1 | 1 | 49µs | 205µs | Class::MOP::Method::BEGIN@19 |
| 1 | 1 | 1 | 43µs | 213µs | Class::MOP::Method::BEGIN@7 |
| 1 | 1 | 1 | 41µs | 3.18ms | Class::MOP::Method::BEGIN@14 |
| 1 | 1 | 1 | 38µs | 105µs | Class::MOP::Method::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Method::__ANON__[:19] |
| 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 | |||||
| 4 | 3 | 93µs | 2 | 102µs | # spent 85µs (68+17) within Class::MOP::Method::BEGIN@4 which was called:
# once (68µs+17µs) by base::import at line 4 # spent 85µs making 1 call to Class::MOP::Method::BEGIN@4
# spent 17µs making 1 call to strict::import |
| 5 | 3 | 98µs | 2 | 173µs | # spent 105µs (38+67) within Class::MOP::Method::BEGIN@5 which was called:
# once (38µs+67µs) by base::import at line 5 # spent 105µs making 1 call to Class::MOP::Method::BEGIN@5
# spent 67µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 130µs | 2 | 382µs | # spent 213µs (43+169) within Class::MOP::Method::BEGIN@7 which was called:
# once (43µs+169µs) by base::import at line 7 # spent 213µs making 1 call to Class::MOP::Method::BEGIN@7
# spent 169µs making 1 call to Exporter::import |
| 8 | 3 | 221µs | 2 | 429µs | # spent 242µs (54+188) within Class::MOP::Method::BEGIN@8 which was called:
# once (54µs+188µs) by base::import at line 8 # spent 242µs making 1 call to Class::MOP::Method::BEGIN@8
# spent 188µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 4µs | our $VERSION = '1.11'; | ||
| 11 | 1 | 62µs | $VERSION = eval $VERSION; # spent 14µs executing statements in string eval | ||
| 12 | 1 | 5µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 13 | |||||
| 14 | 3 | 208µs | 2 | 3.18ms | # spent 3.18ms (41µs+3.14) within Class::MOP::Method::BEGIN@14 which was called:
# once (41µs+3.14ms) by base::import at line 14 # spent 3.18ms making 1 call to Class::MOP::Method::BEGIN@14
# spent 3.14ms making 1 call to base::import, recursion: max depth 1, sum of overlapping time 3.14ms |
| 15 | |||||
| 16 | # NOTE: | ||||
| 17 | # if poked in the right way, | ||||
| 18 | # they should act like CODE refs. | ||||
| 19 | 3 | 1.93ms | 2 | 362µs | # spent 205µs (49+157) within Class::MOP::Method::BEGIN@19 which was called:
# once (49µs+157µs) by base::import at line 19 # spent 205µs making 1 call to Class::MOP::Method::BEGIN@19
# spent 156µs making 1 call to overload::import |
| 20 | |||||
| 21 | # construction | ||||
| 22 | |||||
| 23 | # spent 263ms (51.7+212) within Class::MOP::Method::wrap which was called 532 times, avg 495µs/call:
# 257 times (24.9ms+20.1ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 51 of Class/MOP/Mixin/HasMethods.pm, avg 175µs/call
# 126 times (13.2ms+181ms) by Class::MOP::Method::Meta::wrap at line 58 of Class/MOP/Method/Meta.pm, avg 1.54ms/call
# 75 times (7.13ms+4.95ms) by Class::MOP::Method::Wrapped::wrap at line 92 of Class/MOP/Method/Wrapped.pm, avg 161µs/call
# 57 times (5.02ms+3.54ms) by Class::MOP::Attribute::_process_accessors at line 312 of Class/MOP/Attribute.pm, avg 150µs/call
# 17 times (1.45ms+1.87ms) by Moose::Meta::Method::Overridden::new at line 43 of Moose/Meta/Method/Overridden.pm, avg 195µs/call | ||||
| 24 | 4788 | 59.9ms | my ( $class, @args ) = @_; | ||
| 25 | |||||
| 26 | unshift @args, 'body' if @args % 2 == 1; | ||||
| 27 | |||||
| 28 | my %params = @args; | ||||
| 29 | my $code = $params{body}; | ||||
| 30 | |||||
| 31 | 1064 | 5.76ms | if (blessed($code) && $code->isa(__PACKAGE__)) { # spent 2.91ms making 532 calls to Scalar::Util::blessed, avg 5µs/call
# spent 2.85ms making 532 calls to Scalar::Util::reftype, avg 5µs/call | ||
| 32 | my $method = $code->clone; | ||||
| 33 | delete $params{body}; | ||||
| 34 | Class::MOP::class_of($class)->rebless_instance($method, %params); | ||||
| 35 | return $method; | ||||
| 36 | } | ||||
| 37 | elsif (!ref $code || 'CODE' ne reftype($code)) { | ||||
| 38 | confess "You must supply a CODE reference to bless, not (" . ($code || 'undef') . ")"; | ||||
| 39 | } | ||||
| 40 | |||||
| 41 | ($params{package_name} && $params{name}) | ||||
| 42 | || confess "You must supply the package_name and name parameters"; | ||||
| 43 | |||||
| 44 | 532 | 203ms | my $self = $class->_new(\%params); # spent 148ms making 147 calls to Moose::Meta::Method::_new, avg 1.01ms/call
# spent 36.4ms making 92 calls to Class::MOP::Method::_new, avg 396µs/call
# spent 9.33ms making 144 calls to Moose::Meta::Role::Method::_new, avg 65µs/call
# spent 4.12ms making 75 calls to Class::MOP::Method::Wrapped::_new, avg 55µs/call
# spent 2.89ms making 57 calls to Class::MOP::Method::Accessor::_new, avg 51µs/call
# spent 1.69ms making 17 calls to Moose::Meta::Method::Overridden::_new, avg 100µs/call | ||
| 45 | |||||
| 46 | 383 | 3.21ms | weaken($self->{associated_metaclass}) if $self->{associated_metaclass}; # spent 3.21ms making 383 calls to Scalar::Util::weaken, avg 8µs/call | ||
| 47 | |||||
| 48 | return $self; | ||||
| 49 | } | ||||
| 50 | |||||
| 51 | # spent 45.5ms (3.90+41.6) within Class::MOP::Method::_new which was called 94 times, avg 484µs/call:
# 92 times (3.82ms+32.6ms) by Class::MOP::Method::wrap at line 44, avg 396µs/call
# 2 times (73µs+8.99ms) by Class::MOP::Method::Accessor::new at line 32 of Class/MOP/Method/Accessor.pm, avg 4.53ms/call | ||||
| 52 | 324 | 4.10ms | my $class = shift; | ||
| 53 | |||||
| 54 | 52 | 41.6ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 32.3ms making 26 calls to Class::MOP::Class::new_object, avg 1.24ms/call
# spent 9.32ms making 26 calls to Class::MOP::Class::initialize, avg 358µs/call | ||
| 55 | if $class ne __PACKAGE__; | ||||
| 56 | |||||
| 57 | my $params = @_ == 1 ? $_[0] : {@_}; | ||||
| 58 | |||||
| 59 | return bless { | ||||
| 60 | 'body' => $params->{body}, | ||||
| 61 | 'associated_metaclass' => $params->{associated_metaclass}, | ||||
| 62 | 'package_name' => $params->{package_name}, | ||||
| 63 | 'name' => $params->{name}, | ||||
| 64 | 'original_method' => $params->{original_method}, | ||||
| 65 | } => $class; | ||||
| 66 | } | ||||
| 67 | |||||
| 68 | ## accessors | ||||
| 69 | |||||
| 70 | 218 | 3.11ms | sub associated_metaclass { shift->{'associated_metaclass'} } | ||
| 71 | |||||
| 72 | # spent 53.0ms (42.7+10.3) within Class::MOP::Method::attach_to_class which was called 1619 times, avg 33µs/call:
# 1619 times (42.7ms+10.3ms) by Class::MOP::Mixin::HasMethods::add_method at line 74 of Class/MOP/Mixin/HasMethods.pm, avg 33µs/call | ||||
| 73 | 4857 | 53.8ms | my ( $self, $class ) = @_; | ||
| 74 | $self->{associated_metaclass} = $class; | ||||
| 75 | 1619 | 10.3ms | weaken($self->{associated_metaclass}); # spent 10.3ms making 1619 calls to Scalar::Util::weaken, avg 6µs/call | ||
| 76 | } | ||||
| 77 | |||||
| 78 | sub detach_from_class { | ||||
| 79 | my $self = shift; | ||||
| 80 | delete $self->{associated_metaclass}; | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | sub fully_qualified_name { | ||||
| 84 | my $self = shift; | ||||
| 85 | $self->package_name . '::' . $self->name; | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | sub original_method { (shift)->{'original_method'} } | ||||
| 89 | |||||
| 90 | 1065 | 15.2ms | sub _set_original_method { $_[0]->{'original_method'} = $_[1] } | ||
| 91 | |||||
| 92 | # It's possible that this could cause a loop if there is a circular | ||||
| 93 | # reference in here. That shouldn't ever happen in normal | ||||
| 94 | # circumstances, since original method only gets set when clone is | ||||
| 95 | # called. We _could_ check for such a loop, but it'd involve some sort | ||||
| 96 | # of package-lexical variable, and wouldn't be terribly subclassable. | ||||
| 97 | sub original_package_name { | ||||
| 98 | my $self = shift; | ||||
| 99 | |||||
| 100 | $self->original_method | ||||
| 101 | ? $self->original_method->original_package_name | ||||
| 102 | : $self->package_name; | ||||
| 103 | } | ||||
| 104 | |||||
| 105 | sub original_name { | ||||
| 106 | my $self = shift; | ||||
| 107 | |||||
| 108 | $self->original_method | ||||
| 109 | ? $self->original_method->original_name | ||||
| 110 | : $self->name; | ||||
| 111 | } | ||||
| 112 | |||||
| 113 | sub original_fully_qualified_name { | ||||
| 114 | my $self = shift; | ||||
| 115 | |||||
| 116 | $self->original_method | ||||
| 117 | ? $self->original_method->original_fully_qualified_name | ||||
| 118 | : $self->fully_qualified_name; | ||||
| 119 | } | ||||
| 120 | |||||
| 121 | sub execute { | ||||
| 122 | my $self = shift; | ||||
| 123 | $self->body->(@_); | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | # We used to go through use Class::MOP::Class->clone_instance to do this, but | ||||
| 127 | # this was awfully slow. This method may be called a number of times when | ||||
| 128 | # classes are loaded (especially during Moose role application), so it is | ||||
| 129 | # worth optimizing. - DR | ||||
| 130 | # spent 83.6ms (65.6+18.0) within Class::MOP::Method::clone which was called 1065 times, avg 79µs/call:
# 876 times (54.8ms+15.0ms) by Class::MOP::Mixin::HasMethods::add_method at line 67 of Class/MOP/Mixin/HasMethods.pm, avg 80µs/call
# 179 times (10.1ms+2.90ms) by Moose::Meta::Role::Composite::add_method at line 83 of Moose/Meta/Role/Composite.pm, avg 72µs/call
# 10 times (732µs+166µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 90µs/call | ||||
| 131 | 4260 | 70.7ms | my $self = shift; | ||
| 132 | |||||
| 133 | 1065 | 6.16ms | my $clone = bless { %{$self}, @_ }, blessed($self); # spent 6.16ms making 1065 calls to Scalar::Util::blessed, avg 6µs/call | ||
| 134 | |||||
| 135 | 1065 | 11.9ms | $clone->_set_original_method($self); # spent 11.9ms making 1065 calls to Class::MOP::Method::_set_original_method, avg 11µs/call | ||
| 136 | |||||
| 137 | return $clone; | ||||
| 138 | } | ||||
| 139 | |||||
| 140 | 1 | 15µs | 1; | ||
| 141 | |||||
| 142 | __END__ |