Filename | /usr/local/lib/perl/5.14.2/Class/MOP/Mixin/HasMethods.pm |
Statements | Executed 17358 statements in 37.0ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
501 | 21 | 8 | 11.5ms | 31.1ms | add_method | Class::MOP::Mixin::HasMethods::
1095 | 2 | 1 | 5.50ms | 16.9ms | _get_maybe_raw_method | Class::MOP::Mixin::HasMethods::
824 | 8 | 4 | 3.54ms | 21.1ms | get_method | Class::MOP::Mixin::HasMethods::
501 | 1 | 1 | 2.23ms | 3.18ms | update_package_cache_flag | Class::MOP::Mixin::HasMethods::
271 | 5 | 3 | 1.29ms | 4.11ms | has_method | Class::MOP::Mixin::HasMethods::
171 | 1 | 1 | 860µs | 1.10ms | _code_is_mine | Class::MOP::Mixin::HasMethods::
84 | 1 | 1 | 821µs | 2.84ms | wrap_method_body | Class::MOP::Mixin::HasMethods::
501 | 1 | 1 | 801µs | 801µs | CORE:match (opcode) | Class::MOP::Mixin::HasMethods::
35 | 5 | 4 | 516µs | 14.0ms | _add_meta_method | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 467µs | 2.17ms | BEGIN@12 | Class::MOP::Mixin::HasMethods::
20 | 1 | 1 | 420µs | 5.87ms | _full_method_map | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 332µs | 446µs | BEGIN@13 | Class::MOP::Mixin::HasMethods::
20 | 1 | 1 | 93µs | 5.97ms | _get_local_methods | Class::MOP::Mixin::HasMethods::
25 | 2 | 1 | 25µs | 25µs | _meta_method_class | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 9µs | 37µs | BEGIN@17 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 8µs | 38µs | BEGIN@15 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 7µs | 10µs | BEGIN@9 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 7µs | 15µs | BEGIN@10 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 7µs | 29µs | BEGIN@16 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 6µs | 45µs | BEGIN@21 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 4µs | 4µs | BEGIN@19 | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | _get_overloaded_operator_body | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | _overload_map | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | _restore_metamethods_from | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | _wrap_overload | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | add_overloaded_operator | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | get_all_overloaded_operators | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | get_method_list | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | get_overload_list | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | get_overloaded_operator | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | has_overloaded_operator | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | is_overloaded | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | overload_operators | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | remove_method | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | remove_overloaded_operator | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | reset_package_cache_flag | Class::MOP::Mixin::HasMethods::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Class::MOP::Mixin::HasMethods; | ||||
2 | # spent 8µs within Class::MOP::Mixin::HasMethods::BEGIN@2 which was called:
# once (8µs+0s) by Class::MOP::BEGIN@25 at line 4 | ||||
3 | 1 | 5µs | $Class::MOP::Mixin::HasMethods::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 28µs | 1 | 8µs | } # spent 8µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@2 |
5 | { | ||||
6 | 2 | 1µs | $Class::MOP::Mixin::HasMethods::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 21µs | 2 | 13µs | # spent 10µs (7+3) within Class::MOP::Mixin::HasMethods::BEGIN@9 which was called:
# once (7µs+3µs) by Class::MOP::BEGIN@25 at line 9 # spent 10µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@9
# spent 3µs making 1 call to strict::import |
10 | 2 | 22µs | 2 | 23µs | # spent 15µs (7+8) within Class::MOP::Mixin::HasMethods::BEGIN@10 which was called:
# once (7µs+8µs) by Class::MOP::BEGIN@25 at line 10 # spent 15µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@10
# spent 8µs making 1 call to warnings::import |
11 | |||||
12 | 2 | 90µs | 1 | 2.17ms | # spent 2.17ms (467µs+1.70) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called:
# once (467µs+1.70ms) by Class::MOP::BEGIN@25 at line 12 # spent 2.17ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12 |
13 | 2 | 100µs | 1 | 446µs | # spent 446µs (332+114) within Class::MOP::Mixin::HasMethods::BEGIN@13 which was called:
# once (332µs+114µs) by Class::MOP::BEGIN@25 at line 13 # spent 446µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@13 |
14 | |||||
15 | 2 | 25µs | 2 | 69µs | # spent 38µs (8+31) within Class::MOP::Mixin::HasMethods::BEGIN@15 which was called:
# once (8µs+31µs) by Class::MOP::BEGIN@25 at line 15 # spent 38µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@15
# spent 31µs making 1 call to Exporter::import |
16 | 2 | 23µs | 2 | 52µs | # spent 29µs (7+23) within Class::MOP::Mixin::HasMethods::BEGIN@16 which was called:
# once (7µs+23µs) by Class::MOP::BEGIN@25 at line 16 # spent 29µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@16
# spent 23µs making 1 call to Exporter::import |
17 | 2 | 25µs | 2 | 65µs | # spent 37µs (9+28) within Class::MOP::Mixin::HasMethods::BEGIN@17 which was called:
# once (9µs+28µs) by Class::MOP::BEGIN@25 at line 17 # spent 37µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@17
# spent 28µs making 1 call to Exporter::import |
18 | |||||
19 | 2 | 20µs | 1 | 4µs | # spent 4µs within Class::MOP::Mixin::HasMethods::BEGIN@19 which was called:
# once (4µs+0s) by Class::MOP::BEGIN@25 at line 19 # spent 4µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@19 |
20 | |||||
21 | 2 | 1.20ms | 2 | 84µs | # spent 45µs (6+39) within Class::MOP::Mixin::HasMethods::BEGIN@21 which was called:
# once (6µs+39µs) by Class::MOP::BEGIN@25 at line 21 # spent 45µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@21
# spent 39µs making 1 call to base::import |
22 | |||||
23 | 25 | 45µs | # spent 25µs within Class::MOP::Mixin::HasMethods::_meta_method_class which was called 25 times, avg 988ns/call:
# 23 times (22µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 970ns/call
# 2 times (2µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 31, avg 1µs/call | ||
24 | |||||
25 | # spent 14.0ms (516µs+13.4) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 35 times, avg 399µs/call:
# 20 times (255µs+7.05ms) by metaclass::import at line 49 of metaclass.pm, avg 365µs/call
# 11 times (138µs+4.21ms) by Moose::init_meta at line 217 of Moose.pm, avg 395µs/call
# 2 times (33µs+809µs) by Class::MOP::Class::create at line 448 of Class/MOP/Class.pm, avg 421µs/call
# once (64µs+935µs) by Moose::Exporter::BEGIN@13 at line 660 of Class/MOP.pm
# once (25µs+440µs) by Moose::Exporter::BEGIN@13 at line 666 of Class/MOP.pm | ||||
26 | 175 | 492µs | my $self = shift; | ||
27 | my ($name) = @_; | ||||
28 | 70 | 2.74ms | my $existing_method = $self->can('find_method_by_name') # spent 2.70ms making 35 calls to Class::MOP::Class::find_method_by_name, avg 77µs/call
# spent 35µs making 35 calls to UNIVERSAL::can, avg 1µs/call | ||
29 | ? $self->find_method_by_name($name) | ||||
30 | : $self->get_method($name); | ||||
31 | 4 | 5µs | return if $existing_method # spent 3µ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 | ||
32 | && $existing_method->isa($self->_meta_method_class); | ||||
33 | 140 | 10.7ms | $self->add_method( # spent 4.80ms making 23 calls to Class::MOP::Method::Meta::wrap, avg 209µs/call
# spent 3.62ms making 12 calls to Moose::Meta::Method::Meta::wrap, avg 302µs/call
# spent 2.23ms making 35 calls to Class::MOP::Mixin::HasMethods::add_method, avg 64µs/call
# spent 22µs making 23 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 970ns/call
# spent 21µs making 35 calls to Class::MOP::Package::name, avg 609ns/call
# spent 12µs making 12 calls to Moose::Meta::Class::_meta_method_class, avg 967ns/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 2.84ms (821µs+2.01) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 84 times, avg 34µs/call:
# 84 times (821µs+2.01ms) by Class::MOP::Mixin::HasMethods::get_method at line 124, avg 34µs/call | ||||
43 | 252 | 950µs | my ( $self, %args ) = @_; | ||
44 | |||||
45 | 84 | 48µs | ( 'CODE' eq reftype $args{body} ) # spent 48µs making 84 calls to Scalar::Util::reftype, avg 569ns/call | ||
46 | || confess "Your code block must be a CODE reference"; | ||||
47 | |||||
48 | 252 | 1.97ms | $self->method_metaclass->wrap( # spent 1.89ms making 84 calls to Class::MOP::Method::wrap, avg 22µs/call
# spent 46µs making 84 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 552ns/call
# spent 36µs making 84 calls to Class::MOP::Package::name, avg 423ns/call | ||
49 | package_name => $self->name, | ||||
50 | %args, | ||||
51 | ); | ||||
52 | } | ||||
53 | |||||
54 | # spent 31.1ms (11.5+19.6) within Class::MOP::Mixin::HasMethods::add_method which was called 501 times, avg 62µs/call:
# 180 times (4.24ms+7.23ms) by Class::MOP::Attribute::install_accessors at line 428 of Class/MOP/Attribute.pm, avg 64µs/call
# 75 times (1.75ms+3.12ms) by Class::MOP::Attribute::install_accessors at line 424 of Class/MOP/Attribute.pm, avg 65µs/call
# 46 times (1.03ms+1.73ms) by Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.14.2/Class/MOP/Class.pm:1072] at line 1070 of Class/MOP/Class.pm, avg 60µs/call
# 44 times (979µs+1.67ms) by Class::MOP::Attribute::install_accessors at line 436 of Class/MOP/Attribute.pm, avg 60µs/call
# 36 times (806µs+1.28ms) by Moose::Meta::Attribute::install_delegation at line 1125 of Moose/Meta/Attribute.pm, avg 58µs/call
# 35 times (844µs+1.39ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 64µs/call
# 35 times (817µs+1.40ms) by Class::MOP::Class::_inline_constructor at line 1452 of Class/MOP/Class.pm, avg 63µs/call
# 14 times (342µs+631µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 70µs/call
# 8 times (182µs+326µs) by Class::MOP::Attribute::install_accessors at line 432 of Class/MOP/Attribute.pm, avg 64µs/call
# 7 times (117µs+220µs) by Moose::BEGIN@46 at line 30 of Moose/Meta/Attribute/Native.pm, avg 48µs/call
# 3 times (73µs+116µs) by Class::MOP::Class::_inline_destructor at line 1490 of Class/MOP/Class.pm, avg 63µs/call
# 3 times (49µs+86µs) by Moose::BEGIN@35 at line 318 of Moose/Meta/Role.pm, avg 45µs/call
# 3 times (47µs+82µs) by Moose::BEGIN@35 at line 345 of Moose/Meta/Role.pm, avg 43µs/call
# 3 times (46µs+80µs) by Moose::BEGIN@35 at line 326 of Moose/Meta/Role.pm, avg 42µs/call
# 2 times (47µs+80µs) by Class::MOP::Attribute::install_accessors at line 440 of Class/MOP/Attribute.pm, avg 64µs/call
# 2 times (31µs+53µs) by Moose::BEGIN@35 at line 119 of Moose/Meta/Role.pm, avg 42µs/call
# once (17µs+33µs) by Moose::Exporter::BEGIN@13 at line 486 of Class/MOP.pm
# once (17µs+29µs) by Moose::BEGIN@35 at line 99 of Moose/Meta/Role.pm
# once (17µs+28µs) by Moose::BEGIN@35 at line 109 of Moose/Meta/Role.pm
# once (15µs+29µs) by Moose::BEGIN@35 at line 124 of Moose/Meta/Role.pm
# once (16µs+27µs) by Moose::BEGIN@35 at line 104 of Moose/Meta/Role.pm | ||||
55 | 5010 | 14.2ms | my ( $self, $method_name, $method ) = @_; | ||
56 | ( defined $method_name && length $method_name ) | ||||
57 | || confess "You must define a method name"; | ||||
58 | |||||
59 | 501 | 382µs | my $package_name = $self->name; # spent 382µs making 501 calls to Class::MOP::Package::name, avg 763ns/call | ||
60 | |||||
61 | my $body; | ||||
62 | 1457 | 2.50ms | 979 | 729µs | if ( blessed($method) && $method->isa('Class::MOP::Method') ) { # spent 371µs making 478 calls to UNIVERSAL::isa, avg 776ns/call
# spent 358µs making 501 calls to Scalar::Util::blessed, avg 714ns/call |
63 | 478 | 254µs | $body = $method->body; # spent 254µs making 478 calls to Class::MOP::Method::body, avg 532ns/call | ||
64 | 14 | 15µs | 478 | 233µs | if ( $method->package_name ne $package_name ) { # spent 233µs making 478 calls to Class::MOP::Method::package_name, avg 488ns/call |
65 | 14 | 166µs | $method = $method->clone( # spent 166µs making 14 calls to Class::MOP::Method::clone, avg 12µs/call | ||
66 | package_name => $package_name, | ||||
67 | name => $method_name, | ||||
68 | ); | ||||
69 | } | ||||
70 | |||||
71 | 478 | 1.96ms | $method->attach_to_class($self); # spent 1.96ms making 478 calls to Class::MOP::Method::attach_to_class, avg 4µ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 | $body = $method; | ||||
77 | } | ||||
78 | |||||
79 | 524 | 1.32ms | $self->_method_map->{$method_name} = $method; # spent 1.30ms making 501 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 3µs/call
# spent 12µs making 23 calls to Class::MOP::Method::body, avg 500ns/call | ||
80 | |||||
81 | 501 | 574µs | my ($current_package, $current_name) = Class::MOP::get_code_info($body); # spent 574µs making 501 calls to Class::MOP::get_code_info, avg 1µs/call | ||
82 | |||||
83 | 932 | 2.24ms | subname($package_name . '::' . $method_name, $body) # spent 1.44ms making 431 calls to Sub::Name::subname, avg 3µs/call
# spent 801µs making 501 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 2µs/call | ||
84 | unless defined $current_name && $current_name !~ /^__ANON__/; | ||||
85 | |||||
86 | 501 | 8.62ms | $self->add_package_symbol("&$method_name", $body); # spent 8.62ms making 501 calls to Class::MOP::Package::add_package_symbol, avg 17µs/call | ||
87 | |||||
88 | # we added the method to the method map too, so it's still valid | ||||
89 | 501 | 3.18ms | $self->update_package_cache_flag; # spent 3.18ms making 501 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 6µs/call | ||
90 | } | ||||
91 | |||||
92 | # spent 1.10ms (860µs+237µs) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 171 times, avg 6µs/call:
# 171 times (860µs+237µs) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 139, avg 6µs/call | ||||
93 | 513 | 1.21ms | my ( $self, $code ) = @_; | ||
94 | |||||
95 | 171 | 148µs | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); # spent 148µs making 171 calls to Class::MOP::get_code_info, avg 863ns/call | ||
96 | |||||
97 | 171 | 89µs | return ( $code_package && $code_package eq $self->name ) # spent 89µs making 171 calls to Class::MOP::Package::name, avg 523ns/call | ||
98 | || ( $code_package eq 'constant' && $code_name eq '__ANON__' ); | ||||
99 | } | ||||
100 | |||||
101 | # spent 4.11ms (1.29+2.82) within Class::MOP::Mixin::HasMethods::has_method which was called 271 times, avg 15µs/call:
# 145 times (866µs+892µs) by Moose::Meta::Class::_inline_create_error at line 850 of Moose/Meta/Class.pm, avg 12µs/call
# 64 times (216µs+859µs) by Moose::Meta::Attribute::_process_accessors at line 1070 of Moose/Meta/Attribute.pm, avg 17µs/call
# 35 times (122µs+649µs) by Class::MOP::Class::_inline_constructor at line 1424 of Class/MOP/Class.pm, avg 22µs/call
# 24 times (77µs+367µs) by Class::MOP::Class::find_all_methods_by_name at line 1155 of Class/MOP/Class.pm, avg 19µs/call
# 3 times (11µs+49µs) by Class::MOP::Class::_inline_destructor at line 1464 of Class/MOP/Class.pm, avg 20µs/call | ||||
102 | 960 | 1.35ms | my ( $self, $method_name ) = @_; | ||
103 | |||||
104 | ( defined $method_name && length $method_name ) | ||||
105 | || confess "You must define a method name"; | ||||
106 | |||||
107 | 271 | 2.67ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 2.67ms making 271 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 10µs/call | ||
108 | or return; | ||||
109 | |||||
110 | 147 | 149µs | return defined($self->_method_map->{$method_name} = $method); # spent 149µs making 147 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call | ||
111 | } | ||||
112 | |||||
113 | # spent 21.1ms (3.54+17.6) within Class::MOP::Mixin::HasMethods::get_method which was called 824 times, avg 26µs/call:
# 367 times (1.43ms+7.35ms) by Class::MOP::Class::find_method_by_name at line 1123 of Class/MOP/Class.pm, avg 24µs/call
# 158 times (792µs+2.67ms) by Class::MOP::Class::find_next_method_by_name at line 1171 of Class/MOP/Class.pm, avg 22µs/call
# 130 times (761µs+4.54ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 205, avg 41µs/call
# 64 times (231µs+1.34ms) by Moose::Meta::Attribute::_process_accessors at line 1043 of Moose/Meta/Attribute.pm, avg 25µs/call
# 47 times (155µs+708µs) by Moose::Meta::Attribute::install_delegation at line 1106 of Moose/Meta/Attribute.pm, avg 18µs/call
# 46 times (125µs+693µs) by Class::MOP::Class::__ANON__[/usr/local/lib/perl/5.14.2/Class/MOP/Class.pm:1072] at line 1047 of Class/MOP/Class.pm, avg 18µs/call
# 11 times (42µs+209µs) by Moose::init_meta at line 207 of Moose.pm, avg 23µs/call
# once (9µs+44µs) by Class::MOP::Class::find_all_methods_by_name at line 1155 of Class/MOP/Class.pm | ||||
114 | 2773 | 3.71ms | my ( $self, $method_name ) = @_; | ||
115 | |||||
116 | ( defined $method_name && length $method_name ) | ||||
117 | || confess "You must define a method name"; | ||||
118 | |||||
119 | 824 | 14.2ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 14.2ms making 824 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 17µs/call | ||
120 | or return; | ||||
121 | |||||
122 | 350 | 278µs | return $method if blessed($method) && $method->isa('Class::MOP::Method'); # spent 178µs making 217 calls to Scalar::Util::blessed, avg 820ns/call
# spent 100µs making 133 calls to UNIVERSAL::isa, avg 751ns/call | ||
123 | |||||
124 | 168 | 3.10ms | return $self->_method_map->{$method_name} = $self->wrap_method_body( # spent 2.84ms making 84 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 34µs/call
# spent 91µs making 14 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::_method_map, avg 6µs/call
# spent 86µs making 13 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 7µs/call
# spent 84µs making 57 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call | ||
125 | body => $method, | ||||
126 | name => $method_name, | ||||
127 | associated_metaclass => $self, | ||||
128 | ); | ||||
129 | } | ||||
130 | |||||
131 | # spent 16.9ms (5.50+11.4) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 1095 times, avg 15µs/call:
# 824 times (4.32ms+9.86ms) by Class::MOP::Mixin::HasMethods::get_method at line 119, avg 17µs/call
# 271 times (1.18ms+1.49ms) by Class::MOP::Mixin::HasMethods::has_method at line 107, avg 10µs/call | ||||
132 | 5002 | 7.08ms | my ( $self, $method_name ) = @_; | ||
133 | |||||
134 | 1112 | 3.42ms | my $map_entry = $self->_method_map->{$method_name}; # spent 1.48ms making 228 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 6µs/call
# spent 1.46ms making 782 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call
# spent 472µs making 85 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::_method_map, avg 6µs/call
# spent 12µs making 17 calls to Class::MOP::Method::body, avg 682ns/call | ||
135 | return $map_entry if defined $map_entry; | ||||
136 | |||||
137 | 816 | 6.85ms | my $code = $self->get_package_symbol("&$method_name"); # spent 6.85ms making 816 calls to Class::MOP::Package::get_package_symbol, avg 8µs/call | ||
138 | |||||
139 | 171 | 1.10ms | return unless $code && $self->_code_is_mine($code); # spent 1.10ms making 171 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 6µs/call | ||
140 | |||||
141 | 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 | sub get_method_list { | ||||
164 | my $self = shift; | ||||
165 | |||||
166 | return keys %{ $self->_full_method_map }; | ||||
167 | } | ||||
168 | |||||
169 | # spent 5.97ms (93µs+5.87) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 20 times, avg 298µs/call:
# 20 times (93µs+5.87ms) by Class::MOP::Class::get_all_methods at line 1136 of Class/MOP/Class.pm, avg 298µs/call | ||||
170 | 40 | 55µs | my $self = shift; | ||
171 | |||||
172 | 20 | 28µs | 20 | 5.87ms | return values %{ $self->_full_method_map }; # spent 5.87ms making 20 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 294µ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 | sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef } | ||||
186 | # spent 3.18ms (2.23+951µs) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 501 times, avg 6µs/call:
# 501 times (2.23ms+951µs) by Class::MOP::Mixin::HasMethods::add_method at line 89, avg 6µs/call | ||||
187 | 1002 | 3.44ms | 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 | 1002 | 950µs | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); # spent 655µs making 501 calls to mro::get_pkg_gen, avg 1µs/call
# spent 296µs making 501 calls to Class::MOP::Package::name, avg 590ns/call | ||
195 | } | ||||
196 | |||||
197 | # spent 5.87ms (420µs+5.45) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 20 times, avg 294µs/call:
# 20 times (420µs+5.45ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 172, avg 294µs/call | ||||
198 | 80 | 207µs | my $self = shift; | ||
199 | |||||
200 | 40 | 32µs | my $pkg_gen = Class::MOP::check_package_cache_flag($self->name); # spent 22µs making 20 calls to mro::get_pkg_gen, avg 1µs/call
# spent 10µs making 20 calls to Class::MOP::Package::name, avg 520ns/call | ||
201 | |||||
202 | 12 | 200µs | if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) { | ||
203 | # forcibly reify all method map entries | ||||
204 | $self->get_method($_) | ||||
205 | 136 | 5.39ms | for $self->list_all_package_symbols('CODE'); # spent 5.30ms making 130 calls to Class::MOP::Mixin::HasMethods::get_method, avg 41µs/call
# spent 91µs making 6 calls to Class::MOP::Package::list_all_package_symbols, avg 15µs/call | ||
206 | $self->{_package_cache_flag_full} = $pkg_gen; | ||||
207 | } | ||||
208 | |||||
209 | 20 | 29µs | return $self->_method_map; # spent 24µs making 19 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call
# spent 6µs making 1 call to Class::MOP::Class::Immutable::Moose::Meta::Class::_method_map | ||
210 | } | ||||
211 | |||||
212 | # overloading | ||||
213 | |||||
214 | 1 | 200ns | 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 801µs within Class::MOP::Mixin::HasMethods::CORE:match which was called 501 times, avg 2µs/call:
# 501 times (801µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 83, avg 2µs/call |