| Filename | /home/doy/coding/src/Class-MOP/blib/lib//Class/MOP/Mixin/HasMethods.pm |
| Statements | Executed 36552 statements in 556ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1051 | 24 | 11 | 171ms | 460ms | Class::MOP::Mixin::HasMethods::add_method |
| 2295 | 2 | 1 | 91.1ms | 276ms | Class::MOP::Mixin::HasMethods::_get_maybe_raw_method |
| 1777 | 13 | 9 | 60.1ms | 331ms | Class::MOP::Mixin::HasMethods::get_method |
| 1051 | 1 | 1 | 32.7ms | 47.6ms | Class::MOP::Mixin::HasMethods::update_package_cache_flag |
| 518 | 10 | 7 | 14.2ms | 78.9ms | Class::MOP::Mixin::HasMethods::has_method |
| 198 | 1 | 1 | 11.9ms | 51.4ms | Class::MOP::Mixin::HasMethods::wrap_method_body |
| 268 | 1 | 1 | 9.73ms | 13.1ms | Class::MOP::Mixin::HasMethods::_code_is_mine |
| 1051 | 1 | 1 | 9.55ms | 9.55ms | Class::MOP::Mixin::HasMethods::CORE:match (opcode) |
| 92 | 6 | 5 | 9.38ms | 237ms | Class::MOP::Mixin::HasMethods::_add_meta_method |
| 54 | 1 | 1 | 8.62ms | 86.8ms | Class::MOP::Mixin::HasMethods::_full_method_map |
| 1 | 1 | 1 | 1.97ms | 14.2ms | Class::MOP::Mixin::HasMethods::BEGIN@6 |
| 54 | 4 | 4 | 1.62ms | 88.4ms | Class::MOP::Mixin::HasMethods::_get_local_methods |
| 1 | 1 | 1 | 1.06ms | 3.22ms | Class::MOP::Mixin::HasMethods::BEGIN@14 |
| 39 | 2 | 2 | 423µs | 423µs | Class::MOP::Mixin::HasMethods::reset_package_cache_flag |
| 25 | 2 | 1 | 244µs | 244µs | Class::MOP::Mixin::HasMethods::_meta_method_class |
| 1 | 1 | 1 | 65µs | 83µs | Class::MOP::Mixin::HasMethods::BEGIN@3 |
| 1 | 1 | 1 | 44µs | 210µs | Class::MOP::Mixin::HasMethods::BEGIN@12 |
| 1 | 1 | 1 | 42µs | 283µs | Class::MOP::Mixin::HasMethods::BEGIN@16 |
| 1 | 1 | 1 | 38µs | 165µs | Class::MOP::Mixin::HasMethods::BEGIN@13 |
| 1 | 1 | 1 | 38µs | 105µs | Class::MOP::Mixin::HasMethods::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::_restore_metamethods_from |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::get_method_list |
| 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 | 95µs | 2 | 102µs | # spent 83µs (65+19) within Class::MOP::Mixin::HasMethods::BEGIN@3 which was called:
# once (65µs+19µs) by Class::MOP::BEGIN@18 at line 3 # spent 83µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@3
# spent 19µs making 1 call to strict::import |
| 4 | 3 | 94µs | 2 | 173µs | # spent 105µs (38+68) within Class::MOP::Mixin::HasMethods::BEGIN@4 which was called:
# once (38µs+68µs) by Class::MOP::BEGIN@18 at line 4 # spent 105µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@4
# spent 68µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 3 | 563µs | 1 | 14.2ms | # spent 14.2ms (1.97+12.2) within Class::MOP::Mixin::HasMethods::BEGIN@6 which was called:
# once (1.97ms+12.2ms) by Class::MOP::BEGIN@18 at line 6 # spent 14.2ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@6 |
| 7 | |||||
| 8 | 1 | 5µs | our $VERSION = '1.11'; | ||
| 9 | 1 | 67µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 10 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 11 | |||||
| 12 | 3 | 110µs | 2 | 376µs | # spent 210µs (44+166) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called:
# once (44µs+166µs) by Class::MOP::BEGIN@18 at line 12 # spent 210µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12
# spent 166µs making 1 call to Exporter::import |
| 13 | 3 | 99µs | 2 | 292µs | # spent 165µs (38+127) within Class::MOP::Mixin::HasMethods::BEGIN@13 which was called:
# once (38µs+127µs) by Class::MOP::BEGIN@18 at line 13 # spent 165µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@13
# spent 127µs making 1 call to Exporter::import |
| 14 | 3 | 640µs | 2 | 3.43ms | # spent 3.22ms (1.06+2.16) within Class::MOP::Mixin::HasMethods::BEGIN@14 which was called:
# once (1.06ms+2.16ms) by Class::MOP::BEGIN@18 at line 14 # spent 3.22ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@14
# spent 209µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 3 | 3.08ms | 2 | 524µs | # spent 283µs (42+241) within Class::MOP::Mixin::HasMethods::BEGIN@16 which was called:
# once (42µs+241µs) by Class::MOP::BEGIN@18 at line 16 # spent 283µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@16
# spent 241µs making 1 call to base::import |
| 17 | |||||
| 18 | 25 | 312µs | # spent 244µs within Class::MOP::Mixin::HasMethods::_meta_method_class which was called 25 times, avg 10µs/call:
# 23 times (223µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28, avg 10µs/call
# 2 times (20µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 26, avg 10µs/call | ||
| 19 | |||||
| 20 | # spent 237ms (9.38+227) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 92 times, avg 2.57ms/call:
# 35 times (3.36ms+82.0ms) by Moose::Role::init_meta at line 146 of Moose/Role.pm, avg 2.44ms/call
# 25 times (2.48ms+63.0ms) by Moose::init_meta at line 214 of Moose.pm, avg 2.62ms/call
# 20 times (1.96ms+47.4ms) by metaclass::import at line 46 of metaclass.pm, avg 2.47ms/call
# 10 times (1.08ms+25.8ms) by Class::MOP::Class::create at line 517 of Class/MOP/Class.pm, avg 2.69ms/call
# once (339µs+6.13ms) by Moose::Exporter::BEGIN@11 at line 672 of Class/MOP.pm
# once (165µs+2.99ms) by Moose::Exporter::BEGIN@11 at line 678 of Class/MOP.pm | ||||
| 21 | 460 | 9.97ms | my $self = shift; | ||
| 22 | my ($name) = @_; | ||||
| 23 | 184 | 24.9ms | my $existing_method = $self->can('find_method_by_name') # spent 19.0ms making 57 calls to Class::MOP::Class::find_method_by_name, avg 334µs/call
# spent 5.16ms making 35 calls to Moose::Meta::Role::find_method_by_name, avg 147µs/call
# spent 699µs making 92 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 20µs making 2 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 10µs/call
# spent 18µs making 2 calls to UNIVERSAL::isa, avg 9µs/call | ||
| 27 | && $existing_method->isa($self->_meta_method_class); | ||||
| 28 | 368 | 202ms | $self->add_method( # spent 126ms making 69 calls to Moose::Meta::Method::Meta::wrap, avg 1.83ms/call
# spent 39.5ms making 92 calls to Class::MOP::Mixin::HasMethods::add_method, avg 429µs/call
# spent 35.2ms making 23 calls to Class::MOP::Method::Meta::wrap, avg 1.53ms/call
# spent 470µs making 92 calls to Class::MOP::Package::name, avg 5µs/call
# spent 428µs making 35 calls to Moose::Meta::Role::_meta_method_class, avg 12µs/call
# spent 333µs making 34 calls to Moose::Meta::Class::_meta_method_class, avg 10µs/call
# spent 223µ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 51.4ms (11.9+39.5) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 198 times, avg 260µs/call:
# 198 times (11.9ms+39.5ms) by Class::MOP::Mixin::HasMethods::get_method at line 119, avg 260µs/call | ||||
| 38 | 594 | 13.0ms | my ( $self, %args ) = @_; | ||
| 39 | |||||
| 40 | ( 'CODE' eq ref $args{body} ) | ||||
| 41 | || confess "Your code block must be a CODE reference"; | ||||
| 42 | |||||
| 43 | 594 | 39.5ms | $self->method_metaclass->wrap( # spent 36.8ms making 198 calls to Class::MOP::Method::wrap, avg 186µs/call
# spent 1.10ms making 86 calls to Moose::Meta::Role::method_metaclass, avg 13µs/call
# spent 944µs making 198 calls to Class::MOP::Package::name, avg 5µs/call
# spent 633µs making 112 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 6µs/call | ||
| 44 | package_name => $self->name, | ||||
| 45 | %args, | ||||
| 46 | ); | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | # spent 460ms (171+289) within Class::MOP::Mixin::HasMethods::add_method which was called 1051 times, avg 438µs/call:
# 247 times (41.0ms+68.1ms) by Class::MOP::Attribute::install_accessors at line 419 of Class/MOP/Attribute.pm, avg 441µs/call
# 164 times (27.2ms+47.9ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 100 of Moose/Meta/Role/Application/ToRole.pm, avg 458µs/call
# 154 times (24.0ms+46.5ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 163 of Moose/Meta/Role/Application/ToClass.pm, avg 458µs/call
# 92 times (15.4ms+24.1ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 28, avg 429µs/call
# 68 times (10.6ms+17.2ms) 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 410µs/call
# 66 times (10.9ms+17.7ms) by Class::MOP::Attribute::install_accessors at line 427 of Class/MOP/Attribute.pm, avg 434µs/call
# 57 times (9.81ms+16.3ms) by Class::MOP::Attribute::install_accessors at line 415 of Class/MOP/Attribute.pm, avg 458µs/call
# 55 times (9.12ms+14.5ms) by Class::MOP::Class::_inline_constructor at line 1480 of Class/MOP/Class.pm, avg 430µs/call
# 29 times (5.06ms+7.91ms) by Class::MOP::Attribute::install_accessors at line 431 of Class/MOP/Attribute.pm, avg 447µs/call
# 28 times (4.63ms+6.81ms) by Moose::Meta::Attribute::install_delegation at line 987 of Moose/Meta/Attribute.pm, avg 409µs/call
# 24 times (3.89ms+5.93ms) by Class::MOP::Class::_inline_destructor at line 1513 of Class/MOP/Class.pm, avg 409µs/call
# 19 times (3.10ms+5.15ms) by Class::MOP::Attribute::install_accessors at line 423 of Class/MOP/Attribute.pm, avg 434µs/call
# 15 times (2.44ms+3.87ms) by Moose::Meta::Class::add_override_method_modifier at line 503 of Moose/Meta/Class.pm, avg 421µs/call
# 10 times (1.59ms+3.05ms) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 464µs/call
# 7 times (805µs+1.34ms) by Moose::BEGIN@38 at line 26 of Moose/Meta/Attribute/Native.pm, avg 307µs/call
# 3 times (369µs+556µs) by Moose::BEGIN@27 at line 319 of Moose/Meta/Role.pm, avg 308µs/call
# 3 times (341µs+540µs) by Moose::BEGIN@27 at line 311 of Moose/Meta/Role.pm, avg 294µs/call
# 3 times (329µs+483µs) by Moose::BEGIN@27 at line 338 of Moose/Meta/Role.pm, avg 270µs/call
# 2 times (211µs+322µs) by Moose::BEGIN@27 at line 116 of Moose/Meta/Role.pm, avg 266µs/call
# once (126µs+208µs) by Moose::Exporter::BEGIN@11 at line 517 of Class/MOP.pm
# once (113µs+186µs) by Moose::BEGIN@27 at line 106 of Moose/Meta/Role.pm
# once (111µs+168µs) by Moose::BEGIN@27 at line 96 of Moose/Meta/Role.pm
# once (107µs+158µs) by Moose::BEGIN@27 at line 101 of Moose/Meta/Role.pm
# once (105µs+156µs) by Moose::BEGIN@27 at line 121 of Moose/Meta/Role.pm | ||||
| 50 | 13617 | 242ms | my ( $self, $method_name, $method ) = @_; | ||
| 51 | ( defined $method_name && length $method_name ) | ||||
| 52 | || confess "You must define a method name"; | ||||
| 53 | |||||
| 54 | 1051 | 6.48ms | my $package_name = $self->name; # spent 6.48ms making 1051 calls to Class::MOP::Package::name, avg 6µs/call | ||
| 55 | |||||
| 56 | my $body; | ||||
| 57 | 1051 | 7.35ms | if ( blessed($method) ) { # spent 7.35ms making 1051 calls to Scalar::Util::blessed, avg 7µs/call | ||
| 58 | 1028 | 6.35ms | $body = $method->body; # spent 6.35ms making 1028 calls to Class::MOP::Method::body, avg 6µs/call | ||
| 59 | 1356 | 31.8ms | if ( $method->package_name ne $package_name ) { # spent 26.5ms making 328 calls to Class::MOP::Method::clone, avg 81µs/call
# spent 5.22ms making 1028 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 | 1028 | 34.1ms | $method->attach_to_class($self); # spent 34.1ms making 1028 calls to Class::MOP::Method::attach_to_class, avg 33µ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 | 1074 | 16.8ms | $self->_method_map->{$method_name} = $method; # spent 16.6ms making 1051 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 16µs/call
# spent 112µs making 23 calls to Class::MOP::Method::body, avg 5µs/call | ||
| 75 | |||||
| 76 | 1051 | 9.34ms | my ($current_package, $current_name) = Class::MOP::get_code_info($body); # spent 9.34ms making 1051 calls to Class::MOP::get_code_info, avg 9µs/call | ||
| 77 | |||||
| 78 | 1715 | 20.7ms | subname($package_name . '::' . $method_name, $body) # spent 11.2ms making 664 calls to Sub::Name::subname, avg 17µs/call
# spent 9.55ms making 1051 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 9µs/call | ||
| 79 | unless defined $current_name && $current_name !~ /^__ANON__/; | ||||
| 80 | |||||
| 81 | 1051 | 109ms | $self->add_package_symbol("&$method_name", $body); # spent 109ms making 1051 calls to Class::MOP::Package::add_package_symbol, avg 103µs/call | ||
| 82 | |||||
| 83 | # we added the method to the method map too, so it's still valid | ||||
| 84 | 1051 | 47.6ms | $self->update_package_cache_flag; # spent 47.6ms making 1051 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 45µs/call | ||
| 85 | } | ||||
| 86 | |||||
| 87 | # spent 13.1ms (9.73+3.39) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 268 times, avg 49µs/call:
# 268 times (9.73ms+3.39ms) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 134, avg 49µs/call | ||||
| 88 | 804 | 13.8ms | my ( $self, $code ) = @_; | ||
| 89 | |||||
| 90 | 268 | 1.96ms | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); # spent 1.96ms making 268 calls to Class::MOP::get_code_info, avg 7µs/call | ||
| 91 | |||||
| 92 | 268 | 1.43ms | return ( $code_package && $code_package eq $self->name ) # spent 1.43ms making 268 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 93 | || ( $code_package eq 'constant' && $code_name eq '__ANON__' ); | ||||
| 94 | } | ||||
| 95 | |||||
| 96 | # spent 78.9ms (14.2+64.7) within Class::MOP::Mixin::HasMethods::has_method which was called 518 times, avg 152µs/call:
# 193 times (5.31ms+20.9ms) by Moose::Meta::Attribute::_process_accessors at line 936 of Moose/Meta/Attribute.pm, avg 136µs/call
# 98 times (2.64ms+12.0ms) by Class::MOP::Class::find_all_methods_by_name at line 1192 of Class/MOP/Class.pm, avg 149µs/call
# 55 times (1.56ms+8.79ms) by Class::MOP::Class::_inline_constructor at line 1457 of Class/MOP/Class.pm, avg 188µs/call
# 39 times (1.13ms+5.68ms) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 103 of Moose/Meta/Role/Application/RoleSummation.pm, avg 175µs/call
# 28 times (791µs+3.26ms) by Moose::Meta::Attribute::install_delegation at line 972 of Moose/Meta/Attribute.pm, avg 145µs/call
# 27 times (642µs+3.11ms) by Moose::Meta::Role::add_override_method_modifier at line 358 of Moose/Meta/Role.pm, avg 139µs/call
# 24 times (683µs+2.95ms) by Class::MOP::Class::_inline_destructor at line 1492 of Class/MOP/Class.pm, avg 151µs/call
# 24 times (637µs+2.74ms) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 138 of Moose/Meta/Role/Application/ToRole.pm, avg 141µs/call
# 15 times (434µs+3.69ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 197 of Moose/Meta/Role/Application/ToClass.pm, avg 275µs/call
# 15 times (361µs+1.64ms) by Moose::Meta::Class::add_override_method_modifier at line 500 of Moose/Meta/Class.pm, avg 134µs/call | ||||
| 97 | 1564 | 14.0ms | my ( $self, $method_name ) = @_; | ||
| 98 | |||||
| 99 | ( defined $method_name && length $method_name ) | ||||
| 100 | || confess "You must define a method name"; | ||||
| 101 | |||||
| 102 | 518 | 64.6ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 64.6ms making 518 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 125µs/call | ||
| 103 | or return; | ||||
| 104 | |||||
| 105 | 10 | 99µs | return defined($self->_method_map->{$method_name} = $method); # spent 99µs making 10 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 10µs/call | ||
| 106 | } | ||||
| 107 | |||||
| 108 | # spent 331ms (60.1+271) within Class::MOP::Mixin::HasMethods::get_method which was called 1777 times, avg 186µs/call:
# 436 times (14.4ms+74.0ms) by Class::MOP::Class::find_method_by_name at line 1159 of Class/MOP/Class.pm, avg 203µs/call
# 338 times (14.6ms+59.0ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 200, avg 218µs/call
# 249 times (9.02ms+34.1ms) by Class::MOP::Class::find_next_method_by_name at line 1208 of Class/MOP/Class.pm, avg 173µs/call
# 193 times (5.50ms+27.7ms) by Moose::Meta::Attribute::_process_accessors at line 910 of Moose/Meta/Attribute.pm, avg 172µs/call
# 164 times (4.37ms+19.4ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 88 of Moose/Meta/Role/Application/ToRole.pm, avg 145µs/call
# 157 times (4.39ms+21.5ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 159 of Moose/Meta/Role/Application/ToClass.pm, avg 165µs/call
# 68 times (1.87ms+8.37ms) 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 151µs/call
# 57 times (1.89ms+12.9ms) by Moose::Meta::Role::find_method_by_name at line 427 of Moose/Meta/Role.pm, avg 259µs/call
# 50 times (1.77ms+2.00ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 160 of Moose/Meta/Role/Application/RoleSummation.pm, avg 76µs/call
# 35 times (1.18ms+6.84ms) by Moose::Role::init_meta at line 136 of Moose/Role.pm, avg 229µs/call
# 25 times (755µs+3.40ms) by Moose::init_meta at line 204 of Moose.pm, avg 166µs/call
# 4 times (267µs+1.47ms) by Class::MOP::Class::find_all_methods_by_name at line 1192 of Class/MOP/Class.pm, avg 435µs/call
# once (37µs+41µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 168 of Moose/Meta/Role/Application/RoleSummation.pm | ||||
| 109 | 6214 | 65.8ms | my ( $self, $method_name ) = @_; | ||
| 110 | |||||
| 111 | ( defined $method_name && length $method_name ) | ||||
| 112 | || confess "You must define a method name"; | ||||
| 113 | |||||
| 114 | 1777 | 211ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 211ms making 1777 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 119µs/call | ||
| 115 | or return; | ||||
| 116 | |||||
| 117 | 685 | 4.52ms | return $method if blessed $method; # spent 4.52ms making 685 calls to Scalar::Util::blessed, avg 7µs/call | ||
| 118 | |||||
| 119 | 396 | 54.7ms | return $self->_method_map->{$method_name} = $self->wrap_method_body( # spent 51.4ms making 198 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 260µs/call
# spent 2.08ms making 175 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 12µs/call
# spent 1.21ms making 23 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 53µs/call | ||
| 120 | body => $method, | ||||
| 121 | name => $method_name, | ||||
| 122 | associated_metaclass => $self, | ||||
| 123 | ); | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | # spent 276ms (91.1+185) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 2295 times, avg 120µs/call:
# 1777 times (69.8ms+142ms) by Class::MOP::Mixin::HasMethods::get_method at line 114, avg 119µs/call
# 518 times (21.3ms+43.3ms) by Class::MOP::Mixin::HasMethods::has_method at line 102, avg 125µs/call | ||||
| 127 | 10679 | 132ms | my ( $self, $method_name ) = @_; | ||
| 128 | |||||
| 129 | 2837 | 55.0ms | my $map_entry = $self->_method_map->{$method_name}; # spent 36.8ms making 2021 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 18µs/call
# spent 15.0ms making 268 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 56µs/call
# spent 2.70ms making 542 calls to Class::MOP::Method::body, avg 5µs/call
# spent 570µs making 6 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::_method_map, avg 95µs/call | ||
| 130 | return $map_entry if defined $map_entry; | ||||
| 131 | |||||
| 132 | 1798 | 120ms | my $code = $self->get_package_symbol("&$method_name"); # spent 120ms making 1798 calls to Class::MOP::Package::get_package_symbol, avg 66µs/call | ||
| 133 | |||||
| 134 | 268 | 13.1ms | return unless $code && $self->_code_is_mine($code); # spent 13.1ms making 268 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 49µ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 | sub get_method_list { | ||||
| 159 | my $self = shift; | ||||
| 160 | |||||
| 161 | return keys %{ $self->_full_method_map }; | ||||
| 162 | } | ||||
| 163 | |||||
| 164 | # spent 88.4ms (1.62+86.8) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 54 times, avg 1.64ms/call:
# 20 times (566µs+29.0ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 152 of Moose/Meta/Role/Application/ToClass.pm, avg 1.48ms/call
# 16 times (499µs+23.0ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 80 of Moose/Meta/Role/Application/ToRole.pm, avg 1.47ms/call
# 9 times (306µs+21.1ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 171 of Moose/Meta/Role/Application/RoleSummation.pm, avg 2.38ms/call
# 9 times (252µs+13.7ms) by Class::MOP::Class::get_all_methods at line 1172 of Class/MOP/Class.pm, avg 1.55ms/call | ||||
| 165 | 108 | 1.56ms | my $self = shift; | ||
| 166 | |||||
| 167 | 54 | 86.8ms | return values %{ $self->_full_method_map }; # spent 86.8ms making 54 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 1.61ms/call | ||
| 168 | } | ||||
| 169 | |||||
| 170 | sub _restore_metamethods_from { | ||||
| 171 | my $self = shift; | ||||
| 172 | my ($old_meta) = @_; | ||||
| 173 | |||||
| 174 | for my $method ($old_meta->_get_local_methods) { | ||||
| 175 | $method->_make_compatible_with($self->method_metaclass); | ||||
| 176 | $self->add_method($method->name => $method); | ||||
| 177 | } | ||||
| 178 | } | ||||
| 179 | |||||
| 180 | 39 | 541µs | # spent 423µs within Class::MOP::Mixin::HasMethods::reset_package_cache_flag which was called 39 times, avg 11µs/call:
# 21 times (228µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 190 of Moose/Meta/Role/Application/ToClass.pm, avg 11µs/call
# 18 times (195µs+0s) by Moose::Meta::Role::add_role at line 400 of Moose/Meta/Role.pm, avg 11µs/call | ||
| 181 | # spent 47.6ms (32.7+14.9) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 1051 times, avg 45µs/call:
# 1051 times (32.7ms+14.9ms) by Class::MOP::Mixin::HasMethods::add_method at line 84, avg 45µs/call | ||||
| 182 | 2102 | 48.5ms | 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 | 2102 | 14.9ms | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); # spent 9.60ms making 1051 calls to mro::get_pkg_gen, avg 9µs/call
# spent 5.34ms making 1051 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 190 | } | ||||
| 191 | |||||
| 192 | # spent 86.8ms (8.62+78.2) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 54 times, avg 1.61ms/call:
# 54 times (8.62ms+78.2ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 167, avg 1.61ms/call | ||||
| 193 | 321 | 9.38ms | my $self = shift; | ||
| 194 | |||||
| 195 | 108 | 944µs | my $pkg_gen = Class::MOP::check_package_cache_flag($self->name); # spent 664µs making 54 calls to mro::get_pkg_gen, avg 12µs/call
# spent 281µs making 54 calls to Class::MOP::Package::name, avg 5µs/call | ||
| 196 | |||||
| 197 | if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) { | ||||
| 198 | # forcibly reify all method map entries | ||||
| 199 | $self->get_method($_) | ||||
| 200 | 373 | 76.7ms | for $self->list_all_package_symbols('CODE'); # spent 73.6ms making 338 calls to Class::MOP::Mixin::HasMethods::get_method, avg 218µs/call
# spent 3.05ms making 35 calls to Class::MOP::Package::list_all_package_symbols, avg 87µs/call | ||
| 201 | $self->{_package_cache_flag_full} = $pkg_gen; | ||||
| 202 | } | ||||
| 203 | |||||
| 204 | 54 | 582µs | return $self->_method_map; # spent 582µs making 54 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 11µs/call | ||
| 205 | } | ||||
| 206 | |||||
| 207 | 1 | 12µs | 1; | ||
| 208 | |||||
| 209 | __END__ | ||||
# spent 9.55ms within Class::MOP::Mixin::HasMethods::CORE:match which was called 1051 times, avg 9µs/call:
# 1051 times (9.55ms+0s) by Class::MOP::Mixin::HasMethods::add_method at line 78, avg 9µs/call |