| 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 28803 statements in 390ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2206 | 3 | 3 | 133ms | 171ms | Class::MOP::Method::clone |
| 936 | 6 | 6 | 87.9ms | 443ms | Class::MOP::Method::wrap |
| 2877 | 1 | 1 | 72.8ms | 96.1ms | Class::MOP::Method::attach_to_class |
| 95 | 2 | 2 | 3.73ms | 45.6ms | Class::MOP::Method::_new |
| 1 | 1 | 1 | 71µs | 90µs | Class::MOP::Method::BEGIN@4 |
| 1 | 1 | 1 | 47µs | 198µs | Class::MOP::Method::BEGIN@19 |
| 1 | 1 | 1 | 41µs | 3.10ms | Class::MOP::Method::BEGIN@14 |
| 1 | 1 | 1 | 37µs | 105µs | Class::MOP::Method::BEGIN@5 |
| 1 | 1 | 1 | 37µs | 217µs | Class::MOP::Method::BEGIN@8 |
| 1 | 1 | 1 | 36µs | 272µs | Class::MOP::Method::BEGIN@7 |
| 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 | 119µs | 2 | 108µs | # spent 90µs (71+18) within Class::MOP::Method::BEGIN@4 which was called:
# once (71µs+18µs) by base::import at line 4 # spent 90µs making 1 call to Class::MOP::Method::BEGIN@4
# spent 18µs making 1 call to strict::import |
| 5 | 3 | 98µs | 2 | 173µs | # spent 105µs (37+68) within Class::MOP::Method::BEGIN@5 which was called:
# once (37µs+68µs) by base::import at line 5 # spent 105µs making 1 call to Class::MOP::Method::BEGIN@5
# spent 68µs making 1 call to warnings::import |
| 6 | |||||
| 7 | 3 | 117µs | 2 | 508µs | # spent 272µs (36+236) within Class::MOP::Method::BEGIN@7 which was called:
# once (36µs+236µs) by base::import at line 7 # spent 272µs making 1 call to Class::MOP::Method::BEGIN@7
# spent 236µs making 1 call to Exporter::import |
| 8 | 3 | 205µs | 2 | 398µs | # spent 217µs (37+180) within Class::MOP::Method::BEGIN@8 which was called:
# once (37µs+180µs) by base::import at line 8 # spent 217µs making 1 call to Class::MOP::Method::BEGIN@8
# spent 180µs making 1 call to Exporter::import |
| 9 | |||||
| 10 | 1 | 4µs | our $VERSION = '1.11'; | ||
| 11 | 1 | 106µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 12 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 13 | |||||
| 14 | 3 | 212µs | 2 | 3.10ms | # spent 3.10ms (41µs+3.06) within Class::MOP::Method::BEGIN@14 which was called:
# once (41µs+3.06ms) by base::import at line 14 # spent 3.10ms making 1 call to Class::MOP::Method::BEGIN@14
# spent 3.06ms making 1 call to base::import, recursion: max depth 2, sum of overlapping time 3.06ms |
| 15 | |||||
| 16 | # NOTE: | ||||
| 17 | # if poked in the right way, | ||||
| 18 | # they should act like CODE refs. | ||||
| 19 | 3 | 1.99ms | 2 | 349µs | # spent 198µs (47+151) within Class::MOP::Method::BEGIN@19 which was called:
# once (47µs+151µs) by base::import at line 19 # spent 198µs making 1 call to Class::MOP::Method::BEGIN@19
# spent 151µs making 1 call to overload::import |
| 20 | |||||
| 21 | # construction | ||||
| 22 | |||||
| 23 | # spent 443ms (87.9+355) within Class::MOP::Method::wrap which was called 936 times, avg 474µs/call:
# 296 times (28.4ms+21.0ms) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 51 of Class/MOP/Mixin/HasMethods.pm, avg 167µs/call
# 216 times (22.4ms+307ms) by Class::MOP::Method::Meta::wrap at line 58 of Class/MOP/Method/Meta.pm, avg 1.53ms/call
# 212 times (17.7ms+13.7ms) by MooseX::Role::Parameterized::method at line 71 of MooseX/Role/Parameterized.pm, avg 148µs/call
# 110 times (10.5ms+6.32ms) by Class::MOP::Method::Wrapped::wrap at line 92 of Class/MOP/Method/Wrapped.pm, avg 153µs/call
# 57 times (4.92ms+3.46ms) by Class::MOP::Attribute::_process_accessors at line 312 of Class/MOP/Attribute.pm, avg 147µs/call
# 45 times (3.96ms+3.57ms) by Moose::Meta::Method::Overridden::new at line 43 of Moose/Meta/Method/Overridden.pm, avg 168µs/call | ||||
| 24 | 936 | 10.1ms | my ( $class, @args ) = @_; | ||
| 25 | |||||
| 26 | 936 | 4.56ms | unshift @args, 'body' if @args % 2 == 1; | ||
| 27 | |||||
| 28 | 936 | 8.30ms | my %params = @args; | ||
| 29 | 936 | 2.60ms | my $code = $params{body}; | ||
| 30 | |||||
| 31 | 936 | 31.2ms | 1872 | 9.96ms | if (blessed($code) && $code->isa(__PACKAGE__)) { # spent 5.11ms making 936 calls to Scalar::Util::blessed, avg 5µs/call
# spent 4.84ms making 936 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 | 936 | 2.93ms | ($params{package_name} && $params{name}) | ||
| 42 | || confess "You must supply the package_name and name parameters"; | ||||
| 43 | |||||
| 44 | 936 | 13.1ms | 936 | 341ms | my $self = $class->_new(\%params); # spent 270ms making 208 calls to Moose::Meta::Method::_new, avg 1.30ms/call
# spent 36.5ms making 93 calls to Class::MOP::Method::_new, avg 392µs/call
# spent 23.5ms making 423 calls to Moose::Meta::Role::Method::_new, avg 56µs/call
# spent 5.10ms making 110 calls to Class::MOP::Method::Wrapped::_new, avg 46µs/call
# spent 3.07ms making 45 calls to Moose::Meta::Method::Overridden::_new, avg 68µs/call
# spent 2.84ms making 57 calls to Class::MOP::Method::Accessor::_new, avg 50µs/call |
| 45 | |||||
| 46 | 936 | 12.8ms | 512 | 4.44ms | weaken($self->{associated_metaclass}) if $self->{associated_metaclass}; # spent 4.44ms making 512 calls to Scalar::Util::weaken, avg 9µs/call |
| 47 | |||||
| 48 | 936 | 15.8ms | return $self; | ||
| 49 | } | ||||
| 50 | |||||
| 51 | # spent 45.6ms (3.73+41.9) within Class::MOP::Method::_new which was called 95 times, avg 480µs/call:
# 93 times (3.66ms+32.8ms) by Class::MOP::Method::wrap at line 44, avg 392µs/call
# 2 times (74µs+9.05ms) by Class::MOP::Method::Accessor::new at line 32 of Class/MOP/Method/Accessor.pm, avg 4.56ms/call | ||||
| 52 | 95 | 329µs | my $class = shift; | ||
| 53 | |||||
| 54 | 95 | 971µs | 52 | 41.9ms | return Class::MOP::Class->initialize($class)->new_object(@_) # spent 32.6ms making 26 calls to Class::MOP::Class::new_object, avg 1.25ms/call
# spent 9.30ms making 26 calls to Class::MOP::Class::initialize, avg 358µs/call |
| 55 | if $class ne __PACKAGE__; | ||||
| 56 | |||||
| 57 | 69 | 225µs | my $params = @_ == 1 ? $_[0] : {@_}; | ||
| 58 | |||||
| 59 | 69 | 2.46ms | 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 | 368 | 5.13ms | sub associated_metaclass { shift->{'associated_metaclass'} } | ||
| 71 | |||||
| 72 | # spent 96.1ms (72.8+23.3) within Class::MOP::Method::attach_to_class which was called 2877 times, avg 33µs/call:
# 2877 times (72.8ms+23.3ms) by Class::MOP::Mixin::HasMethods::add_method at line 74 of Class/MOP/Mixin/HasMethods.pm, avg 33µs/call | ||||
| 73 | 2877 | 9.74ms | my ( $self, $class ) = @_; | ||
| 74 | 2877 | 10.9ms | $self->{associated_metaclass} = $class; | ||
| 75 | 2877 | 79.4ms | 2877 | 23.3ms | weaken($self->{associated_metaclass}); # spent 23.3ms making 2877 calls to Scalar::Util::weaken, avg 8µ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 | 2206 | 32.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 171ms (133+38.5) within Class::MOP::Method::clone which was called 2206 times, avg 78µs/call:
# 2018 times (121ms+35.3ms) by Class::MOP::Mixin::HasMethods::add_method at line 67 of Class/MOP/Mixin/HasMethods.pm, avg 78µs/call
# 178 times (10.8ms+2.97ms) by Moose::Meta::Role::Composite::add_method at line 83 of Moose/Meta/Role/Composite.pm, avg 77µs/call
# 10 times (801µs+177µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 98µs/call | ||||
| 131 | 2206 | 6.75ms | my $self = shift; | ||
| 132 | |||||
| 133 | 2206 | 89.7ms | 2206 | 12.9ms | my $clone = bless { %{$self}, @_ }, blessed($self); # spent 12.9ms making 2206 calls to Scalar::Util::blessed, avg 6µs/call |
| 134 | |||||
| 135 | 2206 | 23.2ms | 2206 | 25.5ms | $clone->_set_original_method($self); # spent 25.5ms making 2206 calls to Class::MOP::Method::_set_original_method, avg 12µs/call |
| 136 | |||||
| 137 | 2206 | 25.0ms | return $clone; | ||
| 138 | } | ||||
| 139 | |||||
| 140 | 1 | 11µs | 1; | ||
| 141 | |||||
| 142 | __END__ |