| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Mixin/HasMethods.pm |
| Statements | Executed 31703 statements in 66.2ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 913 | 24 | 12 | 23.9ms | 71.3ms | Class::MOP::Mixin::HasMethods::add_method |
| 1997 | 2 | 1 | 11.1ms | 44.9ms | Class::MOP::Mixin::HasMethods::_get_maybe_raw_method |
| 1661 | 13 | 9 | 6.28ms | 54.0ms | Class::MOP::Mixin::HasMethods::get_method |
| 913 | 1 | 1 | 6.15ms | 7.49ms | Class::MOP::Mixin::HasMethods::update_package_cache_flag |
| 44 | 2 | 1 | 4.35ms | 15.1ms | Class::MOP::Mixin::HasMethods::_full_method_map |
| 183 | 1 | 1 | 1.52ms | 5.35ms | Class::MOP::Mixin::HasMethods::wrap_method_body |
| 305 | 1 | 1 | 1.32ms | 1.69ms | Class::MOP::Mixin::HasMethods::_code_is_mine |
| 336 | 10 | 7 | 1.21ms | 4.72ms | Class::MOP::Mixin::HasMethods::has_method |
| 913 | 1 | 1 | 671µs | 671µs | Class::MOP::Mixin::HasMethods::CORE:match (opcode) |
| 55 | 6 | 5 | 667µs | 30.8ms | Class::MOP::Mixin::HasMethods::_add_meta_method |
| 1 | 1 | 1 | 438µs | 2.01ms | Class::MOP::Mixin::HasMethods::BEGIN@12 |
| 1 | 1 | 1 | 307µs | 418µs | Class::MOP::Mixin::HasMethods::BEGIN@13 |
| 43 | 4 | 4 | 152µs | 14.3ms | Class::MOP::Mixin::HasMethods::_get_local_methods |
| 25 | 2 | 1 | 23µs | 23µs | Class::MOP::Mixin::HasMethods::_meta_method_class |
| 21 | 2 | 2 | 22µs | 22µs | Class::MOP::Mixin::HasMethods::reset_package_cache_flag |
| 1 | 1 | 1 | 10µs | 10µs | Class::MOP::Mixin::HasMethods::BEGIN@2 |
| 1 | 1 | 1 | 9µs | 1.01ms | Class::MOP::Mixin::HasMethods::get_method_list |
| 1 | 1 | 1 | 6µs | 31µs | Class::MOP::Mixin::HasMethods::BEGIN@15 |
| 1 | 1 | 1 | 6µs | 23µs | Class::MOP::Mixin::HasMethods::BEGIN@16 |
| 1 | 1 | 1 | 6µs | 9µs | Class::MOP::Mixin::HasMethods::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 51µs | Class::MOP::Mixin::HasMethods::BEGIN@21 |
| 1 | 1 | 1 | 5µs | 27µs | Class::MOP::Mixin::HasMethods::BEGIN@17 |
| 1 | 1 | 1 | 5µs | 16µs | Class::MOP::Mixin::HasMethods::BEGIN@9 |
| 1 | 1 | 1 | 3µs | 3µs | Class::MOP::Mixin::HasMethods::BEGIN@19 |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::_get_overloaded_operator_body |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::_overload_map |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::_restore_metamethods_from |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::_wrap_overload |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::add_overloaded_operator |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::get_all_overloaded_operators |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::get_overload_list |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::get_overloaded_operator |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::has_overloaded_operator |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::is_overloaded |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::overload_operators |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::remove_method |
| 0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::remove_overloaded_operator |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::MOP::Mixin::HasMethods; | ||||
| 2 | # spent 10µs within Class::MOP::Mixin::HasMethods::BEGIN@2 which was called:
# once (10µs+0s) by Class::MOP::BEGIN@25 at line 4 | ||||
| 3 | 1 | 4µs | $Class::MOP::Mixin::HasMethods::AUTHORITY = 'cpan:STEVAN'; | ||
| 4 | 1 | 30µs | 1 | 10µs | } # spent 10µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@2 |
| 5 | { | ||||
| 6 | 2 | 800ns | $Class::MOP::Mixin::HasMethods::VERSION = '2.1005'; | ||
| 7 | } | ||||
| 8 | |||||
| 9 | 2 | 19µs | 2 | 26µs | # spent 16µs (5+10) within Class::MOP::Mixin::HasMethods::BEGIN@9 which was called:
# once (5µs+10µs) by Class::MOP::BEGIN@25 at line 9 # spent 16µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@9
# spent 10µs making 1 call to strict::import |
| 10 | 2 | 18µs | 2 | 12µs | # spent 9µs (6+3) within Class::MOP::Mixin::HasMethods::BEGIN@10 which was called:
# once (6µs+3µs) by Class::MOP::BEGIN@25 at line 10 # spent 9µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@10
# spent 3µs making 1 call to warnings::import |
| 11 | |||||
| 12 | 2 | 86µs | 1 | 2.01ms | # spent 2.01ms (438µs+1.58) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called:
# once (438µs+1.58ms) by Class::MOP::BEGIN@25 at line 12 # spent 2.01ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12 |
| 13 | 2 | 88µs | 1 | 418µs | # spent 418µs (307+112) within Class::MOP::Mixin::HasMethods::BEGIN@13 which was called:
# once (307µs+112µs) by Class::MOP::BEGIN@25 at line 13 # spent 418µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@13 |
| 14 | |||||
| 15 | 2 | 21µs | 2 | 55µs | # spent 31µs (6+24) within Class::MOP::Mixin::HasMethods::BEGIN@15 which was called:
# once (6µs+24µs) by Class::MOP::BEGIN@25 at line 15 # spent 31µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@15
# spent 24µs making 1 call to Exporter::import |
| 16 | 2 | 20µs | 2 | 41µs | # spent 23µs (6+18) within Class::MOP::Mixin::HasMethods::BEGIN@16 which was called:
# once (6µs+18µs) by Class::MOP::BEGIN@25 at line 16 # spent 23µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@16
# spent 18µs making 1 call to Exporter::import |
| 17 | 2 | 19µs | 2 | 49µs | # spent 27µs (5+22) within Class::MOP::Mixin::HasMethods::BEGIN@17 which was called:
# once (5µs+22µs) by Class::MOP::BEGIN@25 at line 17 # spent 27µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@17
# spent 22µs making 1 call to Exporter::import |
| 18 | |||||
| 19 | 2 | 19µs | 1 | 3µs | # spent 3µs within Class::MOP::Mixin::HasMethods::BEGIN@19 which was called:
# once (3µs+0s) by Class::MOP::BEGIN@25 at line 19 # spent 3µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@19 |
| 20 | |||||
| 21 | 2 | 1.11ms | 2 | 96µs | # spent 51µs (6+45) within Class::MOP::Mixin::HasMethods::BEGIN@21 which was called:
# once (6µs+45µs) by Class::MOP::BEGIN@25 at line 21 # spent 51µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@21
# spent 45µs making 1 call to base::import |
| 22 | |||||
| 23 | 25 | 38µs | # spent 23µs within Class::MOP::Mixin::HasMethods::_meta_method_class which was called 25 times, avg 924ns/call:
# 23 times (20µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 891ns/call
# 2 times (3µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 31, avg 1µs/call | ||
| 24 | |||||
| 25 | # spent 30.8ms (667µs+30.1) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 55 times, avg 560µs/call:
# 20 times (224µs+8.33ms) by metaclass::import at line 49 of metaclass.pm, avg 428µs/call
# 19 times (212µs+8.91ms) by Moose::Role::init_meta at line 155 of Moose/Role.pm, avg 480µs/call
# 10 times (127µs+6.84ms) by Class::MOP::Class::create at line 448 of Class/MOP/Class.pm, avg 697µs/call
# 4 times (46µs+4.72ms) by Moose::init_meta at line 217 of Moose.pm, avg 1.19ms/call
# once (35µs+908µs) by Moose::Exporter::BEGIN@13 at line 660 of Class/MOP.pm
# once (23µs+413µs) by Moose::Exporter::BEGIN@13 at line 666 of Class/MOP.pm | ||||
| 26 | 55 | 7µs | my $self = shift; | ||
| 27 | 55 | 14µs | my ($name) = @_; | ||
| 28 | 55 | 182µs | 110 | 6.64ms | my $existing_method = $self->can('find_method_by_name') # spent 6.27ms making 36 calls to Class::MOP::Class::find_method_by_name, avg 174µs/call
# spent 330µs making 19 calls to Moose::Meta::Role::find_method_by_name, avg 17µs/call
# spent 39µs making 55 calls to UNIVERSAL::can, avg 704ns/call |
| 29 | ? $self->find_method_by_name($name) | ||||
| 30 | : $self->get_method($name); | ||||
| 31 | 55 | 19µs | 4 | 5µs | return if $existing_method # spent 3µs making 2 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 1µs/call
# spent 2µs making 2 calls to UNIVERSAL::isa, avg 1µs/call |
| 32 | && $existing_method->isa($self->_meta_method_class); | ||||
| 33 | 55 | 347µs | 220 | 23.5ms | $self->add_method( # spent 13.9ms making 32 calls to Moose::Meta::Method::Meta::wrap, avg 434µs/call
# spent 6.52ms making 23 calls to Class::MOP::Method::Meta::wrap, avg 283µs/call
# spent 3.00ms making 55 calls to Class::MOP::Mixin::HasMethods::add_method, avg 55µs/call
# spent 28µs making 55 calls to Class::MOP::Package::name, avg 504ns/call
# spent 20µs making 23 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 891ns/call
# spent 16µs making 19 calls to Moose::Meta::Role::_meta_method_class, avg 826ns/call
# spent 12µs making 13 calls to Moose::Meta::Class::_meta_method_class, avg 962ns/call |
| 34 | $name => $self->_meta_method_class->wrap( | ||||
| 35 | name => $name, | ||||
| 36 | package_name => $self->name, | ||||
| 37 | associated_metaclass => $self, | ||||
| 38 | ) | ||||
| 39 | ); | ||||
| 40 | } | ||||
| 41 | |||||
| 42 | # spent 5.35ms (1.52+3.83) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 183 times, avg 29µs/call:
# 183 times (1.52ms+3.83ms) by Class::MOP::Mixin::HasMethods::get_method at line 124, avg 29µs/call | ||||
| 43 | 183 | 179µs | my ( $self, %args ) = @_; | ||
| 44 | |||||
| 45 | 183 | 335µs | 183 | 70µs | ( 'CODE' eq reftype $args{body} ) # spent 70µs making 183 calls to Scalar::Util::reftype, avg 384ns/call |
| 46 | || confess "Your code block must be a CODE reference"; | ||||
| 47 | |||||
| 48 | 183 | 1.03ms | 549 | 3.76ms | $self->method_metaclass->wrap( # spent 3.52ms making 183 calls to Class::MOP::Method::wrap, avg 19µs/call
# spent 122µs making 96 calls to Moose::Meta::Role::method_metaclass, avg 1µs/call
# spent 77µs making 183 calls to Class::MOP::Package::name, avg 420ns/call
# spent 46µs making 87 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 532ns/call |
| 49 | package_name => $self->name, | ||||
| 50 | %args, | ||||
| 51 | ); | ||||
| 52 | } | ||||
| 53 | |||||
| 54 | # spent 71.3ms (23.9+47.4) within Class::MOP::Mixin::HasMethods::add_method which was called 913 times, avg 78µs/call:
# 199 times (6.41ms+10.1ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 173 of Moose/Meta/Role/Application/ToClass.pm, avg 83µs/call
# 194 times (6.76ms+10.7ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 99 of Moose/Meta/Role/Application/ToRole.pm, avg 90µs/call
# 155 times (3.30ms+14.9ms) by Class::MOP::Attribute::install_accessors at line 428 of Class/MOP/Attribute.pm, avg 118µs/call
# 68 times (1.37ms+2.14ms) by Class::MOP::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Class.pm:1072] at line 1070 of Class/MOP/Class.pm, avg 52µs/call
# 67 times (1.40ms+2.26ms) by Class::MOP::Attribute::install_accessors at line 424 of Class/MOP/Attribute.pm, avg 55µs/call
# 55 times (1.19ms+1.81ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 55µs/call
# 50 times (1.01ms+1.55ms) by Class::MOP::Attribute::install_accessors at line 436 of Class/MOP/Attribute.pm, avg 51µs/call
# 31 times (637µs+1.01ms) by Class::MOP::Class::_inline_constructor at line 1452 of Class/MOP/Class.pm, avg 53µs/call
# 26 times (586µs+849µs) by Moose::Meta::Attribute::install_delegation at line 1125 of Moose/Meta/Attribute.pm, avg 55µs/call
# 21 times (435µs+656µs) by Moose::Meta::Class::add_override_method_modifier at line 595 of Moose/Meta/Class.pm, avg 52µs/call
# 14 times (286µs+561µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 61µs/call
# 8 times (162µs+249µs) by Class::MOP::Attribute::install_accessors at line 432 of Class/MOP/Attribute.pm, avg 51µs/call
# 7 times (102µs+179µs) by Moose::BEGIN@46 at line 30 of Moose/Meta/Attribute/Native.pm, avg 40µs/call
# 3 times (43µs+69µs) by Moose::BEGIN@35 at line 318 of Moose/Meta/Role.pm, avg 37µs/call
# 3 times (41µs+70µs) by Moose::BEGIN@35 at line 326 of Moose/Meta/Role.pm, avg 37µs/call
# 3 times (41µs+65µs) by Moose::BEGIN@35 at line 345 of Moose/Meta/Role.pm, avg 35µs/call
# 2 times (27µs+44µs) by Moose::BEGIN@35 at line 119 of Moose/Meta/Role.pm, avg 35µs/call
# once (28µs+52µs) by MooseX::Storage::import at line 23 of MooseX/Storage.pm
# once (25µs+30µs) by Class::MOP::Class::_inline_destructor at line 1490 of Class/MOP/Class.pm
# once (17µs+31µs) by Moose::Exporter::BEGIN@13 at line 486 of Class/MOP.pm
# once (15µs+24µs) by Moose::BEGIN@35 at line 99 of Moose/Meta/Role.pm
# once (14µs+24µs) by Moose::BEGIN@35 at line 109 of Moose/Meta/Role.pm
# once (14µs+23µs) by Moose::BEGIN@35 at line 124 of Moose/Meta/Role.pm
# once (14µs+23µs) by Moose::BEGIN@35 at line 104 of Moose/Meta/Role.pm | ||||
| 55 | 913 | 241µs | my ( $self, $method_name, $method ) = @_; | ||
| 56 | 913 | 201µs | ( defined $method_name && length $method_name ) | ||
| 57 | || confess "You must define a method name"; | ||||
| 58 | |||||
| 59 | 913 | 1.75ms | 913 | 436µs | my $package_name = $self->name; # spent 436µs making 913 calls to Class::MOP::Package::name, avg 478ns/call |
| 60 | |||||
| 61 | 913 | 400ns | my $body; | ||
| 62 | 913 | 3.24ms | 1803 | 1.01ms | if ( blessed($method) && $method->isa('Class::MOP::Method') ) { # spent 556µs making 913 calls to Scalar::Util::blessed, avg 609ns/call
# spent 450µs making 890 calls to UNIVERSAL::isa, avg 506ns/call |
| 63 | 890 | 1.55ms | 890 | 361µs | $body = $method->body; # spent 361µs making 890 calls to Class::MOP::Method::body, avg 405ns/call |
| 64 | 890 | 1.86ms | 1298 | 4.89ms | if ( $method->package_name ne $package_name ) { # spent 4.54ms making 408 calls to Class::MOP::Method::clone, avg 11µs/call
# spent 352µs making 890 calls to Class::MOP::Method::package_name, avg 396ns/call |
| 65 | $method = $method->clone( | ||||
| 66 | package_name => $package_name, | ||||
| 67 | name => $method_name, | ||||
| 68 | ); | ||||
| 69 | } | ||||
| 70 | |||||
| 71 | 890 | 761µs | 890 | 2.83ms | $method->attach_to_class($self); # spent 2.83ms making 890 calls to Class::MOP::Method::attach_to_class, avg 3µs/call |
| 72 | } | ||||
| 73 | else { | ||||
| 74 | # If a raw code reference is supplied, its method object is not created. | ||||
| 75 | # The method object won't be created until required. | ||||
| 76 | 23 | 4µs | $body = $method; | ||
| 77 | } | ||||
| 78 | |||||
| 79 | 913 | 3.29ms | 937 | 1.63ms | $self->_method_map->{$method_name} = $method; # spent 1.62ms making 913 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call
# spent 11µs making 24 calls to Class::MOP::Method::body, avg 475ns/call |
| 80 | |||||
| 81 | 913 | 4.93ms | 913 | 812µs | my ($current_package, $current_name) = Class::MOP::get_code_info($body); # spent 812µs making 913 calls to Class::MOP::get_code_info, avg 889ns/call |
| 82 | |||||
| 83 | 913 | 3.59ms | 1361 | 1.70ms | subname($package_name . '::' . $method_name, $body) # spent 1.03ms making 448 calls to Sub::Name::subname, avg 2µs/call
# spent 671µs making 913 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 735ns/call |
| 84 | unless defined $current_name && $current_name !~ /^__ANON__/; | ||||
| 85 | |||||
| 86 | 913 | 1.17ms | 913 | 26.2ms | $self->add_package_symbol("&$method_name", $body); # spent 26.2ms making 913 calls to Class::MOP::Package::add_package_symbol, avg 29µs/call |
| 87 | |||||
| 88 | # we added the method to the method map too, so it's still valid | ||||
| 89 | 913 | 2.12ms | 913 | 7.49ms | $self->update_package_cache_flag; # spent 7.49ms making 913 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 8µs/call |
| 90 | } | ||||
| 91 | |||||
| 92 | # spent 1.69ms (1.32+373µs) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 305 times, avg 6µs/call:
# 305 times (1.32ms+373µs) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 139, avg 6µs/call | ||||
| 93 | 305 | 58µs | my ( $self, $code ) = @_; | ||
| 94 | |||||
| 95 | 305 | 711µs | 305 | 224µs | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); # spent 224µs making 305 calls to Class::MOP::get_code_info, avg 733ns/call |
| 96 | |||||
| 97 | 305 | 1.04ms | 305 | 149µs | return ( $code_package && $code_package eq $self->name ) # spent 149µs making 305 calls to Class::MOP::Package::name, avg 490ns/call |
| 98 | || ( $code_package eq 'constant' && $code_name eq '__ANON__' ); | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | # spent 4.72ms (1.21+3.51) within Class::MOP::Mixin::HasMethods::has_method which was called 336 times, avg 14µs/call:
# 148 times (723µs+734µs) by Moose::Meta::Class::_inline_create_error at line 850 of Moose/Meta/Class.pm, avg 10µs/call
# 35 times (98µs+397µs) by Moose::Meta::Attribute::_process_accessors at line 1070 of Moose/Meta/Attribute.pm, avg 14µs/call
# 33 times (74µs+401µs) by Moose::Meta::Role::add_override_method_modifier at line 366 of Moose/Meta/Role.pm, avg 14µs/call
# 31 times (84µs+482µs) by Class::MOP::Class::_inline_constructor at line 1424 of Class/MOP/Class.pm, avg 18µs/call
# 30 times (76µs+362µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 137 of Moose/Meta/Role/Application/ToRole.pm, avg 15µs/call
# 21 times (58µs+611µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 207 of Moose/Meta/Role/Application/ToClass.pm, avg 32µs/call
# 21 times (46µs+252µs) by Moose::Meta::Class::add_override_method_modifier at line 592 of Moose/Meta/Class.pm, avg 14µs/call
# 10 times (31µs+193µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 106 of Moose/Meta/Role/Application/RoleSummation.pm, avg 22µs/call
# 6 times (17µs+66µs) by Class::MOP::Class::find_all_methods_by_name at line 1155 of Class/MOP/Class.pm, avg 14µs/call
# once (3µs+13µs) by Class::MOP::Class::_inline_destructor at line 1464 of Class/MOP/Class.pm | ||||
| 102 | 336 | 66µs | my ( $self, $method_name ) = @_; | ||
| 103 | |||||
| 104 | 336 | 71µs | ( defined $method_name && length $method_name ) | ||
| 105 | || confess "You must define a method name"; | ||||
| 106 | |||||
| 107 | 336 | 419µs | 336 | 3.38ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 3.38ms making 336 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 10µs/call |
| 108 | or return; | ||||
| 109 | |||||
| 110 | 152 | 585µs | 152 | 129µs | return defined($self->_method_map->{$method_name} = $method); # spent 129µs making 152 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 851ns/call |
| 111 | } | ||||
| 112 | |||||
| 113 | # spent 54.0ms (6.28+47.8) within Class::MOP::Mixin::HasMethods::get_method which was called 1661 times, avg 33µs/call:
# 438 times (2.17ms+8.21ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 205, avg 24µs/call
# 367 times (1.21ms+14.0ms) by Class::MOP::Class::find_method_by_name at line 1123 of Class/MOP/Class.pm, avg 41µs/call
# 216 times (650µs+7.46ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 90 of Moose/Meta/Role/Application/ToRole.pm, avg 38µs/call
# 199 times (500µs+8.25ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 169 of Moose/Meta/Role/Application/ToClass.pm, avg 44µs/call
# 186 times (832µs+3.12ms) by Class::MOP::Class::find_next_method_by_name at line 1171 of Class/MOP/Class.pm, avg 21µs/call
# 68 times (187µs+850µs) by Class::MOP::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Class.pm:1072] at line 1047 of Class/MOP/Class.pm, avg 15µs/call
# 63 times (317µs+275µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 163 of Moose/Meta/Role/Application/RoleSummation.pm, avg 9µs/call
# 39 times (161µs+1.14ms) by Moose::Meta::Role::find_method_by_name at line 436 of Moose/Meta/Role.pm, avg 33µs/call
# 35 times (103µs+655µs) by Moose::Meta::Attribute::_process_accessors at line 1043 of Moose/Meta/Attribute.pm, avg 22µs/call
# 26 times (78µs+3.14ms) by Moose::Meta::Attribute::install_delegation at line 1106 of Moose/Meta/Attribute.pm, avg 124µs/call
# 19 times (58µs+601µs) by Moose::Role::init_meta at line 145 of Moose/Role.pm, avg 35µs/call
# 4 times (11µs+63µs) by Moose::init_meta at line 207 of Moose.pm, avg 18µs/call
# once (6µs+5µs) by Class::MOP::Class::find_all_methods_by_name at line 1155 of Class/MOP/Class.pm | ||||
| 114 | 1661 | 362µs | my ( $self, $method_name ) = @_; | ||
| 115 | |||||
| 116 | 1661 | 291µs | ( defined $method_name && length $method_name ) | ||
| 117 | || confess "You must define a method name"; | ||||
| 118 | |||||
| 119 | 1661 | 2.18ms | 1661 | 41.5ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 41.5ms making 1661 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 25µs/call |
| 120 | or return; | ||||
| 121 | |||||
| 122 | 625 | 2.36ms | 1067 | 570µs | return $method if blessed($method) && $method->isa('Class::MOP::Method'); # spent 360µs making 625 calls to Scalar::Util::blessed, avg 577ns/call
# spent 209µs making 442 calls to UNIVERSAL::isa, avg 474ns/call |
| 123 | |||||
| 124 | 183 | 929µs | 366 | 5.69ms | return $self->_method_map->{$method_name} = $self->wrap_method_body( # spent 5.35ms making 183 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 29µs/call
# spent 200µs making 160 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call
# spent 133µs making 23 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 6µs/call |
| 125 | body => $method, | ||||
| 126 | name => $method_name, | ||||
| 127 | associated_metaclass => $self, | ||||
| 128 | ); | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | # spent 44.9ms (11.1+33.8) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 1997 times, avg 22µs/call:
# 1661 times (9.83ms+31.7ms) by Class::MOP::Mixin::HasMethods::get_method at line 119, avg 25µs/call
# 336 times (1.26ms+2.12ms) by Class::MOP::Mixin::HasMethods::has_method at line 107, avg 10µs/call | ||||
| 132 | 1997 | 238µs | my ( $self, $method_name ) = @_; | ||
| 133 | |||||
| 134 | 1997 | 8.97ms | 2545 | 9.26ms | my $map_entry = $self->_method_map->{$method_name}; # spent 5.81ms making 268 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 22µs/call
# spent 3.27ms making 1729 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call
# spent 178µs making 548 calls to Class::MOP::Method::body, avg 325ns/call |
| 135 | 1997 | 929µs | return $map_entry if defined $map_entry; | ||
| 136 | |||||
| 137 | 1404 | 1.53ms | 1404 | 23.0ms | my $code = $self->get_package_symbol("&$method_name"); # spent 23.0ms making 1404 calls to Class::MOP::Package::get_package_symbol, avg 16µs/call |
| 138 | |||||
| 139 | 1404 | 1.83ms | 305 | 1.69ms | return unless $code && $self->_code_is_mine($code); # spent 1.69ms making 305 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 6µs/call |
| 140 | |||||
| 141 | 184 | 233µs | return $code; | ||
| 142 | } | ||||
| 143 | |||||
| 144 | sub remove_method { | ||||
| 145 | my ( $self, $method_name ) = @_; | ||||
| 146 | |||||
| 147 | ( defined $method_name && length $method_name ) | ||||
| 148 | || confess "You must define a method name"; | ||||
| 149 | |||||
| 150 | my $removed_method = delete $self->_method_map->{$method_name}; | ||||
| 151 | |||||
| 152 | $self->remove_package_symbol("&$method_name"); | ||||
| 153 | |||||
| 154 | $removed_method->detach_from_class | ||||
| 155 | if blessed($removed_method) && $removed_method->isa('Class::MOP::Method'); | ||||
| 156 | |||||
| 157 | # still valid, since we just removed the method from the map | ||||
| 158 | $self->update_package_cache_flag; | ||||
| 159 | |||||
| 160 | return $removed_method; | ||||
| 161 | } | ||||
| 162 | |||||
| 163 | # spent 1.01ms (9µs+999µs) within Class::MOP::Mixin::HasMethods::get_method_list which was called:
# once (9µs+999µs) by namespace::autoclean::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/namespace/autoclean.pm:57] at line 45 of namespace/autoclean.pm | ||||
| 164 | 1 | 300ns | my $self = shift; | ||
| 165 | |||||
| 166 | 1 | 8µs | 1 | 999µs | return keys %{ $self->_full_method_map }; # spent 999µs making 1 call to Class::MOP::Mixin::HasMethods::_full_method_map |
| 167 | } | ||||
| 168 | |||||
| 169 | # spent 14.3ms (152µs+14.1) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 43 times, avg 332µs/call:
# 17 times (56µs+2.11ms) by Class::MOP::Class::get_all_methods at line 1136 of Class/MOP/Class.pm, avg 128µs/call
# 9 times (37µs+5.62ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 82 of Moose/Meta/Role/Application/ToRole.pm, avg 629µs/call
# 9 times (34µs+3.30ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 162 of Moose/Meta/Role/Application/ToClass.pm, avg 371µs/call
# 8 times (24µs+3.08ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 174 of Moose/Meta/Role/Application/RoleSummation.pm, avg 389µs/call | ||||
| 170 | 43 | 5µs | my $self = shift; | ||
| 171 | |||||
| 172 | 43 | 138µs | 43 | 14.1ms | return values %{ $self->_full_method_map }; # spent 14.1ms making 43 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 328µs/call |
| 173 | } | ||||
| 174 | |||||
| 175 | sub _restore_metamethods_from { | ||||
| 176 | my $self = shift; | ||||
| 177 | my ($old_meta) = @_; | ||||
| 178 | |||||
| 179 | for my $method ($old_meta->_get_local_methods) { | ||||
| 180 | $method->_make_compatible_with($self->method_metaclass); | ||||
| 181 | $self->add_method($method->name => $method); | ||||
| 182 | } | ||||
| 183 | } | ||||
| 184 | |||||
| 185 | 21 | 37µs | # spent 22µs within Class::MOP::Mixin::HasMethods::reset_package_cache_flag which was called 21 times, avg 1µs/call:
# 11 times (12µs+0s) by Moose::Meta::Role::add_role at line 409 of Moose/Meta/Role.pm, avg 1µs/call
# 10 times (10µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 200 of Moose/Meta/Role/Application/ToClass.pm, avg 1µs/call | ||
| 186 | # spent 7.49ms (6.15+1.35) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 913 times, avg 8µs/call:
# 913 times (6.15ms+1.35ms) by Class::MOP::Mixin::HasMethods::add_method at line 89, avg 8µs/call | ||||
| 187 | 913 | 141µs | my $self = shift; | ||
| 188 | # NOTE: | ||||
| 189 | # we can manually update the cache number | ||||
| 190 | # since we are actually adding the method | ||||
| 191 | # to our cache as well. This avoids us | ||||
| 192 | # having to regenerate the method_map. | ||||
| 193 | # - SL | ||||
| 194 | 913 | 10.7ms | 1826 | 1.35ms | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); # spent 960µs making 913 calls to mro::get_pkg_gen, avg 1µs/call
# spent 388µs making 913 calls to Class::MOP::Package::name, avg 425ns/call |
| 195 | } | ||||
| 196 | |||||
| 197 | # spent 15.1ms (4.35+10.8) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 44 times, avg 344µs/call:
# 43 times (4.29ms+9.83ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 172, avg 328µs/call
# once (60µs+940µs) by Class::MOP::Mixin::HasMethods::get_method_list at line 166 | ||||
| 198 | 44 | 3µs | my $self = shift; | ||
| 199 | |||||
| 200 | 44 | 3.45ms | 88 | 72µs | my $pkg_gen = Class::MOP::check_package_cache_flag($self->name); # spent 54µs making 44 calls to mro::get_pkg_gen, avg 1µs/call
# spent 18µs making 44 calls to Class::MOP::Package::name, avg 409ns/call |
| 201 | |||||
| 202 | 44 | 21µs | if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) { | ||
| 203 | # forcibly reify all method map entries | ||||
| 204 | $self->get_method($_) | ||||
| 205 | 24 | 452µs | 462 | 10.6ms | for $self->list_all_package_symbols('CODE'); # spent 10.4ms making 438 calls to Class::MOP::Mixin::HasMethods::get_method, avg 24µs/call
# spent 276µs making 24 calls to Class::MOP::Package::list_all_package_symbols, avg 11µs/call |
| 206 | 24 | 14µs | $self->{_package_cache_flag_full} = $pkg_gen; | ||
| 207 | } | ||||
| 208 | |||||
| 209 | 44 | 179µs | 44 | 50µs | return $self->_method_map; # spent 50µs making 44 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call |
| 210 | } | ||||
| 211 | |||||
| 212 | # overloading | ||||
| 213 | |||||
| 214 | 1 | 0s | my $overload_operators; | ||
| 215 | sub overload_operators { | ||||
| 216 | $overload_operators ||= [map { split /\s+/ } values %overload::ops]; | ||||
| 217 | return @$overload_operators; | ||||
| 218 | } | ||||
| 219 | |||||
| 220 | sub is_overloaded { | ||||
| 221 | my $self = shift; | ||||
| 222 | return overload::Overloaded($self->name); | ||||
| 223 | } | ||||
| 224 | |||||
| 225 | # XXX this could probably stand to be cached, but i figure it should be | ||||
| 226 | # uncommon enough to not particularly matter | ||||
| 227 | sub _overload_map { | ||||
| 228 | my $self = shift; | ||||
| 229 | |||||
| 230 | return {} unless $self->is_overloaded; | ||||
| 231 | |||||
| 232 | my %map; | ||||
| 233 | for my $op ($self->overload_operators) { | ||||
| 234 | my $body = $self->_get_overloaded_operator_body($op); | ||||
| 235 | next unless defined $body; | ||||
| 236 | $map{$op} = $body; | ||||
| 237 | } | ||||
| 238 | |||||
| 239 | return \%map; | ||||
| 240 | } | ||||
| 241 | |||||
| 242 | sub get_overload_list { | ||||
| 243 | my $self = shift; | ||||
| 244 | return keys %{ $self->_overload_map }; | ||||
| 245 | } | ||||
| 246 | |||||
| 247 | sub get_all_overloaded_operators { | ||||
| 248 | my $self = shift; | ||||
| 249 | my $map = $self->_overload_map; | ||||
| 250 | return map { $self->_wrap_overload($_, $map->{$_}) } keys %$map; | ||||
| 251 | } | ||||
| 252 | |||||
| 253 | sub has_overloaded_operator { | ||||
| 254 | my $self = shift; | ||||
| 255 | my ($op) = @_; | ||||
| 256 | return defined $self->_get_overloaded_operator_body($op); | ||||
| 257 | } | ||||
| 258 | |||||
| 259 | sub get_overloaded_operator { | ||||
| 260 | my $self = shift; | ||||
| 261 | my ($op) = @_; | ||||
| 262 | my $body = $self->_get_overloaded_operator_body($op); | ||||
| 263 | return unless defined $body; | ||||
| 264 | return $self->_wrap_overload($op, $body); | ||||
| 265 | } | ||||
| 266 | |||||
| 267 | sub add_overloaded_operator { | ||||
| 268 | my $self = shift; | ||||
| 269 | my ($op, $body) = @_; | ||||
| 270 | $self->name->overload::OVERLOAD($op => $body); | ||||
| 271 | } | ||||
| 272 | |||||
| 273 | sub remove_overloaded_operator { | ||||
| 274 | my $self = shift; | ||||
| 275 | my ($op) = @_; | ||||
| 276 | |||||
| 277 | if ( $] < 5.018 ) { | ||||
| 278 | # ugh, overload.pm provides no api for this - but the problem that | ||||
| 279 | # makes this necessary has been fixed in 5.18 | ||||
| 280 | $self->get_or_add_package_symbol('%OVERLOAD')->{dummy}++; | ||||
| 281 | } | ||||
| 282 | |||||
| 283 | $self->remove_package_symbol('&(' . $op); | ||||
| 284 | } | ||||
| 285 | |||||
| 286 | sub _get_overloaded_operator_body { | ||||
| 287 | my $self = shift; | ||||
| 288 | my ($op) = @_; | ||||
| 289 | return overload::Method($self->name, $op); | ||||
| 290 | } | ||||
| 291 | |||||
| 292 | sub _wrap_overload { | ||||
| 293 | my $self = shift; | ||||
| 294 | my ($op, $body) = @_; | ||||
| 295 | return Class::MOP::Method::Overload->wrap( | ||||
| 296 | operator => $op, | ||||
| 297 | package_name => $self->name, | ||||
| 298 | associated_metaclass => $self, | ||||
| 299 | body => $body, | ||||
| 300 | ); | ||||
| 301 | } | ||||
| 302 | |||||
| 303 | 1 | 3µs | 1; | ||
| 304 | |||||
| 305 | # ABSTRACT: Methods for metaclasses which have methods | ||||
| 306 | |||||
| 307 | __END__ | ||||
# spent 671µs within Class::MOP::Mixin::HasMethods::CORE:match which was called 913 times, avg 735ns/call:
# 913 times (671µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 83, avg 735ns/call |