Profile of Class/MOP/Mixin/HasMethods.pm

← 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
Statements | Executed 48684 statements in 121ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1263 | 24 | 11 | 36.8ms | 90.9ms | Class::MOP::Mixin::HasMethods::::add_methodClass::MOP::Mixin::HasMethods::add_method
2438 | 15 | 11 | 28.2ms | 89.6ms | Class::MOP::Mixin::HasMethods::::get_methodClass::MOP::Mixin::HasMethods::get_method
3007 | 2 | 1 | 26.2ms | 68.0ms | Class::MOP::Mixin::HasMethods::::_get_maybe_raw_methodClass::MOP::Mixin::HasMethods::_get_maybe_raw_method
97 | 6 | 5 | 6.54ms | 47.0ms | Class::MOP::Mixin::HasMethods::::_add_meta_methodClass::MOP::Mixin::HasMethods::_add_meta_method
107 | 1 | 1 | 5.59ms | 38.5ms | Class::MOP::Mixin::HasMethods::::_full_method_mapClass::MOP::Mixin::HasMethods::_full_method_map
296 | 1 | 1 | 5.54ms | 5.85ms | Class::MOP::Mixin::HasMethods::::_code_is_mineClass::MOP::Mixin::HasMethods::_code_is_mine
1264 | 2 | 1 | 4.88ms | 6.74ms | Class::MOP::Mixin::HasMethods::::update_package_cache_flagClass::MOP::Mixin::HasMethods::update_package_cache_flag
221 | 1 | 1 | 1.97ms | 6.86ms | Class::MOP::Mixin::HasMethods::::wrap_method_bodyClass::MOP::Mixin::HasMethods::wrap_method_body
569 | 8 | 6 | 1.90ms | 17.6ms | Class::MOP::Mixin::HasMethods::::has_methodClass::MOP::Mixin::HasMethods::has_method
1263 | 1 | 1 | 1.37ms | 1.37ms | Class::MOP::Mixin::HasMethods::::CORE:matchClass::MOP::Mixin::HasMethods::CORE:match (opcode)
107 | 4 | 4 | 422µs | 38.9ms | Class::MOP::Mixin::HasMethods::::_get_local_methodsClass::MOP::Mixin::HasMethods::_get_local_methods
1 | 1 | 1 | 392µs | 2.40ms | Class::MOP::Mixin::HasMethods::::BEGIN@7Class::MOP::Mixin::HasMethods::BEGIN@7
42 | 2 | 2 | 65µs | 65µs | Class::MOP::Mixin::HasMethods::::reset_package_cache_flagClass::MOP::Mixin::HasMethods::reset_package_cache_flag
1 | 1 | 1 | 39µs | 64µs | Class::MOP::Mixin::HasMethods::::remove_methodClass::MOP::Mixin::HasMethods::remove_method
25 | 2 | 1 | 32µs | 32µs | Class::MOP::Mixin::HasMethods::::_meta_method_classClass::MOP::Mixin::HasMethods::_meta_method_class
1 | 1 | 1 | 9µs | 33µs | Class::MOP::Mixin::HasMethods::::BEGIN@10Class::MOP::Mixin::HasMethods::BEGIN@10
1 | 1 | 1 | 8µs | 18µs | Class::MOP::Mixin::HasMethods::::BEGIN@4Class::MOP::Mixin::HasMethods::BEGIN@4
1 | 1 | 1 | 7µs | 22µs | Class::MOP::Mixin::HasMethods::::BEGIN@12Class::MOP::Mixin::HasMethods::BEGIN@12
1 | 1 | 1 | 6µs | 31µs | Class::MOP::Mixin::HasMethods::::BEGIN@9Class::MOP::Mixin::HasMethods::BEGIN@9
1 | 1 | 1 | 6µs | 9µs | Class::MOP::Mixin::HasMethods::::BEGIN@5Class::MOP::Mixin::HasMethods::BEGIN@5
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::_restore_metamethods_fromClass::MOP::Mixin::HasMethods::_restore_metamethods_from
0 | 0 | 0 | 0s | 0s | Class::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
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Class::MOP::Mixin::HasMethods;
2 | 1 | 600ns |  |  | our $VERSION = '2.1604';
3 |  |  |  |  |
4 | 2 | 18µs | 2 | 27µ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
5 | 2 | 18µs | 2 | 12µ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 |  |  |  |  |
7 | 2 | 90µs | 1 | 2.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 |  |  |  |  |
9 | 2 | 22µs | 2 | 56µ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
10 | 2 | 26µs | 2 | 57µ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 |  |  |  |  |
12 | 2 | 738µs | 2 | 37µ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 |  |  |  |  |
14 | 25 | 57µ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 {
17 | 97 | 30µs |  |  | my $self = shift;
18 | 97 | 44µs |  |  | my ($name) = @_;
19 | 97 | 457µs | 194 | 4.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);
22 | 97 | 41µs | 6 | 6µ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);
24 | 97 | 872µs | 388 | 35.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 {
34 | 221 | 257µs |  |  | my ( $self, %args ) = @_;
35 |  |  |  |  |
36 | 221 | 518µs | 221 | 96µ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 |  |  |  |  | );
40 | 221 | 1.34ms | 663 | 4.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 {
47 | 1263 | 432µs |  |  | my ( $self, $method_name, $method ) = @_;
48 | 1263 | 404µs |  |  | ( defined $method_name && length $method_name )
49 |  |  |  |  | || $self->_throw_exception( MustDefineAMethodName => instance => $self );
50 |  |  |  |  |
51 | 1263 | 2.68ms | 1263 | 613µs | my $package_name = $self->name; # spent 613µs making 1263 calls to Class::MOP::Package::name, avg 486ns/call
52 |  |  |  |  |
53 | 1263 | 117µs |  |  | my $body;
54 | 1263 | 10.4ms | 2503 | 1.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
55 | 1240 | 6.74ms | 1240 | 558µs | $body = $method->body; # spent 558µs making 1240 calls to Class::MOP::Method::body, avg 450ns/call
56 | 1240 | 2.79ms | 1747 | 6.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 |  |  |  |  |
63 | 1240 | 1.29ms | 1240 | 4.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.
68 | 23 | 5µs |  |  | $body = $method;
69 |  |  |  |  | }
70 |  |  |  |  |
71 | 1263 | 5.14ms | 1286 | 2.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 |  |  |  |  |
73 | 1263 | 3.31ms | 1263 | 1.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 |  |  |  |  |
75 | 1263 | 6.32ms | 1950 | 2.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 |  |  |  |  |
78 | 1263 | 1.81ms | 1263 | 27.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
81 | 1263 | 3.61ms | 1263 | 6.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 {
85 | 296 | 93µs |  |  | my ( $self, $code ) = @_;
86 |  |  |  |  |
87 | 296 | 694µs | 296 | 207µ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 |  |  |  |  |
89 | 296 | 5.27ms | 296 | 107µ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 {
94 | 569 | 186µs |  |  | my ( $self, $method_name ) = @_;
95 |  |  |  |  |
96 | 569 | 198µs |  |  | ( defined $method_name && length $method_name )
97 |  |  |  |  | || $self->_throw_exception( MustDefineAMethodName => instance => $self );
98 |  |  |  |  |
99 | 569 | 394µs | 569 | 15.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
100 | 569 | 892µs | 11 | 13µ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 |  |  |  |  |
102 | 13 | 46µs | 13 | 89µ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 {
106 | 2438 | 655µs |  |  | my ( $self, $method_name ) = @_;
107 |  |  |  |  |
108 | 2438 | 612µs |  |  | ( defined $method_name && length $method_name )
109 |  |  |  |  | || $self->_throw_exception( MustDefineAMethodName => instance => $self );
110 |  |  |  |  |
111 | 2438 | 1.62ms | 2438 | 52.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
112 | 2438 | 3.06ms | 776 | 515µ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 |  |  |  |  |
114 | 997 | 13.4ms | 1773 | 1.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 |  |  |  |  |
116 | 221 | 1.25ms | 442 | 7.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 {
124 | 3007 | 576µs |  |  | my ( $self, $method_name ) = @_;
125 |  |  |  |  |
126 | 3007 | 17.3ms | 3802 | 14.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
127 | 3007 | 1.50ms |  |  | return $map_entry if defined $map_entry;
128 |  |  |  |  |
129 | 2218 | 2.52ms | 2218 | 22.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 |  |  |  |  |
131 | 2218 | 6.78ms | 296 | 5.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 |  |  |  |  |
133 | 221 | 318µ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 {
137 | 1 | 500ns |  |  | my ( $self, $method_name ) = @_;
138 |  |  |  |  |
139 | 1 | 500ns |  |  | ( defined $method_name && length $method_name )
140 |  |  |  |  | || $self->_throw_exception( MustDefineAMethodName => instance => $self );
141 |  |  |  |  |
142 | 1 | 5µs | 1 | 1µs | my $removed_method = delete $self->_method_map->{$method_name}; # spent 1µs making 1 call to Class::MOP::Mixin::HasMethods::_method_map
143 |  |  |  |  |
144 | 1 | 17µs | 1 | 15µs | $self->remove_package_symbol("&$method_name"); # spent 15µs making 1 call to Class::MOP::Package::remove_package_symbol
145 |  |  |  |  |
146 | 1 | 11µs | 3 | 4µ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
150 | 1 | 1µs | 1 | 5µs | $self->update_package_cache_flag; # spent 5µs making 1 call to Class::MOP::Mixin::HasMethods::update_package_cache_flag
151 |  |  |  |  |
152 | 1 | 3µs |  |  | return $removed_method;
153 |  |  |  |  | }
154 |  |  |  |  |
155 |  |  |  |  | sub 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 {
162 | 107 | 29µs |  |  | my $self = shift;
163 |  |  |  |  |
164 | 107 | 408µs | 107 | 38.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 |  |  |  |  |
167 |  |  |  |  | sub _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 |  |  |  |  |
200 | 42 | 95µ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 {
202 | 1264 | 245µ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
209 | 1264 | 7.30ms | 2528 | 1.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 {
213 | 107 | 21µs |  |  | my $self = shift;
214 |  |  |  |  |
215 | 107 | 4.52ms | 214 | 174µ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 |  |  |  |  |
217 | 107 | 87µs |  |  | if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) {
218 |  |  |  |  | # forcibly reify all method map entries
219 |  |  |  |  | $self->get_method($_)
220 | 40 | 484µs | 471 | 32.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
221 | 40 | 30µs |  |  | $self->{_package_cache_flag_full} = $pkg_gen;
222 |  |  |  |  | }
223 |  |  |  |  |
224 | 107 | 506µs | 107 | 139µs | return $self->_method_map; # spent 139µs making 107 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call
225 |  |  |  |  | }
226 |  |  |  |  |
227 | 1 | 2µs |  |  | 1;
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