Filename | /usr/local/lib/perl/5.14.2/Class/MOP/Mixin/HasMethods.pm |
Statements | Executed 17358 statements in 37.8ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
501 | 21 | 8 | 11.6ms | 31.6ms | add_method | Class::MOP::Mixin::HasMethods::
1095 | 2 | 1 | 5.64ms | 17.4ms | _get_maybe_raw_method | Class::MOP::Mixin::HasMethods::
824 | 8 | 4 | 3.65ms | 21.8ms | get_method | Class::MOP::Mixin::HasMethods::
501 | 1 | 1 | 2.19ms | 3.16ms | update_package_cache_flag | Class::MOP::Mixin::HasMethods::
271 | 5 | 3 | 1.34ms | 4.25ms | has_method | Class::MOP::Mixin::HasMethods::
171 | 1 | 1 | 885µs | 1.14ms | _code_is_mine | Class::MOP::Mixin::HasMethods::
84 | 1 | 1 | 855µs | 2.95ms | wrap_method_body | Class::MOP::Mixin::HasMethods::
501 | 1 | 1 | 792µs | 792µs | CORE:match (opcode) | Class::MOP::Mixin::HasMethods::
35 | 5 | 4 | 534µs | 14.3ms | _add_meta_method | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 476µs | 2.20ms | BEGIN@12 | Class::MOP::Mixin::HasMethods::
20 | 1 | 1 | 420µs | 6.04ms | _full_method_map | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 345µs | 494µs | BEGIN@13 | Class::MOP::Mixin::HasMethods::
20 | 1 | 1 | 90µs | 6.13ms | _get_local_methods | Class::MOP::Mixin::HasMethods::
25 | 2 | 1 | 25µs | 25µs | _meta_method_class | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 10µs | 39µs | BEGIN@17 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 9µs | 9µ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 | 16µs | BEGIN@10 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 7µs | 10µs | BEGIN@9 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 7µs | 28µ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 9µs within Class::MOP::Mixin::HasMethods::BEGIN@2 which was called:
# once (9µ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 | 9µs | } # spent 9µ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 | 21µs | 2 | 24µs | # spent 16µ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 16µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@10
# spent 8µs making 1 call to warnings::import |
11 | |||||
12 | 2 | 95µs | 1 | 2.20ms | # spent 2.20ms (476µs+1.73) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called:
# once (476µs+1.73ms) by Class::MOP::BEGIN@25 at line 12 # spent 2.20ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12 |
13 | 2 | 98µs | 1 | 494µs | # spent 494µs (345+148) within Class::MOP::Mixin::HasMethods::BEGIN@13 which was called:
# once (345µs+148µs) by Class::MOP::BEGIN@25 at line 13 # spent 494µ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 | 49µs | # spent 28µs (7+21) within Class::MOP::Mixin::HasMethods::BEGIN@16 which was called:
# once (7µs+21µs) by Class::MOP::BEGIN@25 at line 16 # spent 28µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@16
# spent 21µs making 1 call to Exporter::import |
17 | 2 | 26µs | 2 | 68µs | # spent 39µs (10+29) within Class::MOP::Mixin::HasMethods::BEGIN@17 which was called:
# once (10µs+29µs) by Class::MOP::BEGIN@25 at line 17 # spent 39µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@17
# spent 29µ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 | 85µ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 980ns/call:
# 23 times (22µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 965ns/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.3ms (534µs+13.8) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 35 times, avg 408µs/call:
# 20 times (260µs+7.21ms) by metaclass::import at line 49 of metaclass.pm, avg 374µs/call
# 11 times (148µs+4.34ms) by Moose::init_meta at line 217 of Moose.pm, avg 408µs/call
# 2 times (34µs+775µs) by Class::MOP::Class::create at line 448 of Class/MOP/Class.pm, avg 405µs/call
# once (65µs+997µs) by Moose::Exporter::BEGIN@13 at line 660 of Class/MOP.pm
# once (26µs+440µs) by Moose::Exporter::BEGIN@13 at line 666 of Class/MOP.pm | ||||
26 | 175 | 511µs | my $self = shift; | ||
27 | my ($name) = @_; | ||||
28 | 70 | 2.87ms | my $existing_method = $self->can('find_method_by_name') # spent 2.83ms making 35 calls to Class::MOP::Class::find_method_by_name, avg 81µs/call
# spent 36µ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.9ms | $self->add_method( # spent 4.88ms making 23 calls to Class::MOP::Method::Meta::wrap, avg 212µs/call
# spent 3.68ms making 12 calls to Moose::Meta::Method::Meta::wrap, avg 307µs/call
# spent 2.27ms making 35 calls to Class::MOP::Mixin::HasMethods::add_method, avg 65µs/call
# spent 22µs making 23 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 965ns/call
# spent 21µs making 35 calls to Class::MOP::Package::name, avg 591ns/call
# spent 14µs making 12 calls to Moose::Meta::Class::_meta_method_class, avg 1µs/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.95ms (855µs+2.09) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 84 times, avg 35µs/call:
# 84 times (855µs+2.09ms) by Class::MOP::Mixin::HasMethods::get_method at line 124, avg 35µs/call | ||||
43 | 252 | 965µs | my ( $self, %args ) = @_; | ||
44 | |||||
45 | 84 | 51µs | ( 'CODE' eq reftype $args{body} ) # spent 51µs making 84 calls to Scalar::Util::reftype, avg 602ns/call | ||
46 | || confess "Your code block must be a CODE reference"; | ||||
47 | |||||
48 | 252 | 2.04ms | $self->method_metaclass->wrap( # spent 1.96ms making 84 calls to Class::MOP::Method::wrap, avg 23µs/call
# spent 46µs making 84 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 551ns/call
# spent 37µs making 84 calls to Class::MOP::Package::name, avg 438ns/call | ||
49 | package_name => $self->name, | ||||
50 | %args, | ||||
51 | ); | ||||
52 | } | ||||
53 | |||||
54 | # spent 31.6ms (11.6+19.9) within Class::MOP::Mixin::HasMethods::add_method which was called 501 times, avg 63µs/call:
# 180 times (4.31ms+7.31ms) by Class::MOP::Attribute::install_accessors at line 428 of Class/MOP/Attribute.pm, avg 65µs/call
# 75 times (1.76ms+3.14ms) by Class::MOP::Attribute::install_accessors at line 424 of Class/MOP/Attribute.pm, avg 65µs/call
# 46 times (1.07ms+1.79ms) 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 62µs/call
# 44 times (981µs+1.65ms) by Class::MOP::Attribute::install_accessors at line 436 of Class/MOP/Attribute.pm, avg 60µs/call
# 36 times (849µs+1.33ms) by Moose::Meta::Attribute::install_delegation at line 1125 of Moose/Meta/Attribute.pm, avg 60µs/call
# 35 times (848µs+1.43ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 65µs/call
# 35 times (819µs+1.45ms) by Class::MOP::Class::_inline_constructor at line 1452 of Class/MOP/Class.pm, avg 65µs/call
# 14 times (318µs+662µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 70µs/call
# 8 times (181µs+304µs) by Class::MOP::Attribute::install_accessors at line 432 of Class/MOP/Attribute.pm, avg 61µs/call
# 7 times (117µs+219µs) by Moose::BEGIN@46 at line 30 of Moose/Meta/Attribute/Native.pm, avg 48µs/call
# 3 times (73µs+118µs) by Class::MOP::Class::_inline_destructor at line 1490 of Class/MOP/Class.pm, avg 64µs/call
# 3 times (62µs+88µs) by Moose::BEGIN@35 at line 318 of Moose/Meta/Role.pm, avg 50µs/call
# 3 times (47µs+80µs) by Moose::BEGIN@35 at line 326 of Moose/Meta/Role.pm, avg 42µs/call
# 3 times (45µs+79µs) by Moose::BEGIN@35 at line 345 of Moose/Meta/Role.pm, avg 41µs/call
# 2 times (48µs+83µs) by Class::MOP::Attribute::install_accessors at line 440 of Class/MOP/Attribute.pm, avg 66µs/call
# 2 times (31µs+54µs) by Moose::BEGIN@35 at line 119 of Moose/Meta/Role.pm, avg 42µs/call
# once (18µs+34µ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 (16µs+29µ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+28µs) by Moose::BEGIN@35 at line 104 of Moose/Meta/Role.pm | ||||
55 | 5010 | 14.5ms | my ( $self, $method_name, $method ) = @_; | ||
56 | ( defined $method_name && length $method_name ) | ||||
57 | || confess "You must define a method name"; | ||||
58 | |||||
59 | 501 | 379µs | my $package_name = $self->name; # spent 379µs making 501 calls to Class::MOP::Package::name, avg 757ns/call | ||
60 | |||||
61 | my $body; | ||||
62 | 1457 | 2.53ms | 979 | 757µs | if ( blessed($method) && $method->isa('Class::MOP::Method') ) { # spent 396µs making 478 calls to UNIVERSAL::isa, avg 828ns/call
# spent 361µs making 501 calls to Scalar::Util::blessed, avg 720ns/call |
63 | 478 | 276µs | $body = $method->body; # spent 276µs making 478 calls to Class::MOP::Method::body, avg 578ns/call | ||
64 | 14 | 15µs | 478 | 237µs | if ( $method->package_name ne $package_name ) { # spent 237µs making 478 calls to Class::MOP::Method::package_name, avg 495ns/call |
65 | 14 | 182µs | $method = $method->clone( # spent 182µs making 14 calls to Class::MOP::Method::clone, avg 13µs/call | ||
66 | package_name => $package_name, | ||||
67 | name => $method_name, | ||||
68 | ); | ||||
69 | } | ||||
70 | |||||
71 | 478 | 1.95ms | $method->attach_to_class($self); # spent 1.95ms 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.36ms | $self->_method_map->{$method_name} = $method; # spent 1.35ms 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 539ns/call | ||
80 | |||||
81 | 501 | 575µs | my ($current_package, $current_name) = Class::MOP::get_code_info($body); # spent 575µs making 501 calls to Class::MOP::get_code_info, avg 1µs/call | ||
82 | |||||
83 | 932 | 2.27ms | subname($package_name . '::' . $method_name, $body) # spent 1.48ms making 431 calls to Sub::Name::subname, avg 3µs/call
# spent 792µ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.78ms | $self->add_package_symbol("&$method_name", $body); # spent 8.78ms making 501 calls to Class::MOP::Package::add_package_symbol, avg 18µs/call | ||
87 | |||||
88 | # we added the method to the method map too, so it's still valid | ||||
89 | 501 | 3.16ms | $self->update_package_cache_flag; # spent 3.16ms making 501 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 6µs/call | ||
90 | } | ||||
91 | |||||
92 | # spent 1.14ms (885µs+251µs) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 171 times, avg 7µs/call:
# 171 times (885µs+251µs) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 139, avg 7µs/call | ||||
93 | 513 | 1.25ms | my ( $self, $code ) = @_; | ||
94 | |||||
95 | 171 | 161µs | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); # spent 161µs making 171 calls to Class::MOP::get_code_info, avg 944ns/call | ||
96 | |||||
97 | 171 | 90µs | return ( $code_package && $code_package eq $self->name ) # spent 90µs making 171 calls to Class::MOP::Package::name, avg 526ns/call | ||
98 | || ( $code_package eq 'constant' && $code_name eq '__ANON__' ); | ||||
99 | } | ||||
100 | |||||
101 | # spent 4.25ms (1.34+2.91) within Class::MOP::Mixin::HasMethods::has_method which was called 271 times, avg 16µs/call:
# 145 times (900µs+921µs) by Moose::Meta::Class::_inline_create_error at line 850 of Moose/Meta/Class.pm, avg 13µs/call
# 64 times (221µs+870µs) by Moose::Meta::Attribute::_process_accessors at line 1070 of Moose/Meta/Attribute.pm, avg 17µs/call
# 35 times (126µs+683µs) by Class::MOP::Class::_inline_constructor at line 1424 of Class/MOP/Class.pm, avg 23µs/call
# 24 times (79µs+388µ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+50µs) by Class::MOP::Class::_inline_destructor at line 1464 of Class/MOP/Class.pm, avg 20µs/call | ||||
102 | 960 | 1.37ms | my ( $self, $method_name ) = @_; | ||
103 | |||||
104 | ( defined $method_name && length $method_name ) | ||||
105 | || confess "You must define a method name"; | ||||
106 | |||||
107 | 271 | 2.76ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 2.76ms making 271 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 10µs/call | ||
108 | or return; | ||||
109 | |||||
110 | 147 | 153µs | return defined($self->_method_map->{$method_name} = $method); # spent 153µs making 147 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call | ||
111 | } | ||||
112 | |||||
113 | # spent 21.8ms (3.65+18.1) within Class::MOP::Mixin::HasMethods::get_method which was called 824 times, avg 26µs/call:
# 367 times (1.46ms+7.50ms) by Class::MOP::Class::find_method_by_name at line 1123 of Class/MOP/Class.pm, avg 24µs/call
# 158 times (829µs+2.73ms) by Class::MOP::Class::find_next_method_by_name at line 1171 of Class/MOP/Class.pm, avg 23µs/call
# 130 times (785µs+4.68ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 205, avg 42µs/call
# 64 times (233µs+1.54ms) by Moose::Meta::Attribute::_process_accessors at line 1043 of Moose/Meta/Attribute.pm, avg 28µs/call
# 47 times (157µs+726µs) by Moose::Meta::Attribute::install_delegation at line 1106 of Moose/Meta/Attribute.pm, avg 19µs/call
# 46 times (128µs+696µ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 (44µs+212µs) by Moose::init_meta at line 207 of Moose.pm, avg 23µs/call
# once (9µs+47µs) by Class::MOP::Class::find_all_methods_by_name at line 1155 of Class/MOP/Class.pm | ||||
114 | 2773 | 3.80ms | my ( $self, $method_name ) = @_; | ||
115 | |||||
116 | ( defined $method_name && length $method_name ) | ||||
117 | || confess "You must define a method name"; | ||||
118 | |||||
119 | 824 | 14.7ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 14.7ms making 824 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 18µs/call | ||
120 | or return; | ||||
121 | |||||
122 | 350 | 269µs | return $method if blessed($method) && $method->isa('Class::MOP::Method'); # spent 166µs making 217 calls to Scalar::Util::blessed, avg 763ns/call
# spent 103µs making 133 calls to UNIVERSAL::isa, avg 776ns/call | ||
123 | |||||
124 | 168 | 3.21ms | return $self->_method_map->{$method_name} = $self->wrap_method_body( # spent 2.95ms making 84 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 35µs/call
# spent 90µs making 14 calls to Class::MOP::Class::Immutable::Moose::Meta::Class::_method_map, avg 6µs/call
# spent 87µs making 57 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call
# spent 84µs making 13 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 17.4ms (5.64+11.8) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 1095 times, avg 16µs/call:
# 824 times (4.41ms+10.2ms) by Class::MOP::Mixin::HasMethods::get_method at line 119, avg 18µs/call
# 271 times (1.23ms+1.53ms) by Class::MOP::Mixin::HasMethods::has_method at line 107, avg 10µs/call | ||||
132 | 5002 | 7.34ms | my ( $self, $method_name ) = @_; | ||
133 | |||||
134 | 1112 | 3.52ms | my $map_entry = $self->_method_map->{$method_name}; # spent 1.53ms making 782 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call
# spent 1.48ms making 228 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 7µs/call
# spent 494µ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 706ns/call | ||
135 | return $map_entry if defined $map_entry; | ||||
136 | |||||
137 | 816 | 7.13ms | my $code = $self->get_package_symbol("&$method_name"); # spent 7.13ms making 816 calls to Class::MOP::Package::get_package_symbol, avg 9µs/call | ||
138 | |||||
139 | 171 | 1.14ms | return unless $code && $self->_code_is_mine($code); # spent 1.14ms making 171 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 7µ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 6.13ms (90µs+6.04) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 20 times, avg 307µs/call:
# 20 times (90µs+6.04ms) by Class::MOP::Class::get_all_methods at line 1136 of Class/MOP/Class.pm, avg 307µs/call | ||||
170 | 40 | 56µs | my $self = shift; | ||
171 | |||||
172 | 20 | 29µs | 20 | 6.04ms | return values %{ $self->_full_method_map }; # spent 6.04ms making 20 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 302µ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.16ms (2.19+971µs) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 501 times, avg 6µs/call:
# 501 times (2.19ms+971µs) by Class::MOP::Mixin::HasMethods::add_method at line 89, avg 6µs/call | ||||
187 | 1002 | 3.41ms | 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 | 971µs | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); # spent 667µs making 501 calls to mro::get_pkg_gen, avg 1µs/call
# spent 304µs making 501 calls to Class::MOP::Package::name, avg 607ns/call | ||
195 | } | ||||
196 | |||||
197 | # spent 6.04ms (420µs+5.62) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 20 times, avg 302µs/call:
# 20 times (420µs+5.62ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 172, avg 302µs/call | ||||
198 | 80 | 206µs | my $self = shift; | ||
199 | |||||
200 | 40 | 34µs | my $pkg_gen = Class::MOP::check_package_cache_flag($self->name); # spent 23µs making 20 calls to mro::get_pkg_gen, avg 1µs/call
# spent 11µs making 20 calls to Class::MOP::Package::name, avg 565ns/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.56ms | for $self->list_all_package_symbols('CODE'); # spent 5.46ms making 130 calls to Class::MOP::Mixin::HasMethods::get_method, avg 42µs/call
# spent 96µs making 6 calls to Class::MOP::Package::list_all_package_symbols, avg 16µs/call | ||
206 | $self->{_package_cache_flag_full} = $pkg_gen; | ||||
207 | } | ||||
208 | |||||
209 | 20 | 30µ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 | 100ns | 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 792µs within Class::MOP::Mixin::HasMethods::CORE:match which was called 501 times, avg 2µs/call:
# 501 times (792µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 83, avg 2µs/call |