| Filename | /home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Mixin/HasMethods.pm |
| Statements | Executed 90222 statements in 1.33s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2175 | 25 | 12 | 351ms | 979ms | Class::MOP::Mixin::HasMethods::add_method |
| 6066 | 2 | 1 | 249ms | 767ms | Class::MOP::Mixin::HasMethods::_get_maybe_raw_method |
| 5411 | 12 | 9 | 164ms | 929ms | Class::MOP::Mixin::HasMethods::get_method |
| 2175 | 1 | 1 | 67.6ms | 99.4ms | Class::MOP::Mixin::HasMethods::update_package_cache_flag |
| 1797 | 1 | 1 | 62.6ms | 83.9ms | Class::MOP::Mixin::HasMethods::_code_is_mine |
| 248 | 2 | 1 | 51.2ms | 532ms | Class::MOP::Mixin::HasMethods::_full_method_map |
| 174 | 7 | 6 | 18.4ms | 451ms | Class::MOP::Mixin::HasMethods::_add_meta_method |
| 655 | 10 | 7 | 17.7ms | 109ms | Class::MOP::Mixin::HasMethods::has_method |
| 299 | 1 | 1 | 17.3ms | 72.7ms | Class::MOP::Mixin::HasMethods::wrap_method_body |
| 2175 | 1 | 1 | 16.4ms | 16.4ms | Class::MOP::Mixin::HasMethods::CORE:match (opcode) |
| 199 | 5 | 5 | 5.29ms | 309ms | Class::MOP::Mixin::HasMethods::_get_local_methods |
| 42 | 1 | 1 | 3.80ms | 172ms | Class::MOP::Mixin::HasMethods::_restore_metamethods_from |
| 1 | 1 | 1 | 1.99ms | 14.4ms | Class::MOP::Mixin::HasMethods::BEGIN@6 |
| 141 | 2 | 2 | 1.54ms | 1.54ms | Class::MOP::Mixin::HasMethods::reset_package_cache_flag |
| 49 | 1 | 1 | 1.44ms | 230ms | Class::MOP::Mixin::HasMethods::get_method_list |
| 1 | 1 | 1 | 1.08ms | 3.29ms | Class::MOP::Mixin::HasMethods::BEGIN@14 |
| 25 | 2 | 1 | 254µs | 254µs | Class::MOP::Mixin::HasMethods::_meta_method_class |
| 1 | 1 | 1 | 65µs | 85µs | Class::MOP::Mixin::HasMethods::BEGIN@3 |
| 1 | 1 | 1 | 52µs | 120µs | Class::MOP::Mixin::HasMethods::BEGIN@4 |
| 1 | 1 | 1 | 47µs | 323µs | Class::MOP::Mixin::HasMethods::BEGIN@16 |
| 1 | 1 | 1 | 43µs | 174µs | Class::MOP::Mixin::HasMethods::BEGIN@13 |
| 1 | 1 | 1 | 42µs | 205µs | Class::MOP::Mixin::HasMethods::BEGIN@12 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::remove_method |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::Mixin::HasMethods; | ||||
| 2 | |||||
| 3 | 3 | 111µs | 2 | 105µs | # spent 85µs (65+20) within Class::MOP::Mixin::HasMethods::BEGIN@3 which was called:
# once (65µs+20µs) by Class::MOP::BEGIN@18 at line 3 # spent 85µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@3
# spent 20µs making 1 call to strict::import |
| 4 | 3 | 99µs | 2 | 188µs | # spent 120µs (52+68) within Class::MOP::Mixin::HasMethods::BEGIN@4 which was called:
# once (52µs+68µs) by Class::MOP::BEGIN@18 at line 4 # spent 120µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@4
# spent 68µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 3 | 529µs | 1 | 14.4ms | # spent 14.4ms (1.99+12.4) within Class::MOP::Mixin::HasMethods::BEGIN@6 which was called:
# once (1.99ms+12.4ms) by Class::MOP::BEGIN@18 at line 6 # spent 14.4ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@6 |
| 7 | |||||
| 8 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 9 | 1 | 65µs | $VERSION = eval $VERSION; # spent 12µs executing statements in string eval | ||
| 10 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 11 | |||||
| 12 | 3 | 110µs | 2 | 368µs | # spent 205µs (42+163) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called:
# once (42µs+163µs) by Class::MOP::BEGIN@18 at line 12 # spent 205µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12
# spent 163µs making 1 call to Exporter::import |
| 13 | 3 | 105µs | 2 | 305µs | # spent 174µs (43+131) within Class::MOP::Mixin::HasMethods::BEGIN@13 which was called:
# once (43µs+131µs) by Class::MOP::BEGIN@18 at line 13 # spent 174µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@13
# spent 131µs making 1 call to Exporter::import |
| 14 | 3 | 610µs | 2 | 3.50ms | # spent 3.29ms (1.08+2.21) within Class::MOP::Mixin::HasMethods::BEGIN@14 which was called:
# once (1.08ms+2.21ms) by Class::MOP::BEGIN@18 at line 14 # spent 3.29ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@14
# spent 212µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 3 | 3.20ms | 2 | 323µs | # spent 323µs (47+276) within Class::MOP::Mixin::HasMethods::BEGIN@16 which was called:
# once (47µs+276µs) by Class::MOP::BEGIN@18 at line 16 # spent 323µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@16
# spent 276µs making 1 call to base::import, recursion: max depth 1, sum of overlapping time 276µs |
| 17 | |||||
| 18 | 25 | 319µs | # spent 254µs within Class::MOP::Mixin::HasMethods::_meta_method_class which was called 25 times, avg 10µs/call:
# 23 times (233µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28, avg 10µs/call
# 2 times (21µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 26, avg 10µs/call | ||
| 19 | |||||
| 20 | # spent 451ms (18.4+433) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 174 times, avg 2.59ms/call:
# 45 times (4.58ms+115ms) by Moose::init_meta at line 214 of Moose.pm, avg 2.65ms/call
# 42 times (4.58ms+104ms) by Moose::Meta::Role::create at line 547 of Moose/Meta/Role.pm, avg 2.58ms/call
# 40 times (3.95ms+93.0ms) by Moose::Role::init_meta at line 146 of Moose/Role.pm, avg 2.42ms/call
# 25 times (2.66ms+65.0ms) by Class::MOP::Class::create at line 517 of Class/MOP/Class.pm, avg 2.70ms/call
# 20 times (2.08ms+47.6ms) by metaclass::import at line 46 of metaclass.pm, avg 2.48ms/call
# once (336µs+6.03ms) by MooseX::Types::Combine::BEGIN@12 at line 672 of Class/MOP.pm
# once (161µs+2.90ms) by MooseX::Types::Combine::BEGIN@12 at line 678 of Class/MOP.pm | ||||
| 21 | 870 | 19.1ms | my $self = shift; | ||
| 22 | my ($name) = @_; | ||||
| 23 | 348 | 47.3ms | my $existing_method = $self->can('find_method_by_name') # spent 30.0ms making 92 calls to Class::MOP::Class::find_method_by_name, avg 326µs/call
# spent 16.0ms making 82 calls to Moose::Meta::Role::find_method_by_name, avg 195µs/call
# spent 1.34ms making 174 calls to UNIVERSAL::can, avg 8µs/call | ||
| 24 | ? $self->find_method_by_name($name) | ||||
| 25 | : $self->get_method($name); | ||||
| 26 | 4 | 38µs | return if $existing_method # spent 21µs making 2 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 10µs/call
# spent 17µs making 2 calls to UNIVERSAL::isa, avg 9µs/call | ||
| 27 | && $existing_method->isa($self->_meta_method_class); | ||||
| 28 | 696 | 385ms | $self->add_method( # spent 271ms making 151 calls to Moose::Meta::Method::Meta::wrap, avg 1.80ms/call
# spent 75.8ms making 174 calls to Class::MOP::Mixin::HasMethods::add_method, avg 436µs/call
# spent 35.5ms making 23 calls to Class::MOP::Method::Meta::wrap, avg 1.54ms/call
# spent 927µs making 174 calls to Class::MOP::Package::name, avg 5µs/call
# spent 822µs making 82 calls to Moose::Meta::Role::_meta_method_class, avg 10µs/call
# spent 677µs making 69 calls to Moose::Meta::Class::_meta_method_class, avg 10µs/call
# spent 233µs making 23 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 10µs/call | ||
| 29 | $name => $self->_meta_method_class->wrap( | ||||
| 30 | name => $name, | ||||
| 31 | package_name => $self->name, | ||||
| 32 | associated_metaclass => $self, | ||||
| 33 | ) | ||||
| 34 | ); | ||||
| 35 | } | ||||
| 36 | |||||
| 37 | # spent 72.7ms (17.3+55.4) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 299 times, avg 243µs/call:
# 299 times (17.3ms+55.4ms) by Class::MOP::Mixin::HasMethods::get_method at line 119, avg 243µs/call | ||||
| 38 | 897 | 18.8ms | my ( $self, %args ) = @_; | ||
| 39 | |||||
| 40 | ( 'CODE' eq ref $args{body} ) | ||||
| 41 | || confess "Your code block must be a CODE reference"; | ||||
| 42 | |||||
| 43 | 897 | 55.4ms | $self->method_metaclass->wrap( # spent 51.3ms making 299 calls to Class::MOP::Method::wrap, avg 171µs/call
# spent 2.02ms making 156 calls to Moose::Meta::Role::method_metaclass, avg 13µs/call
# spent 1.39ms making 299 calls to Class::MOP::Package::name, avg 5µs/call
# spent 764µs making 143 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 5µs/call | ||
| 44 | package_name => $self->name, | ||||
| 45 | %args, | ||||
| 46 | ); | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | # spent 979ms (351+628) within Class::MOP::Mixin::HasMethods::add_method which was called 2175 times, avg 450µs/call:
# 672 times (103ms+199ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 163 of Moose/Meta/Role/Application/ToClass.pm, avg 450µs/call
# 434 times (68.8ms+135ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 100 of Moose/Meta/Role/Application/ToRole.pm, avg 469µs/call
# 213 times (35.0ms+56.5ms) by Class::MOP::Attribute::install_accessors at line 419 of Class/MOP/Attribute.pm, avg 430µs/call
# 212 times (35.8ms+71.1ms) by MooseX::Role::Parameterized::method at line 77 of MooseX/Role/Parameterized.pm, avg 504µs/call
# 174 times (29.7ms+46.1ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28, avg 436µs/call
# 131 times (21.2ms+33.8ms) by Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] at line 1106 of Class/MOP/Class.pm, avg 420µs/call
# 73 times (12.0ms+18.9ms) by Class::MOP::Class::_inline_constructor at line 1480 of Class/MOP/Class.pm, avg 423µs/call
# 43 times (6.95ms+11.3ms) by Class::MOP::Attribute::install_accessors at line 427 of Class/MOP/Attribute.pm, avg 424µs/call
# 42 times (7.27ms+11.8ms) by Class::MOP::Attribute::install_accessors at line 415 of Class/MOP/Attribute.pm, avg 453µs/call
# 42 times (8.36ms+10.6ms) by Class::MOP::Mixin::HasMethods::_restore_metamethods_from at line 176, avg 452µs/call
# 39 times (6.51ms+9.83ms) by Class::MOP::Class::_inline_destructor at line 1513 of Class/MOP/Class.pm, avg 419µs/call
# 36 times (5.86ms+9.24ms) by Moose::Meta::Class::add_override_method_modifier at line 503 of Moose/Meta/Class.pm, avg 420µs/call
# 15 times (3.16ms+4.18ms) by Moose::Meta::Attribute::install_delegation at line 987 of Moose/Meta/Attribute.pm, avg 489µs/call
# 14 times (2.19ms+3.47ms) by Class::MOP::Attribute::install_accessors at line 423 of Class/MOP/Attribute.pm, avg 404µs/call
# 12 times (1.87ms+3.45ms) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 443µs/call
# 7 times (904µs+1.32ms) by Moose::BEGIN@38 at line 26 of Moose/Meta/Attribute/Native.pm, avg 317µs/call
# 3 times (352µs+527µs) by Moose::BEGIN@27 at line 311 of Moose/Meta/Role.pm, avg 293µs/call
# 3 times (329µs+524µs) by Moose::BEGIN@27 at line 319 of Moose/Meta/Role.pm, avg 284µs/call
# 3 times (353µs+490µs) by Moose::BEGIN@27 at line 338 of Moose/Meta/Role.pm, avg 281µs/call
# 2 times (214µs+342µs) by Moose::BEGIN@27 at line 116 of Moose/Meta/Role.pm, avg 278µs/call
# once (147µs+177µs) by Moose::BEGIN@27 at line 96 of Moose/Meta/Role.pm
# once (121µs+199µs) by MooseX::Types::Combine::BEGIN@12 at line 517 of Class/MOP.pm
# once (114µs+180µs) by Moose::BEGIN@27 at line 106 of Moose/Meta/Role.pm
# once (108µs+177µs) by Moose::BEGIN@27 at line 121 of Moose/Meta/Role.pm
# once (107µs+159µs) by Moose::BEGIN@27 at line 101 of Moose/Meta/Role.pm | ||||
| 50 | 21750 | 368ms | my ( $self, $method_name, $method ) = @_; | ||
| 51 | ( defined $method_name && length $method_name ) | ||||
| 52 | || confess "You must define a method name"; | ||||
| 53 | |||||
| 54 | 2175 | 12.0ms | my $package_name = $self->name; # spent 12.0ms making 2175 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 55 | |||||
| 56 | my $body; | ||||
| 57 | 6479 | 113ms | 2175 | 14.6ms | if ( blessed($method) ) { # spent 14.6ms making 2175 calls to Scalar::Util::blessed, avg 7µs/call |
| 58 | 2152 | 11.7ms | $body = $method->body; # spent 11.7ms making 2152 calls to Class::MOP::Method::body, avg 5µs/call | ||
| 59 | 3482 | 117ms | if ( $method->package_name ne $package_name ) { # spent 107ms making 1330 calls to Class::MOP::Method::clone, avg 80µs/call
# spent 10.8ms making 2152 calls to Class::MOP::Method::package_name, avg 5µs/call | ||
| 60 | $method = $method->clone( | ||||
| 61 | package_name => $package_name, | ||||
| 62 | name => $method_name, | ||||
| 63 | ); | ||||
| 64 | } | ||||
| 65 | |||||
| 66 | 2152 | 69.7ms | $method->attach_to_class($self); # spent 69.7ms making 2152 calls to Class::MOP::Method::attach_to_class, avg 32µs/call | ||
| 67 | } | ||||
| 68 | else { | ||||
| 69 | # If a raw code reference is supplied, its method object is not created. | ||||
| 70 | # The method object won't be created until required. | ||||
| 71 | $body = $method; | ||||
| 72 | } | ||||
| 73 | |||||
| 74 | 2309 | 35.4ms | $self->_method_map->{$method_name} = $method; # spent 34.7ms making 2175 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 16µs/call
# spent 646µs making 134 calls to Class::MOP::Method::body, avg 5µs/call | ||
| 75 | |||||
| 76 | 2175 | 18.7ms | my ($current_package, $current_name) = Class::MOP::get_code_info($body); # spent 18.7ms making 2175 calls to Class::MOP::get_code_info, avg 9µs/call | ||
| 77 | |||||
| 78 | 3128 | 33.6ms | subname($package_name . '::' . $method_name, $body) # spent 17.3ms making 953 calls to Sub::Name::subname, avg 18µs/call
# spent 16.4ms making 2175 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 8µs/call | ||
| 79 | unless defined $current_name && $current_name !~ /^__ANON__/; | ||||
| 80 | |||||
| 81 | 2175 | 216ms | $self->add_package_symbol("&$method_name", $body); # spent 216ms making 2175 calls to Class::MOP::Package::add_package_symbol, avg 99µs/call | ||
| 82 | |||||
| 83 | # we added the method to the method map too, so it's still valid | ||||
| 84 | 2175 | 99.4ms | $self->update_package_cache_flag; # spent 99.4ms making 2175 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 46µs/call | ||
| 85 | } | ||||
| 86 | |||||
| 87 | # spent 83.9ms (62.6+21.3) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 1797 times, avg 47µs/call:
# 1797 times (62.6ms+21.3ms) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 134, avg 47µs/call | ||||
| 88 | 5391 | 87.6ms | my ( $self, $code ) = @_; | ||
| 89 | |||||
| 90 | 1797 | 12.1ms | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); # spent 12.1ms making 1797 calls to Class::MOP::get_code_info, avg 7µs/call | ||
| 91 | |||||
| 92 | 1797 | 9.12ms | return ( $code_package && $code_package eq $self->name ) # spent 9.12ms making 1797 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 93 | || ( $code_package eq 'constant' && $code_name eq '__ANON__' ); | ||||
| 94 | } | ||||
| 95 | |||||
| 96 | # spent 109ms (17.7+91.3) within Class::MOP::Mixin::HasMethods::has_method which was called 655 times, avg 166µs/call:
# 253 times (6.53ms+30.5ms) by Class::MOP::Class::find_all_methods_by_name at line 1192 of Class/MOP/Class.pm, avg 146µs/call
# 86 times (2.45ms+9.44ms) by Moose::Meta::Attribute::_process_accessors at line 936 of Moose/Meta/Attribute.pm, avg 138µs/call
# 73 times (2.10ms+16.7ms) by Class::MOP::Class::_inline_constructor at line 1457 of Class/MOP/Class.pm, avg 258µs/call
# 51 times (1.23ms+6.06ms) by Moose::Meta::Role::add_override_method_modifier at line 358 of Moose/Meta/Role.pm, avg 143µs/call
# 48 times (1.29ms+5.63ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 138 of Moose/Meta/Role/Application/ToRole.pm, avg 144µs/call
# 43 times (1.20ms+5.32ms) by Class::MOP::Class::_inline_destructor at line 1492 of Class/MOP/Class.pm, avg 152µs/call
# 36 times (1.08ms+9.23ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 197 of Moose/Meta/Role/Application/ToClass.pm, avg 286µs/call
# 36 times (874µs+4.14ms) by Moose::Meta::Class::add_override_method_modifier at line 500 of Moose/Meta/Class.pm, avg 139µs/call
# 15 times (521µs+2.11ms) by Moose::Meta::Attribute::install_delegation at line 972 of Moose/Meta/Attribute.pm, avg 175µs/call
# 14 times (366µs+2.17ms) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 103 of Moose/Meta/Role/Application/RoleSummation.pm, avg 181µs/call | ||||
| 97 | 1967 | 17.7ms | my ( $self, $method_name ) = @_; | ||
| 98 | |||||
| 99 | ( defined $method_name && length $method_name ) | ||||
| 100 | || confess "You must define a method name"; | ||||
| 101 | |||||
| 102 | 655 | 91.3ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 91.3ms making 655 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 139µs/call | ||
| 103 | or return; | ||||
| 104 | |||||
| 105 | 2 | 18µs | return defined($self->_method_map->{$method_name} = $method); # spent 18µs making 2 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 9µs/call | ||
| 106 | } | ||||
| 107 | |||||
| 108 | # spent 929ms (164+765) within Class::MOP::Mixin::HasMethods::get_method which was called 5411 times, avg 172µs/call:
# 2515 times (78.6ms+378ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 200, avg 182µs/call
# 752 times (22.2ms+103ms) by Class::MOP::Class::find_method_by_name at line 1159 of Class/MOP/Class.pm, avg 167µs/call
# 672 times (17.7ms+81.6ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 159 of Moose/Meta/Role/Application/ToClass.pm, avg 148µs/call
# 547 times (18.3ms+72.9ms) by Class::MOP::Class::find_next_method_by_name at line 1208 of Class/MOP/Class.pm, avg 167µs/call
# 434 times (12.1ms+55.7ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 88 of Moose/Meta/Role/Application/ToRole.pm, avg 156µs/call
# 131 times (3.53ms+16.0ms) by Class::MOP::Class::__ANON__[/home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Class.pm:1108] at line 1083 of Class/MOP/Class.pm, avg 149µs/call
# 112 times (3.64ms+24.1ms) by Moose::Meta::Role::find_method_by_name at line 427 of Moose/Meta/Role.pm, avg 248µs/call
# 86 times (2.49ms+15.4ms) by Moose::Meta::Attribute::_process_accessors at line 910 of Moose/Meta/Attribute.pm, avg 208µs/call
# 76 times (2.74ms+3.17ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 160 of Moose/Meta/Role/Application/RoleSummation.pm, avg 78µs/call
# 45 times (1.36ms+6.35ms) by Moose::init_meta at line 204 of Moose.pm, avg 171µs/call
# 40 times (1.23ms+7.90ms) by Moose::Role::init_meta at line 136 of Moose/Role.pm, avg 228µs/call
# once (39µs+40µs) by Class::MOP::Class::find_all_methods_by_name at line 1192 of Class/MOP/Class.pm | ||||
| 109 | 18186 | 175ms | my ( $self, $method_name ) = @_; | ||
| 110 | |||||
| 111 | ( defined $method_name && length $method_name ) | ||||
| 112 | || confess "You must define a method name"; | ||||
| 113 | |||||
| 114 | 5411 | 676ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 676ms making 5411 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 125µs/call | ||
| 115 | or return; | ||||
| 116 | |||||
| 117 | 1654 | 11.3ms | return $method if blessed $method; # spent 11.3ms making 1654 calls to Scalar::Util::blessed, avg 7µs/call | ||
| 118 | |||||
| 119 | 598 | 77.3ms | return $self->_method_map->{$method_name} = $self->wrap_method_body( # spent 72.7ms making 299 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 243µs/call
# spent 3.33ms making 274 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 12µs/call
# spent 1.23ms making 25 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 49µs/call | ||
| 120 | body => $method, | ||||
| 121 | name => $method_name, | ||||
| 122 | associated_metaclass => $self, | ||||
| 123 | ); | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | # spent 767ms (249+518) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 6066 times, avg 127µs/call:
# 5411 times (221ms+455ms) by Class::MOP::Mixin::HasMethods::get_method at line 114, avg 125µs/call
# 655 times (28.1ms+63.2ms) by Class::MOP::Mixin::HasMethods::has_method at line 102, avg 139µs/call | ||||
| 127 | 27915 | 355ms | my ( $self, $method_name ) = @_; | ||
| 128 | |||||
| 129 | 7869 | 138ms | my $map_entry = $self->_method_map->{$method_name}; # spent 99.3ms making 5500 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 18µs/call
# spent 30.5ms making 566 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 54µs/call
# spent 8.32ms making 1803 calls to Class::MOP::Method::body, avg 5µs/call | ||
| 130 | return $map_entry if defined $map_entry; | ||||
| 131 | |||||
| 132 | 4709 | 304ms | my $code = $self->get_package_symbol("&$method_name"); # spent 304ms making 4709 calls to Class::MOP::Package::get_package_symbol, avg 65µs/call | ||
| 133 | |||||
| 134 | 1797 | 83.9ms | return unless $code && $self->_code_is_mine($code); # spent 83.9ms making 1797 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 47µs/call | ||
| 135 | |||||
| 136 | return $code; | ||||
| 137 | } | ||||
| 138 | |||||
| 139 | sub remove_method { | ||||
| 140 | my ( $self, $method_name ) = @_; | ||||
| 141 | |||||
| 142 | ( defined $method_name && length $method_name ) | ||||
| 143 | || confess "You must define a method name"; | ||||
| 144 | |||||
| 145 | my $removed_method = delete $self->_method_map->{$method_name}; | ||||
| 146 | |||||
| 147 | $self->remove_package_symbol("&$method_name"); | ||||
| 148 | |||||
| 149 | $removed_method->detach_from_class | ||||
| 150 | if blessed($removed_method); | ||||
| 151 | |||||
| 152 | # still valid, since we just removed the method from the map | ||||
| 153 | $self->update_package_cache_flag; | ||||
| 154 | |||||
| 155 | return $removed_method; | ||||
| 156 | } | ||||
| 157 | |||||
| 158 | # spent 230ms (1.44+229) within Class::MOP::Mixin::HasMethods::get_method_list which was called 49 times, avg 4.69ms/call:
# 49 times (1.44ms+229ms) by namespace::autoclean::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/namespace/autoclean.pm:57] at line 45 of namespace/autoclean.pm, avg 4.69ms/call | ||||
| 159 | 98 | 3.25ms | my $self = shift; | ||
| 160 | |||||
| 161 | 49 | 229ms | return keys %{ $self->_full_method_map }; # spent 229ms making 49 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 4.66ms/call | ||
| 162 | } | ||||
| 163 | |||||
| 164 | # spent 309ms (5.29+304) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 199 times, avg 1.55ms/call:
# 73 times (1.94ms+101ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 1.41ms/call
# 65 times (1.80ms+28.1ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 80 of Moose/Meta/Role/Application/ToRole.pm, avg 459µs/call
# 42 times (1.02ms+142ms) by Class::MOP::Mixin::HasMethods::_restore_metamethods_from at line 174, avg 3.40ms/call
# 11 times (308µs+13.9ms) by Class::MOP::Class::get_all_methods at line 1172 of Class/MOP/Class.pm, avg 1.29ms/call
# 8 times (220µs+18.5ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 171 of Moose/Meta/Role/Application/RoleSummation.pm, avg 2.34ms/call | ||||
| 165 | 398 | 5.47ms | my $self = shift; | ||
| 166 | |||||
| 167 | 199 | 304ms | return values %{ $self->_full_method_map }; # spent 304ms making 199 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 1.53ms/call | ||
| 168 | } | ||||
| 169 | |||||
| 170 | # spent 172ms (3.80+168) within Class::MOP::Mixin::HasMethods::_restore_metamethods_from which was called 42 times, avg 4.10ms/call:
# 42 times (3.80ms+168ms) by Class::MOP::Class::_restore_metaobjects_from at line 403 of Class/MOP/Class.pm, avg 4.10ms/call | ||||
| 171 | 126 | 1.28ms | my $self = shift; | ||
| 172 | my ($old_meta) = @_; | ||||
| 173 | |||||
| 174 | 42 | 143ms | for my $method ($old_meta->_get_local_methods) { # spent 143ms making 42 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 3.40ms/call | ||
| 175 | 84 | 2.75ms | 84 | 6.16ms | $method->_make_compatible_with($self->method_metaclass); # spent 5.89ms making 42 calls to Moose::Meta::Method::Meta::_make_compatible_with, avg 140µs/call
# spent 274µs making 42 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 7µs/call |
| 176 | 84 | 19.2ms | $self->add_method($method->name => $method); # spent 19.0ms making 42 calls to Class::MOP::Mixin::HasMethods::add_method, avg 452µs/call
# spent 239µs making 42 calls to Class::MOP::Method::name, avg 6µs/call | ||
| 177 | } | ||||
| 178 | } | ||||
| 179 | |||||
| 180 | 141 | 1.91ms | # spent 1.54ms within Class::MOP::Mixin::HasMethods::reset_package_cache_flag which was called 141 times, avg 11µs/call:
# 73 times (778µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 190 of Moose/Meta/Role/Application/ToClass.pm, avg 11µs/call
# 68 times (761µs+0s) by Moose::Meta::Role::add_role at line 400 of Moose/Meta/Role.pm, avg 11µs/call | ||
| 181 | # spent 99.4ms (67.6+31.8) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 2175 times, avg 46µs/call:
# 2175 times (67.6ms+31.8ms) by Class::MOP::Mixin::HasMethods::add_method at line 84, avg 46µs/call | ||||
| 182 | 4350 | 103ms | my $self = shift; | ||
| 183 | # NOTE: | ||||
| 184 | # we can manually update the cache number | ||||
| 185 | # since we are actually adding the method | ||||
| 186 | # to our cache as well. This avoids us | ||||
| 187 | # having to regenerate the method_map. | ||||
| 188 | # - SL | ||||
| 189 | 4350 | 31.8ms | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); # spent 21.0ms making 2175 calls to mro::get_pkg_gen, avg 10µs/call
# spent 10.8ms making 2175 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 190 | } | ||||
| 191 | |||||
| 192 | # spent 532ms (51.2+481) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 248 times, avg 2.15ms/call:
# 199 times (34.6ms+269ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 167, avg 1.53ms/call
# 49 times (16.6ms+212ms) by Class::MOP::Mixin::HasMethods::get_method_list at line 161, avg 4.66ms/call | ||||
| 193 | 992 | 20.7ms | my $self = shift; | ||
| 194 | |||||
| 195 | 496 | 4.77ms | my $pkg_gen = Class::MOP::check_package_cache_flag($self->name); # spent 3.31ms making 248 calls to mro::get_pkg_gen, avg 13µs/call
# spent 1.46ms making 248 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 196 | |||||
| 197 | 528 | 33.0ms | if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) { | ||
| 198 | # forcibly reify all method map entries | ||||
| 199 | $self->get_method($_) | ||||
| 200 | 2691 | 473ms | for $self->list_all_package_symbols('CODE'); # spent 457ms making 2515 calls to Class::MOP::Mixin::HasMethods::get_method, avg 182µs/call
# spent 16.4ms making 176 calls to Class::MOP::Package::list_all_package_symbols, avg 93µs/call | ||
| 201 | $self->{_package_cache_flag_full} = $pkg_gen; | ||||
| 202 | } | ||||
| 203 | |||||
| 204 | 248 | 2.74ms | return $self->_method_map; # spent 2.74ms making 248 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 11µs/call | ||
| 205 | } | ||||
| 206 | |||||
| 207 | 1 | 13µs | 1; | ||
| 208 | |||||
| 209 | __END__ | ||||
# spent 16.4ms within Class::MOP::Mixin::HasMethods::CORE:match which was called 2175 times, avg 8µs/call:
# 2175 times (16.4ms+0s) by Class::MOP::Mixin::HasMethods::add_method at line 78, avg 8µs/call |