← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename/usr/local/lib/perl/5.18.2/Class/MOP/Mixin/HasMethods.pm
StatementsExecuted 48684 statements in 121ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1263241136.8ms90.9msClass::MOP::Mixin::HasMethods::::add_methodClass::MOP::Mixin::HasMethods::add_method
2438151128.2ms89.6msClass::MOP::Mixin::HasMethods::::get_methodClass::MOP::Mixin::HasMethods::get_method
30072126.2ms68.0msClass::MOP::Mixin::HasMethods::::_get_maybe_raw_methodClass::MOP::Mixin::HasMethods::_get_maybe_raw_method
97656.54ms47.0msClass::MOP::Mixin::HasMethods::::_add_meta_methodClass::MOP::Mixin::HasMethods::_add_meta_method
107115.59ms38.5msClass::MOP::Mixin::HasMethods::::_full_method_mapClass::MOP::Mixin::HasMethods::_full_method_map
296115.54ms5.85msClass::MOP::Mixin::HasMethods::::_code_is_mineClass::MOP::Mixin::HasMethods::_code_is_mine
1264214.88ms6.74msClass::MOP::Mixin::HasMethods::::update_package_cache_flagClass::MOP::Mixin::HasMethods::update_package_cache_flag
221111.97ms6.86msClass::MOP::Mixin::HasMethods::::wrap_method_bodyClass::MOP::Mixin::HasMethods::wrap_method_body
569861.90ms17.6msClass::MOP::Mixin::HasMethods::::has_methodClass::MOP::Mixin::HasMethods::has_method
1263111.37ms1.37msClass::MOP::Mixin::HasMethods::::CORE:matchClass::MOP::Mixin::HasMethods::CORE:match (opcode)
10744422µs38.9msClass::MOP::Mixin::HasMethods::::_get_local_methodsClass::MOP::Mixin::HasMethods::_get_local_methods
111392µs2.40msClass::MOP::Mixin::HasMethods::::BEGIN@7Class::MOP::Mixin::HasMethods::BEGIN@7
422265µs65µsClass::MOP::Mixin::HasMethods::::reset_package_cache_flagClass::MOP::Mixin::HasMethods::reset_package_cache_flag
11139µs64µsClass::MOP::Mixin::HasMethods::::remove_methodClass::MOP::Mixin::HasMethods::remove_method
252132µs32µsClass::MOP::Mixin::HasMethods::::_meta_method_classClass::MOP::Mixin::HasMethods::_meta_method_class
1119µs33µsClass::MOP::Mixin::HasMethods::::BEGIN@10Class::MOP::Mixin::HasMethods::BEGIN@10
1118µs18µsClass::MOP::Mixin::HasMethods::::BEGIN@4Class::MOP::Mixin::HasMethods::BEGIN@4
1117µs22µsClass::MOP::Mixin::HasMethods::::BEGIN@12Class::MOP::Mixin::HasMethods::BEGIN@12
1116µs31µsClass::MOP::Mixin::HasMethods::::BEGIN@9Class::MOP::Mixin::HasMethods::BEGIN@9
1116µs9µsClass::MOP::Mixin::HasMethods::::BEGIN@5Class::MOP::Mixin::HasMethods::BEGIN@5
0000s0sClass::MOP::Mixin::HasMethods::::_restore_metamethods_fromClass::MOP::Mixin::HasMethods::_restore_metamethods_from
0000s0sClass::MOP::Mixin::HasMethods::::get_method_listClass::MOP::Mixin::HasMethods::get_method_list
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Class::MOP::Mixin::HasMethods;
21600nsour $VERSION = '2.1604';
3
4218µs227µs
# spent 18µs (8+9) within Class::MOP::Mixin::HasMethods::BEGIN@4 which was called: # once (8µs+9µs) by Class::MOP::BEGIN@16 at line 4
use strict;
# spent 18µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@4 # spent 9µs making 1 call to strict::import
5218µs212µs
# spent 9µs (6+3) within Class::MOP::Mixin::HasMethods::BEGIN@5 which was called: # once (6µs+3µs) by Class::MOP::BEGIN@16 at line 5
use warnings;
# spent 9µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@5 # spent 3µs making 1 call to warnings::import
6
7290µs12.40ms
# spent 2.40ms (392µs+2.01) within Class::MOP::Mixin::HasMethods::BEGIN@7 which was called: # once (392µs+2.01ms) by Class::MOP::BEGIN@16 at line 7
use Class::MOP::Method::Meta;
# spent 2.40ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@7
8
9222µs256µs
# spent 31µs (6+25) within Class::MOP::Mixin::HasMethods::BEGIN@9 which was called: # once (6µs+25µs) by Class::MOP::BEGIN@16 at line 9
use Scalar::Util 'blessed', 'reftype';
# spent 31µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@9 # spent 25µs making 1 call to Exporter::import
10226µs257µs
# spent 33µs (9+24) within Class::MOP::Mixin::HasMethods::BEGIN@10 which was called: # once (9µs+24µs) by Class::MOP::BEGIN@16 at line 10
use Sub::Name 'subname';
# spent 33µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@10 # spent 24µs making 1 call to Exporter::import
11
122738µs237µs
# spent 22µs (7+15) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called: # once (7µs+15µs) by Class::MOP::BEGIN@16 at line 12
use parent 'Class::MOP::Mixin';
# spent 22µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12 # spent 15µs making 1 call to parent::import
13
142557µs
# spent 32µs within Class::MOP::Mixin::HasMethods::_meta_method_class which was called 25 times, avg 1µs/call: # 23 times (30µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24, avg 1µs/call # 2 times (2µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 22, avg 1µs/call
sub _meta_method_class { 'Class::MOP::Method::Meta' }
15
16
# spent 47.0ms (6.54+40.5) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 97 times, avg 485µs/call: # 35 times (571µs+15.5ms) by Moose::Role::init_meta at line 161 of Moose/Role.pm, avg 460µs/call # 28 times (462µs+9.55ms) by Moose::init_meta at line 221 of Moose.pm, avg 358µs/call # 20 times (5.24ms+9.97ms) by metaclass::import at line 39 of metaclass.pm, avg 761µs/call # 12 times (202µs+4.10ms) by Class::MOP::Class::create at line 446 of Class/MOP/Class.pm, avg 359µs/call # once (34µs+899µs) by Moose::Exporter::BEGIN@8 at line 721 of Class/MOP.pm # once (28µs+426µs) by Moose::Exporter::BEGIN@8 at line 727 of Class/MOP.pm
sub _add_meta_method {
179730µs my $self = shift;
189744µs my ($name) = @_;
1997457µs1944.75ms my $existing_method = $self->can('find_method_by_name')
# spent 4.03ms making 62 calls to Class::MOP::Class::find_method_by_name, avg 65µs/call # spent 605µs making 35 calls to Moose::Meta::Role::find_method_by_name, avg 17µs/call # spent 120µs making 97 calls to UNIVERSAL::can, avg 1µs/call
20 ? $self->find_method_by_name($name)
21 : $self->get_method($name);
229741µs66µs return if $existing_method
# spent 2µs making 2 calls to UNIVERSAL::isa, avg 1µs/call # spent 2µs making 2 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 1µs/call # spent 2µs making 2 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 900ns/call
23 && $existing_method->isa($self->_meta_method_class);
2497872µs38835.7ms $self->add_method(
# spent 17.1ms making 74 calls to Moose::Meta::Method::Meta::wrap, avg 231µs/call # spent 10.4ms making 97 calls to Class::MOP::Mixin::HasMethods::add_method, avg 107µs/call # spent 8.05ms making 23 calls to Class::MOP::Method::Meta::wrap, avg 350µs/call # spent 48µs making 39 calls to Moose::Meta::Class::_meta_method_class, avg 1µs/call # spent 42µs making 97 calls to Class::MOP::Package::name, avg 432ns/call # spent 40µs making 35 calls to Moose::Meta::Role::_meta_method_class, avg 1µs/call # spent 30µs making 23 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 1µs/call
25 $name => $self->_meta_method_class->wrap(
26 name => $name,
27 package_name => $self->name,
28 associated_metaclass => $self,
29 )
30 );
31}
32
33
# spent 6.86ms (1.97+4.89) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 221 times, avg 31µs/call: # 221 times (1.97ms+4.89ms) by Class::MOP::Mixin::HasMethods::get_method at line 116, avg 31µs/call
sub wrap_method_body {
34221257µs my ( $self, %args ) = @_;
35
36221518µs22196µs ( $args{body} && 'CODE' eq reftype $args{body} )
# spent 96µs making 221 calls to Scalar::Util::reftype, avg 433ns/call
37 || $self->_throw_exception( CodeBlockMustBeACodeRef => instance => $self,
38 params => \%args
39 );
402211.34ms6634.80ms $self->method_metaclass->wrap(
# spent 4.53ms making 221 calls to Class::MOP::Method::wrap, avg 20µs/call # spent 139µs making 110 calls to Moose::Meta::Role::method_metaclass, avg 1µs/call # spent 73µs making 221 calls to Class::MOP::Package::name, avg 332ns/call # spent 57µs making 111 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 517ns/call
41 package_name => $self->name,
42 %args,
43 );
44}
45
46
# spent 90.9ms (36.8+54.1) within Class::MOP::Mixin::HasMethods::add_method which was called 1263 times, avg 72µs/call: # 285 times (5.53ms+10.9ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 147 of Moose/Meta/Role/Application/ToClass.pm, avg 58µs/call # 271 times (6.40ms+18.1ms) by Class::MOP::Attribute::install_accessors at line 450 of Class/MOP/Attribute.pm, avg 90µs/call # 209 times (8.78ms+7.71ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 94 of Moose/Meta/Role/Application/ToRole.pm, avg 79µs/call # 97 times (6.90ms+3.52ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24, avg 107µs/call # 75 times (1.64ms+2.41ms) by Class::MOP::Attribute::install_accessors at line 458 of Class/MOP/Attribute.pm, avg 54µs/call # 66 times (1.29ms+1.95ms) by Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Class.pm:1082] at line 1080 of Class/MOP/Class.pm, avg 49µs/call # 58 times (1.53ms+2.27ms) by Class::MOP::Class::_inline_constructor at line 1467 of Class/MOP/Class.pm, avg 66µs/call # 56 times (1.74ms+2.57ms) by Moose::Meta::Attribute::install_delegation at line 1105 of Moose/Meta/Attribute.pm, avg 77µs/call # 43 times (944µs+1.55ms) by Class::MOP::Attribute::install_accessors at line 446 of Class/MOP/Attribute.pm, avg 58µs/call # 28 times (624µs+928µs) by Class::MOP::Class::_inline_destructor at line 1509 of Class/MOP/Class.pm, avg 55µs/call # 25 times (517µs+745µs) by Moose::Meta::Class::add_override_method_modifier at line 590 of Moose/Meta/Class.pm, avg 50µs/call # 13 times (278µs+492µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 59µs/call # 13 times (292µs+418µs) by Class::MOP::Attribute::install_accessors at line 454 of Class/MOP/Attribute.pm, avg 55µs/call # 7 times (105µs+173µs) by Moose::BEGIN@43 at line 26 of Moose/Meta/Attribute/Native.pm, avg 40µs/call # 3 times (43µs+65µs) by Moose::BEGIN@32 at line 315 of Moose/Meta/Role.pm, avg 36µs/call # 3 times (40µs+62µs) by Moose::BEGIN@32 at line 342 of Moose/Meta/Role.pm, avg 34µs/call # 3 times (40µs+61µs) by Moose::BEGIN@32 at line 323 of Moose/Meta/Role.pm, avg 34µs/call # 2 times (27µs+41µs) by Moose::BEGIN@32 at line 112 of Moose/Meta/Role.pm, avg 34µs/call # once (27µs+33µs) by Class::MOP::Attribute::install_accessors at line 462 of Class/MOP/Attribute.pm # once (15µs+28µs) by Moose::Exporter::BEGIN@8 at line 507 of Class/MOP.pm # once (14µs+24µs) by Moose::BEGIN@32 at line 117 of Moose/Meta/Role.pm # once (14µs+22µs) by Moose::BEGIN@32 at line 92 of Moose/Meta/Role.pm # once (14µs+21µs) by Moose::BEGIN@32 at line 102 of Moose/Meta/Role.pm # once (14µs+21µs) by Moose::BEGIN@32 at line 97 of Moose/Meta/Role.pm
sub add_method {
471263432µs my ( $self, $method_name, $method ) = @_;
481263404µs ( defined $method_name && length $method_name )
49 || $self->_throw_exception( MustDefineAMethodName => instance => $self );
50
5112632.68ms1263613µs my $package_name = $self->name;
# spent 613µs making 1263 calls to Class::MOP::Package::name, avg 486ns/call
52
531263117µs my $body;
54126310.4ms25031.71ms if ( blessed($method) && $method->isa('Class::MOP::Method') ) {
# spent 947µs making 1263 calls to Scalar::Util::blessed, avg 750ns/call # spent 764µs making 1240 calls to UNIVERSAL::isa, avg 616ns/call
5512406.74ms1240558µs $body = $method->body;
# spent 558µs making 1240 calls to Class::MOP::Method::body, avg 450ns/call
5612402.79ms17476.29ms if ( $method->package_name ne $package_name ) {
# spent 5.83ms making 507 calls to Class::MOP::Method::clone, avg 11µs/call # spent 470µs making 1240 calls to Class::MOP::Method::package_name, avg 379ns/call
57 $method = $method->clone(
58 package_name => $package_name,
59 name => $method_name,
60 );
61 }
62
6312401.29ms12404.41ms $method->attach_to_class($self);
# spent 4.41ms making 1240 calls to Class::MOP::Method::attach_to_class, avg 4µs/call
64 }
65 else {
66 # If a raw code reference is supplied, its method object is not created.
67 # The method object won't be created until required.
68235µs $body = $method;
69 }
70
7112635.14ms12862.46ms $self->_method_map->{$method_name} = $method;
# spent 2.45ms making 1263 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call # spent 10µs making 23 calls to Class::MOP::Method::body, avg 422ns/call
72
7312633.31ms12631.14ms my ($current_package, $current_name) = Class::MOP::get_code_info($body);
# spent 1.14ms making 1263 calls to Class::MOP::get_code_info, avg 904ns/call
74
7512636.32ms19502.91ms subname($package_name . '::' . $method_name, $body)
# spent 1.53ms making 687 calls to Sub::Name::subname, avg 2µs/call # spent 1.37ms making 1263 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 1µs/call
76 unless defined $current_name && $current_name !~ /^__ANON__/;
77
7812631.81ms126327.3ms $self->add_package_symbol("&$method_name", $body);
# spent 27.3ms making 1263 calls to Class::MOP::Package::add_package_symbol, avg 22µs/call
79
80 # we added the method to the method map too, so it's still valid
8112633.61ms12636.73ms $self->update_package_cache_flag;
# spent 6.73ms making 1263 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 5µs/call
82}
83
84
# spent 5.85ms (5.54+314µs) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 296 times, avg 20µs/call: # 296 times (5.54ms+314µs) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 131, avg 20µs/call
sub _code_is_mine {
8529693µs my ( $self, $code ) = @_;
86
87296694µs296207µs my ( $code_package, $code_name ) = Class::MOP::get_code_info($code);
# spent 207µs making 296 calls to Class::MOP::get_code_info, avg 701ns/call
88
892965.27ms296107µs return ( $code_package && $code_package eq $self->name )
# spent 107µs making 296 calls to Class::MOP::Package::name, avg 362ns/call
90 || ( $code_package eq 'constant' && $code_name eq '__ANON__' );
91}
92
93
# spent 17.6ms (1.90+15.7) within Class::MOP::Mixin::HasMethods::has_method which was called 569 times, avg 31µs/call: # 196 times (569µs+6.94ms) by Class::MOP::Class::find_all_methods_by_name at line 1165 of Class/MOP/Class.pm, avg 38µs/call # 146 times (570µs+1.64ms) by Moose::Meta::Attribute::_process_accessors at line 1048 of Moose/Meta/Attribute.pm, avg 15µs/call # 58 times (241µs+1.38ms) by Class::MOP::Class::_inline_constructor at line 1436 of Class/MOP/Class.pm, avg 28µs/call # 42 times (151µs+829µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 105 of Moose/Meta/Role/Application/RoleSummation.pm, avg 23µs/call # 39 times (82µs+449µs) by Moose::Meta::Role::add_override_method_modifier at line 363 of Moose/Meta/Role.pm, avg 14µs/call # 36 times (100µs+415µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 133 of Moose/Meta/Role/Application/ToRole.pm, avg 14µs/call # 28 times (105µs+416µs) by Class::MOP::Class::_inline_destructor at line 1480 of Class/MOP/Class.pm, avg 19µs/call # 24 times (78µs+3.66ms) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 183 of Moose/Meta/Role/Application/ToClass.pm, avg 156µs/call
sub has_method {
94569186µs my ( $self, $method_name ) = @_;
95
96569198µs ( defined $method_name && length $method_name )
97 || $self->_throw_exception( MustDefineAMethodName => instance => $self );
98
99569394µs56915.6ms my $method = $self->_get_maybe_raw_method($method_name);
# spent 15.6ms making 569 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 27µs/call
100569892µs1113µs return if not $method;
# spent 13µs making 11 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 1µs/call
101
1021346µs1389µs return defined($self->_method_map->{$method_name} = $method);
# spent 86µs making 10 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::_method_map, avg 9µs/call # spent 3µs making 3 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 933ns/call
103}
104
105
# spent 89.6ms (28.2+61.3) within Class::MOP::Mixin::HasMethods::get_method which was called 2438 times, avg 37µs/call: # 566 times (5.51ms+18.5ms) by Class::MOP::Class::find_method_by_name at line 1133 of Class/MOP/Class.pm, avg 42µs/call # 431 times (16.3ms+15.7ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 220, avg 74µs/call # 290 times (758µs+3.95ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 143 of Moose/Meta/Role/Application/ToClass.pm, avg 16µs/call # 275 times (1.78ms+5.00ms) by Class::MOP::Class::find_next_method_by_name at line 1181 of Class/MOP/Class.pm, avg 25µs/call # 229 times (639µs+7.99ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 85 of Moose/Meta/Role/Application/ToRole.pm, avg 38µs/call # 221 times (1.64ms+1.22ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 160 of Moose/Meta/Role/Application/RoleSummation.pm, avg 13µs/call # 146 times (534µs+3.09ms) by Moose::Meta::Attribute::_process_accessors at line 1021 of Moose/Meta/Attribute.pm, avg 25µs/call # 66 times (171µs+838µs) by Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Class.pm:1082] at line 1055 of Class/MOP/Class.pm, avg 15µs/call # 57 times (216µs+1.50ms) by Moose::Meta::Role::find_method_by_name at line 436 of Moose/Meta/Role.pm, avg 30µs/call # 56 times (224µs+955µs) by Moose::Meta::Attribute::install_delegation at line 1084 of Moose/Meta/Attribute.pm, avg 21µs/call # 35 times (159µs+1.39ms) by Moose::Role::init_meta at line 151 of Moose/Role.pm, avg 44µs/call # 28 times (116µs+559µs) by Moose::init_meta at line 211 of Moose.pm, avg 24µs/call # 25 times (56µs+302µs) by Moose::Meta::Class::add_override_method_modifier at line 585 of Moose/Meta/Class.pm, avg 14µs/call # 12 times (95µs+211µs) by Class::MOP::Class::find_all_methods_by_name at line 1165 of Class/MOP/Class.pm, avg 26µs/call # once (11µs+55µs) by Class::MOP::Attribute::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Attribute.pm:478] at line 475 of Class/MOP/Attribute.pm
sub get_method {
1062438655µs my ( $self, $method_name ) = @_;
107
1082438612µs ( defined $method_name && length $method_name )
109 || $self->_throw_exception( MustDefineAMethodName => instance => $self );
110
11124381.62ms243852.4ms my $method = $self->_get_maybe_raw_method($method_name);
# spent 52.4ms making 2438 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 21µs/call
11224383.06ms776515µs return if not $method;
# spent 515µs making 776 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 664ns/call
113
11499713.4ms17731.06ms return $method if blessed($method) && $method->isa('Class::MOP::Method');
# spent 621µs making 997 calls to Scalar::Util::blessed, avg 623ns/call # spent 436µs making 776 calls to UNIVERSAL::isa, avg 562ns/call
115
1162211.25ms4427.36ms return $self->_method_map->{$method_name} = $self->wrap_method_body(
# spent 6.86ms making 221 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 31µs/call # spent 287µs making 197 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call # spent 199µs making 23 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 9µs/call # spent 9µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::_method_map
117 body => $method,
118 name => $method_name,
119 associated_metaclass => $self,
120 );
121}
122
123
# spent 68.0ms (26.2+41.9) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 3007 times, avg 23µs/call: # 2438 times (20.6ms+31.9ms) by Class::MOP::Mixin::HasMethods::get_method at line 111, avg 21µs/call # 569 times (5.61ms+10.0ms) by Class::MOP::Mixin::HasMethods::has_method at line 99, avg 27µs/call
sub _get_maybe_raw_method {
1243007576µs my ( $self, $method_name ) = @_;
125
126300717.3ms380214.2ms my $map_entry = $self->_method_map->{$method_name};
# spent 5.86ms making 2638 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call # spent 5.32ms making 92 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::_method_map, avg 58µs/call # spent 2.76ms making 277 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 10µs/call # spent 291µs making 795 calls to Class::MOP::Method::body, avg 366ns/call
12730071.50ms return $map_entry if defined $map_entry;
128
12922182.52ms221822.1ms my $code = $self->get_package_symbol("&$method_name");
# spent 22.1ms making 2218 calls to Class::MOP::Package::get_package_symbol, avg 10µs/call
130
13122186.78ms2965.85ms return unless $code && $self->_code_is_mine($code);
# spent 5.85ms making 296 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 20µs/call
132
133221318µs return $code;
134}
135
136
# spent 64µs (39+25) within Class::MOP::Mixin::HasMethods::remove_method which was called: # once (39µs+25µs) by Class::MOP::Attribute::__ANON__[/usr/local/lib/perl/5.18.2/Class/MOP/Attribute.pm:478] at line 476 of Class/MOP/Attribute.pm
sub remove_method {
1371500ns my ( $self, $method_name ) = @_;
138
1391500ns ( defined $method_name && length $method_name )
140 || $self->_throw_exception( MustDefineAMethodName => instance => $self );
141
14215µs11µs my $removed_method = delete $self->_method_map->{$method_name};
# spent 1µs making 1 call to Class::MOP::Mixin::HasMethods::_method_map
143
144117µs115µs $self->remove_package_symbol("&$method_name");
# spent 15µs making 1 call to Class::MOP::Package::remove_package_symbol
145
146111µs34µs $removed_method->detach_from_class
# spent 2µs making 1 call to Class::MOP::Method::detach_from_class # spent 700ns making 1 call to Scalar::Util::blessed # spent 400ns making 1 call to UNIVERSAL::isa
147 if blessed($removed_method) && $removed_method->isa('Class::MOP::Method');
148
149 # still valid, since we just removed the method from the map
15011µs15µs $self->update_package_cache_flag;
151
15213µs return $removed_method;
153}
154
155sub get_method_list {
156 my $self = shift;
157
158 return keys %{ $self->_full_method_map };
159}
160
161
# spent 38.9ms (422µs+38.5) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 107 times, avg 363µs/call: # 69 times (246µs+8.92ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 171 of Moose/Meta/Role/Application/RoleSummation.pm, avg 133µs/call # 15 times (60µs+1.99ms) by Class::MOP::Class::get_all_methods at line 1146 of Class/MOP/Class.pm, avg 137µs/call # 14 times (68µs+16.2ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 136 of Moose/Meta/Role/Application/ToClass.pm, avg 1.16ms/call # 9 times (48µs+11.4ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 77 of Moose/Meta/Role/Application/ToRole.pm, avg 1.27ms/call
sub _get_local_methods {
16210729µs my $self = shift;
163
164107408µs10738.5ms return values %{ $self->_full_method_map };
# spent 38.5ms making 107 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 359µs/call
165}
166
167sub _restore_metamethods_from {
168 my $self = shift;
169 my ($old_meta) = @_;
170
171 my $package_name = $self->name;
172
173 # Check if Perl debugger is enabled
174 my $debugger_enabled = ($^P & 0x10);
175 my $debug_method_info;
176
177 for my $method ($old_meta->_get_local_methods) {
178 my $method_name = $method->name;
179
180 # Track DB::sub information for this method if debugger is enabled.
181 # This contains original method filename and line numbers.
182 $debug_method_info = '';
183 if ($debugger_enabled) {
184 $debug_method_info = $DB::sub{$package_name . "::" . $method_name}
185 }
186
187 $method->_make_compatible_with($self->method_metaclass);
188 $self->add_method($method_name => $method);
189
190 # Restore method debug information, which can be clobbered by add_method.
191 # Note that we handle this here instead of in add_method, because we
192 # only want to preserve the original debug info in cases where we are
193 # restoring a method, not overwriting a method.
194 if ($debugger_enabled && $debug_method_info) {
195 $DB::sub{$package_name . "::" . $method_name} = $debug_method_info;
196 }
197 }
198}
199
2004295µs
# spent 65µs within Class::MOP::Mixin::HasMethods::reset_package_cache_flag which was called 42 times, avg 2µs/call: # 28 times (43µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 176 of Moose/Meta/Role/Application/ToClass.pm, avg 2µs/call # 14 times (22µs+0s) by Moose::Meta::Role::add_role at line 409 of Moose/Meta/Role.pm, avg 2µs/call
sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
201
# spent 6.74ms (4.88+1.86) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 1264 times, avg 5µs/call: # 1263 times (4.87ms+1.86ms) by Class::MOP::Mixin::HasMethods::add_method at line 81, avg 5µs/call # once (4µs+2µs) by Class::MOP::Mixin::HasMethods::remove_method at line 150
sub update_package_cache_flag {
2021264245µs my $self = shift;
203 # NOTE:
204 # we can manually update the cache number
205 # since we are actually adding the method
206 # to our cache as well. This avoids us
207 # having to regenerate the method_map.
208 # - SL
20912647.30ms25281.86ms $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
# spent 1.39ms making 1264 calls to mro::get_pkg_gen, avg 1µs/call # spent 468µs making 1264 calls to Class::MOP::Package::name, avg 370ns/call
210}
211
212
# spent 38.5ms (5.59+32.9) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 107 times, avg 359µs/call: # 107 times (5.59ms+32.9ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 164, avg 359µs/call
sub _full_method_map {
21310721µs my $self = shift;
214
2151074.52ms214174µs my $pkg_gen = Class::MOP::check_package_cache_flag($self->name);
# spent 137µs making 107 calls to mro::get_pkg_gen, avg 1µs/call # spent 36µs making 107 calls to Class::MOP::Package::name, avg 341ns/call
216
21710787µs if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) {
218 # forcibly reify all method map entries
219 $self->get_method($_)
22040484µs47132.5ms for $self->list_all_package_symbols('CODE');
# spent 32.1ms making 431 calls to Class::MOP::Mixin::HasMethods::get_method, avg 74µs/call # spent 486µs making 40 calls to Class::MOP::Package::list_all_package_symbols, avg 12µs/call
2214030µs $self->{_package_cache_flag_full} = $pkg_gen;
222 }
223
224107506µs107139µs return $self->_method_map;
# spent 139µs making 107 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call
225}
226
22712µs1;
228
229# ABSTRACT: Methods for metaclasses which have methods
230
231__END__
 
# spent 1.37ms within Class::MOP::Mixin::HasMethods::CORE:match which was called 1263 times, avg 1µs/call: # 1263 times (1.37ms+0s) by Class::MOP::Mixin::HasMethods::add_method at line 75, avg 1µs/call
sub Class::MOP::Mixin::HasMethods::CORE:match; # opcode