Profile of Class/MOP/Mixin/HasMethods.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For xt/tapper-mcp-scheduler-with-db-longrun.t
Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:27 2012

Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Mixin/HasMethods.pm
Statements | Executed 11116 statements in 30.4ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
390 | 19 | 8 | 10.2ms | 26.2ms | Class::MOP::Mixin::HasMethods::::add_methodClass::MOP::Mixin::HasMethods::add_method
530 | 2 | 1 | 3.68ms | 11.6ms | Class::MOP::Mixin::HasMethods::::_get_maybe_raw_methodClass::MOP::Mixin::HasMethods::_get_maybe_raw_method
482 | 9 | 7 | 2.64ms | 16.8ms | Class::MOP::Mixin::HasMethods::::get_methodClass::MOP::Mixin::HasMethods::get_method
390 | 1 | 1 | 1.80ms | 2.61ms | Class::MOP::Mixin::HasMethods::::update_package_cache_flagClass::MOP::Mixin::HasMethods::update_package_cache_flag
35 | 6 | 5 | 914µs | 20.1ms | Class::MOP::Mixin::HasMethods::::_add_meta_methodClass::MOP::Mixin::HasMethods::_add_meta_method
66 | 1 | 1 | 720µs | 3.29ms | Class::MOP::Mixin::HasMethods::::wrap_method_bodyClass::MOP::Mixin::HasMethods::wrap_method_body
125 | 1 | 1 | 693µs | 902µs | Class::MOP::Mixin::HasMethods::::_code_is_mineClass::MOP::Mixin::HasMethods::_code_is_mine
390 | 1 | 1 | 634µs | 634µs | Class::MOP::Mixin::HasMethods::::CORE:matchClass::MOP::Mixin::HasMethods::CORE:match (opcode)
1 | 1 | 1 | 568µs | 3.50ms | Class::MOP::Mixin::HasMethods::::BEGIN@12Class::MOP::Mixin::HasMethods::BEGIN@12
19 | 2 | 1 | 534µs | 6.58ms | Class::MOP::Mixin::HasMethods::::_full_method_mapClass::MOP::Mixin::HasMethods::_full_method_map
48 | 3 | 3 | 328µs | 1.36ms | Class::MOP::Mixin::HasMethods::::has_methodClass::MOP::Mixin::HasMethods::has_method
1 | 1 | 1 | 324µs | 474µs | Class::MOP::Mixin::HasMethods::::BEGIN@13Class::MOP::Mixin::HasMethods::BEGIN@13
1 | 1 | 1 | 180µs | 656µs | Class::MOP::Mixin::HasMethods::::BEGIN@17Class::MOP::Mixin::HasMethods::BEGIN@17
18 | 2 | 2 | 110µs | 5.25ms | Class::MOP::Mixin::HasMethods::::_get_local_methodsClass::MOP::Mixin::HasMethods::_get_local_methods
24 | 2 | 1 | 47µs | 47µs | Class::MOP::Mixin::HasMethods::::_meta_method_classClass::MOP::Mixin::HasMethods::_meta_method_class
1 | 1 | 1 | 31µs | 1.47ms | Class::MOP::Mixin::HasMethods::::get_method_listClass::MOP::Mixin::HasMethods::get_method_list
4 | 1 | 1 | 11µs | 11µs | Class::MOP::Mixin::HasMethods::::reset_package_cache_flagClass::MOP::Mixin::HasMethods::reset_package_cache_flag
1 | 1 | 1 | 8µs | 8µs | Class::MOP::Mixin::HasMethods::::BEGIN@2Class::MOP::Mixin::HasMethods::BEGIN@2
1 | 1 | 1 | 7µs | 30µs | Class::MOP::Mixin::HasMethods::::BEGIN@15Class::MOP::Mixin::HasMethods::BEGIN@15
1 | 1 | 1 | 7µs | 58µs | Class::MOP::Mixin::HasMethods::::BEGIN@21Class::MOP::Mixin::HasMethods::BEGIN@21
1 | 1 | 1 | 7µs | 16µs | Class::MOP::Mixin::HasMethods::::BEGIN@10Class::MOP::Mixin::HasMethods::BEGIN@10
1 | 1 | 1 | 6µs | 9µs | Class::MOP::Mixin::HasMethods::::BEGIN@9Class::MOP::Mixin::HasMethods::BEGIN@9
1 | 1 | 1 | 6µs | 24µs | Class::MOP::Mixin::HasMethods::::BEGIN@16Class::MOP::Mixin::HasMethods::BEGIN@16
1 | 1 | 1 | 5µs | 5µs | Class::MOP::Mixin::HasMethods::::BEGIN@19Class::MOP::Mixin::HasMethods::BEGIN@19
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::_get_overloaded_operator_bodyClass::MOP::Mixin::HasMethods::_get_overloaded_operator_body
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::_overload_mapClass::MOP::Mixin::HasMethods::_overload_map
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::::_wrap_overloadClass::MOP::Mixin::HasMethods::_wrap_overload
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::add_overloaded_operatorClass::MOP::Mixin::HasMethods::add_overloaded_operator
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::get_all_overloaded_operatorsClass::MOP::Mixin::HasMethods::get_all_overloaded_operators
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::get_overload_listClass::MOP::Mixin::HasMethods::get_overload_list
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::get_overloaded_operatorClass::MOP::Mixin::HasMethods::get_overloaded_operator
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::has_overloaded_operatorClass::MOP::Mixin::HasMethods::has_overloaded_operator
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::is_overloadedClass::MOP::Mixin::HasMethods::is_overloaded
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::overload_operatorsClass::MOP::Mixin::HasMethods::overload_operators
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::remove_methodClass::MOP::Mixin::HasMethods::remove_method
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::remove_overloaded_operatorClass::MOP::Mixin::HasMethods::remove_overloaded_operator

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 |  |  |  |  | # 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 BEGIN {
3 | 1 | 4µs |  |  | $Class::MOP::Mixin::HasMethods::AUTHORITY = 'cpan:STEVAN';
4 | 1 | 21µ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.0602';
7 |  |  |  |  | }
8 |  |  |  |  |
9 | 3 | 17µs | 2 | 11µs | # spent 9µs (6+2) within Class::MOP::Mixin::HasMethods::BEGIN@9 which was called: # once (6µs+2µs) by Class::MOP::BEGIN@25 at line 9 use strict; # spent 9µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@9 # spent 2µs making 1 call to strict::import
10 | 3 | 17µs | 2 | 24µs | # spent 16µs (7+9) within Class::MOP::Mixin::HasMethods::BEGIN@10 which was called: # once (7µs+9µs) by Class::MOP::BEGIN@25 at line 10 use warnings; # spent 16µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@10 # spent 9µs making 1 call to warnings::import
11 |  |  |  |  |
12 | 3 | 90µs | 1 | 3.50ms | # spent 3.50ms (568µs+2.93) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called: # once (568µs+2.93ms) by Class::MOP::BEGIN@25 at line 12 use Class::MOP::Method::Meta; # spent 3.50ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12
13 | 3 | 94µs | 1 | 474µs | # spent 474µs (324+149) within Class::MOP::Mixin::HasMethods::BEGIN@13 which was called: # once (324µs+149µs) by Class::MOP::BEGIN@25 at line 13 use Class::MOP::Method::Overload; # spent 474µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@13
14 |  |  |  |  |
15 | 3 | 19µs | 2 | 52µs | # spent 30µs (7+23) within Class::MOP::Mixin::HasMethods::BEGIN@15 which was called: # once (7µs+23µs) by Class::MOP::BEGIN@25 at line 15 use Scalar::Util 'blessed'; # spent 30µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@15 # spent 22µs making 1 call to Exporter::import
16 | 3 | 19µs | 2 | 42µs | # spent 24µs (6+18) within Class::MOP::Mixin::HasMethods::BEGIN@16 which was called: # once (6µs+18µs) by Class::MOP::BEGIN@25 at line 16 use Carp 'confess'; # spent 24µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@16 # spent 18µs making 1 call to Exporter::import
17 | 3 | 97µs | 2 | 689µs | # spent 656µs (180+476) within Class::MOP::Mixin::HasMethods::BEGIN@17 which was called: # once (180µs+476µs) by Class::MOP::BEGIN@25 at line 17 use Sub::Name 'subname'; # spent 656µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@17 # spent 33µs making 1 call to Exporter::import
18 |  |  |  |  |
19 | 3 | 18µs | 1 | 5µs | # spent 5µs within Class::MOP::Mixin::HasMethods::BEGIN@19 which was called: # once (5µs+0s) by Class::MOP::BEGIN@25 at line 19 use overload (); # spent 5µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@19
20 |  |  |  |  |
21 | 3 | 1.08ms | 2 | 108µs | # spent 58µs (7+51) within Class::MOP::Mixin::HasMethods::BEGIN@21 which was called: # once (7µs+51µs) by Class::MOP::BEGIN@25 at line 21 use base 'Class::MOP::Mixin'; # spent 58µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@21 # spent 51µs making 1 call to base::import
22 |  |  |  |  |
23 | 24 | 63µs |  |  | # spent 47µs within Class::MOP::Mixin::HasMethods::_meta_method_class which was called 24 times, avg 2µs/call: # 22 times (43µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 2µs/call # 2 times (4µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 31, avg 2µs/call sub _meta_method_class { 'Class::MOP::Method::Meta' }
24 |  |  |  |  |
25 |  |  |  |  | # spent 20.1ms (914µs+19.2) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 35 times, avg 574µs/call: # 20 times (409µs+9.22ms) by metaclass::import at line 49 of metaclass.pm, avg 482µs/call # 7 times (183µs+3.98ms) by Moose::init_meta at line 211 of Moose.pm, avg 595µs/call # 4 times (115µs+1.96ms) by Moose::Role::init_meta at line 152 of Moose/Role.pm, avg 518µs/call # 2 times (90µs+2.27ms) by Class::MOP::Class::create at line 448 of Class/MOP/Class.pm, avg 1.18ms/call # once (82µs+1.23ms) by Moose::Exporter::BEGIN@13 at line 660 of Class/MOP.pm # once (35µs+504µs) by Moose::Exporter::BEGIN@13 at line 666 of Class/MOP.pm sub _add_meta_method {
26 | 35 | 27µs |  |  | my $self = shift;
27 | 35 | 32µs |  |  | my ($name) = @_;
28 | 35 | 301µs | 70 | 3.35ms | my $existing_method = $self->can('find_method_by_name') # spent 3.19ms making 31 calls to Class::MOP::Class::find_method_by_name, avg 103µs/call # spent 93µs making 4 calls to Moose::Meta::Role::find_method_by_name, avg 23µs/call # spent 75µs making 35 calls to UNIVERSAL::can, avg 2µs/call
29 |  |  |  |  | ? $self->find_method_by_name($name)
30 |  |  |  |  | : $self->get_method($name);
31 | 35 | 35µs | 4 | 8µs | return if $existing_method # spent 4µs making 2 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 2µs/call # spent 4µs making 2 calls to UNIVERSAL::isa, avg 2µs/call
32 |  |  |  |  | && $existing_method->isa($self->_meta_method_class);
33 | 35 | 547µs | 140 | 15.8ms | $self->add_method( # spent 6.61ms making 13 calls to Moose::Meta::Method::Meta::wrap, avg 508µs/call # spent 6.24ms making 22 calls to Class::MOP::Method::Meta::wrap, avg 284µs/call # spent 2.86ms making 35 calls to Class::MOP::Mixin::HasMethods::add_method, avg 82µs/call # spent 43µs making 22 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 2µs/call # spent 21µs making 35 calls to Class::MOP::Package::name, avg 609ns/call # spent 18µs making 9 calls to Moose::Meta::Class::_meta_method_class, avg 2µs/call # spent 7µs making 4 calls to Moose::Meta::Role::_meta_method_class, avg 2µ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 3.29ms (720µs+2.57) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 66 times, avg 50µs/call: # 66 times (720µs+2.57ms) by Class::MOP::Mixin::HasMethods::get_method at line 124, avg 50µs/call sub wrap_method_body {
43 | 66 | 110µs |  |  | my ( $self, %args ) = @_;
44 |  |  |  |  |
45 | 66 | 40µs |  |  | ( 'CODE' eq ref $args{body} )
46 |  |  |  |  | || confess "Your code block must be a CODE reference";
47 |  |  |  |  |
48 | 66 | 625µs | 198 | 2.57ms | $self->method_metaclass->wrap( # spent 2.46ms making 66 calls to Class::MOP::Method::wrap, avg 37µs/call # spent 40µs making 15 calls to Moose::Meta::Role::method_metaclass, avg 3µs/call # spent 36µs making 66 calls to Class::MOP::Package::name, avg 552ns/call # spent 31µs making 51 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 614ns/call
49 |  |  |  |  | package_name => $self->name,
50 |  |  |  |  | %args,
51 |  |  |  |  | );
52 |  |  |  |  | }
53 |  |  |  |  |
54 |  |  |  |  | # spent 26.2ms (10.2+16.0) within Class::MOP::Mixin::HasMethods::add_method which was called 390 times, avg 67µs/call: # 153 times (3.81ms+5.94ms) by Class::MOP::Attribute::install_accessors at line 428 of Class/MOP/Attribute.pm, avg 64µs/call # 51 times (1.40ms+2.35ms) by Class::MOP::Attribute::install_accessors at line 424 of Class/MOP/Attribute.pm, avg 74µs/call # 42 times (889µs+1.36ms) by Class::MOP::Attribute::install_accessors at line 436 of Class/MOP/Attribute.pm, avg 54µs/call # 35 times (1.21ms+1.65ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 82µs/call # 30 times (981µs+1.60ms) by Class::MOP::Class::_inline_constructor at line 1452 of Class/MOP/Class.pm, avg 86µs/call # 23 times (559µs+837µs) by Class::MOP::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Class.pm:1072] at line 1070 of Class/MOP/Class.pm, avg 61µs/call # 15 times (524µs+982µs) by Moose::Meta::Role::Application::ToClass::apply_methods at line 173 of Moose/Meta/Role/Application/ToClass.pm, avg 100µs/call # 10 times (224µs+454µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 68µs/call # 8 times (173µs+256µs) by Class::MOP::Attribute::install_accessors at line 432 of Class/MOP/Attribute.pm, avg 54µs/call # 7 times (127µs+208µs) by Moose::BEGIN@47 at line 30 of Moose/Meta/Attribute/Native.pm, avg 48µs/call # 3 times (48µs+72µs) by Moose::BEGIN@36 at line 318 of Moose/Meta/Role.pm, avg 40µs/call # 3 times (48µs+68µs) by Moose::BEGIN@36 at line 326 of Moose/Meta/Role.pm, avg 39µs/call # 3 times (48µs+68µs) by Moose::BEGIN@36 at line 345 of Moose/Meta/Role.pm, avg 39µs/call # 2 times (32µs+45µs) by Moose::BEGIN@36 at line 119 of Moose/Meta/Role.pm, avg 39µs/call # once (19µs+40µs) by Moose::Exporter::BEGIN@13 at line 486 of Class/MOP.pm # once (17µs+39µs) by Moose::BEGIN@36 at line 99 of Moose/Meta/Role.pm # once (16µs+24µs) by Moose::BEGIN@36 at line 104 of Moose/Meta/Role.pm # once (16µs+24µs) by Moose::BEGIN@36 at line 109 of Moose/Meta/Role.pm # once (16µs+23µs) by Moose::BEGIN@36 at line 124 of Moose/Meta/Role.pm sub add_method {
55 | 390 | 265µs |  |  | my ( $self, $method_name, $method ) = @_;
56 | 390 | 177µs |  |  | ( defined $method_name && length $method_name )
57 |  |  |  |  | || confess "You must define a method name";
58 |  |  |  |  |
59 | 390 | 1.06ms | 390 | 240µs | my $package_name = $self->name; # spent 240µs making 390 calls to Class::MOP::Package::name, avg 616ns/call
60 |  |  |  |  |
61 | 390 | 70µs |  |  | my $body;
62 | 390 | 1.02ms | 390 | 305µs | if ( blessed($method) ) { # spent 305µs making 390 calls to Scalar::Util::blessed, avg 782ns/call
63 | 367 | 1.05ms | 367 | 249µs | $body = $method->body; # spent 249µs making 367 calls to Class::MOP::Method::body, avg 680ns/call
64 | 367 | 1.03ms | 392 | 674µs | if ( $method->package_name ne $package_name ) { # spent 431µs making 25 calls to Class::MOP::Method::clone, avg 17µs/call # spent 243µs making 367 calls to Class::MOP::Method::package_name, avg 663ns/call
65 |  |  |  |  | $method = $method->clone(
66 |  |  |  |  | package_name => $package_name,
67 |  |  |  |  | name => $method_name,
68 |  |  |  |  | );
69 |  |  |  |  | }
70 |  |  |  |  |
71 | 367 | 598µs | 367 | 1.66ms | $method->attach_to_class($self); # spent 1.66ms making 367 calls to Class::MOP::Method::attach_to_class, avg 5µs/call
72 |  |  |  |  | }
73 |  |  |  |  | else {
74 |  |  |  |  | # If a raw code reference is supplied, its method object is not created.
75 |  |  |  |  | # The method object won't be created until required.
76 | 23 | 6µs |  |  | $body = $method;
77 |  |  |  |  | }
78 |  |  |  |  |
79 | 390 | 2.38ms | 413 | 1.36ms | $self->_method_map->{$method_name} = $method; # spent 1.35ms making 390 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 3µs/call # spent 14µs making 23 calls to Class::MOP::Method::body, avg 591ns/call
80 |  |  |  |  |
81 | 390 | 1.36ms | 390 | 480µs | my ($current_package, $current_name) = Class::MOP::get_code_info($body); # spent 480µs making 390 calls to Class::MOP::get_code_info, avg 1µs/call
82 |  |  |  |  |
83 | 390 | 3.06ms | 699 | 1.66ms | subname($package_name . '::' . $method_name, $body) # spent 1.03ms making 309 calls to Sub::Name::subname, avg 3µs/call # spent 634µs making 390 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 2µs/call
84 |  |  |  |  | unless defined $current_name && $current_name !~ /^__ANON__/;
85 |  |  |  |  |
86 | 390 | 773µs | 390 | 6.82ms | $self->add_package_symbol("&$method_name", $body); # spent 6.82ms making 390 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 | 390 | 1.45ms | 390 | 2.61ms | $self->update_package_cache_flag; # spent 2.61ms making 390 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 7µs/call
90 |  |  |  |  | }
91 |  |  |  |  |
92 |  |  |  |  | # spent 902µs (693+209) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 125 times, avg 7µs/call: # 125 times (693µs+209µs) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 139, avg 7µs/call sub _code_is_mine {
93 | 125 | 53µs |  |  | my ( $self, $code ) = @_;
94 |  |  |  |  |
95 | 125 | 396µs | 125 | 136µs | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); # spent 136µs making 125 calls to Class::MOP::get_code_info, avg 1µs/call
96 |  |  |  |  |
97 | 125 | 553µs | 125 | 73µs | return ( $code_package && $code_package eq $self->name ) # spent 73µs making 125 calls to Class::MOP::Package::name, avg 582ns/call
98 |  |  |  |  | || ( $code_package eq 'constant' && $code_name eq '__ANON__' );
99 |  |  |  |  | }
100 |  |  |  |  |
101 |  |  |  |  | # spent 1.36ms (328µs+1.03) within Class::MOP::Mixin::HasMethods::has_method which was called 48 times, avg 28µs/call: # 30 times (197µs+791µs) by Class::MOP::Class::_inline_constructor at line 1424 of Class/MOP/Class.pm, avg 33µs/call # 9 times (58µs+127µs) by Moose::Meta::Attribute::_process_accessors at line 1066 of Moose/Meta/Attribute.pm, avg 21µs/call # 9 times (73µs+111µs) by Moose::Meta::Class::_inline_create_error at line 840 of Moose/Meta/Class.pm, avg 20µs/call sub has_method {
102 | 48 | 37µs |  |  | my ( $self, $method_name ) = @_;
103 |  |  |  |  |
104 | 48 | 24µs |  |  | ( defined $method_name && length $method_name )
105 |  |  |  |  | || confess "You must define a method name";
106 |  |  |  |  |
107 | 48 | 191µs | 48 | 1.02ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 1.02ms making 48 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 21µs/call
108 |  |  |  |  | or return;
109 |  |  |  |  |
110 | 10 | 58µs | 10 | 11µs | return defined($self->_method_map->{$method_name} = $method); # spent 11µs making 10 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call
111 |  |  |  |  | }
112 |  |  |  |  |
113 |  |  |  |  | # spent 16.8ms (2.64+14.2) within Class::MOP::Mixin::HasMethods::get_method which was called 482 times, avg 35µs/call: # 232 times (1.00ms+5.32ms) by Class::MOP::Class::find_method_by_name at line 1123 of Class/MOP/Class.pm, avg 27µs/call # 98 times (721µs+5.02ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 205, avg 59µs/call # 90 times (524µs+2.06ms) by Class::MOP::Class::find_next_method_by_name at line 1171 of Class/MOP/Class.pm, avg 29µs/call # 23 times (68µs+350µs) by Class::MOP::Class::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Class/MOP/Class.pm:1072] at line 1047 of Class/MOP/Class.pm, avg 18µs/call # 15 times (137µs+354µs) by Moose::Meta::Role::Application::ToClass::apply_methods at line 169 of Moose/Meta/Role/Application/ToClass.pm, avg 33µs/call # 9 times (84µs+459µs) by Moose::Meta::Attribute::_process_accessors at line 1039 of Moose/Meta/Attribute.pm, avg 60µs/call # 7 times (53µs+216µs) by Moose::init_meta at line 201 of Moose.pm, avg 38µs/call # 4 times (40µs+312µs) by Moose::Role::init_meta at line 142 of Moose/Role.pm, avg 88µs/call # 4 times (12µs+62µs) by Moose::Meta::Role::find_method_by_name at line 436 of Moose/Meta/Role.pm, avg 19µs/call sub get_method {
114 | 482 | 332µs |  |  | my ( $self, $method_name ) = @_;
115 |  |  |  |  |
116 | 482 | 150µs |  |  | ( defined $method_name && length $method_name )
117 |  |  |  |  | || confess "You must define a method name";
118 |  |  |  |  |
119 | 482 | 1.27ms | 482 | 10.6ms | my $method = $self->_get_maybe_raw_method($method_name) # spent 10.6ms making 482 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 22µs/call
120 |  |  |  |  | or return;
121 |  |  |  |  |
122 | 131 | 500µs | 131 | 121µs | return $method if blessed $method; # spent 121µs making 131 calls to Scalar::Util::blessed, avg 926ns/call
123 |  |  |  |  |
124 | 66 | 510µs | 132 | 3.44ms | return $self->_method_map->{$method_name} = $self->wrap_method_body( # spent 3.29ms making 66 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 50µs/call # spent 101µs making 59 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call # spent 50µs making 7 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 7µs/call
125 |  |  |  |  | body => $method,
126 |  |  |  |  | name => $method_name,
127 |  |  |  |  | associated_metaclass => $self,
128 |  |  |  |  | );
129 |  |  |  |  | }
130 |  |  |  |  |
131 |  |  |  |  | # spent 11.6ms (3.68+7.92) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 530 times, avg 22µs/call: # 482 times (3.32ms+7.27ms) by Class::MOP::Mixin::HasMethods::get_method at line 119, avg 22µs/call # 48 times (361µs+657µs) by Class::MOP::Mixin::HasMethods::has_method at line 107, avg 21µs/call sub _get_maybe_raw_method {
132 | 530 | 226µs |  |  | my ( $self, $method_name ) = @_;
133 |  |  |  |  |
134 | 530 | 2.80ms | 555 | 2.45ms | my $map_entry = $self->_method_map->{$method_name}; # spent 1.52ms making 450 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 3µs/call # spent 897µs making 80 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 11µs/call # spent 28µs making 25 calls to Class::MOP::Method::body, avg 1µs/call
135 | 530 | 255µs |  |  | return $map_entry if defined $map_entry;
136 |  |  |  |  |
137 | 456 | 843µs | 456 | 4.60ms | my $code = $self->get_package_symbol("&$method_name"); # spent 4.60ms making 456 calls to Class::MOP::Package::get_package_symbol, avg 10µs/call
138 |  |  |  |  |
139 | 456 | 962µs | 125 | 902µs | return unless $code && $self->_code_is_mine($code); # spent 902µs making 125 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 7µs/call
140 |  |  |  |  |
141 | 67 | 129µs |  |  | return $code;
142 |  |  |  |  | }
143 |  |  |  |  |
144 |  |  |  |  | sub remove_method {
145 |  |  |  |  | my ( $self, $method_name ) = @_;
146 |  |  |  |  |
147 |  |  |  |  | ( defined $method_name && length $method_name )
148 |  |  |  |  | || confess "You must define a method name";
149 |  |  |  |  |
150 |  |  |  |  | my $removed_method = delete $self->_method_map->{$method_name};
151 |  |  |  |  |
152 |  |  |  |  | $self->remove_package_symbol("&$method_name");
153 |  |  |  |  |
154 |  |  |  |  | $removed_method->detach_from_class
155 |  |  |  |  | if blessed($removed_method);
156 |  |  |  |  |
157 |  |  |  |  | # still valid, since we just removed the method from the map
158 |  |  |  |  | $self->update_package_cache_flag;
159 |  |  |  |  |
160 |  |  |  |  | return $removed_method;
161 |  |  |  |  | }
162 |  |  |  |  |
163 |  |  |  |  | # spent 1.47ms (31µs+1.44) within Class::MOP::Mixin::HasMethods::get_method_list which was called: # once (31µs+1.44ms) by namespace::autoclean::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/namespace/autoclean.pm:57] at line 45 of namespace/autoclean.pm sub get_method_list {
164 | 1 | 900ns |  |  | my $self = shift;
165 |  |  |  |  |
166 | 1 | 32µs | 1 | 1.44ms | return keys %{ $self->_full_method_map }; # spent 1.44ms making 1 call to Class::MOP::Mixin::HasMethods::_full_method_map
167 |  |  |  |  | }
168 |  |  |  |  |
169 |  |  |  |  | # spent 5.25ms (110µs+5.14) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 18 times, avg 292µs/call: # 14 times (74µs+2.18ms) by Class::MOP::Class::get_all_methods at line 1136 of Class/MOP/Class.pm, avg 161µs/call # 4 times (36µs+2.96ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 162 of Moose/Meta/Role/Application/ToClass.pm, avg 748µs/call sub _get_local_methods {
170 | 18 | 7µs |  |  | my $self = shift;
171 |  |  |  |  |
172 | 18 | 100µs | 18 | 5.14ms | return values %{ $self->_full_method_map }; # spent 5.14ms making 18 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 285µ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 | 4 | 18µs |  |  | # spent 11µs within Class::MOP::Mixin::HasMethods::reset_package_cache_flag which was called 4 times, avg 3µs/call: # 4 times (11µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 200 of Moose/Meta/Role/Application/ToClass.pm, avg 3µs/call sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
186 |  |  |  |  | # spent 2.61ms (1.80+805µs) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 390 times, avg 7µs/call: # 390 times (1.80ms+805µs) by Class::MOP::Mixin::HasMethods::add_method at line 89, avg 7µs/call sub update_package_cache_flag {
187 | 390 | 140µs |  |  | my $self = shift;
188 |  |  |  |  | # NOTE:
189 |  |  |  |  | # we can manually update the cache number
190 |  |  |  |  | # since we are actually adding the method
191 |  |  |  |  | # to our cache as well. This avoids us
192 |  |  |  |  | # having to regenerate the method_map.
193 |  |  |  |  | # - SL
194 | 390 | 2.68ms | 780 | 805µs | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); # spent 603µs making 390 calls to mro::get_pkg_gen, avg 2µs/call # spent 202µs making 390 calls to Class::MOP::Package::name, avg 519ns/call
195 |  |  |  |  | }
196 |  |  |  |  |
197 |  |  |  |  | # spent 6.58ms (534µs+6.04) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 19 times, avg 346µs/call: # 18 times (446µs+4.69ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 172, avg 285µs/call # once (88µs+1.35ms) by Class::MOP::Mixin::HasMethods::get_method_list at line 166 sub _full_method_map {
198 | 19 | 8µs |  |  | my $self = shift;
199 |  |  |  |  |
200 | 19 | 165µs | 38 | 64µs | my $pkg_gen = Class::MOP::check_package_cache_flag($self->name); # spent 46µs making 19 calls to mro::get_pkg_gen, avg 2µs/call # spent 17µs making 19 calls to Class::MOP::Package::name, avg 895ns/call
201 |  |  |  |  |
202 | 19 | 27µs |  |  | if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) {
203 |  |  |  |  | # forcibly reify all method map entries
204 |  |  |  |  | $self->get_method($_)
205 | 16 | 212µs | 106 | 5.94ms | for $self->list_all_package_symbols('CODE'); # spent 5.74ms making 98 calls to Class::MOP::Mixin::HasMethods::get_method, avg 59µs/call # spent 200µs making 8 calls to Class::MOP::Package::list_all_package_symbols, avg 25µs/call
206 | 8 | 10µs |  |  | $self->{_package_cache_flag_full} = $pkg_gen;
207 |  |  |  |  | }
208 |  |  |  |  |
209 | 19 | 143µs | 19 | 41µs | return $self->_method_map; # spent 41µs making 19 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call
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 |  |  |  |  | # ugh, overload.pm provides no api for this
277 |  |  |  |  | $self->get_or_add_package_symbol('%OVERLOAD')->{dummy}++;
278 |  |  |  |  | $self->remove_package_symbol('&(' . $op);
279 |  |  |  |  | }
280 |  |  |  |  |
281 |  |  |  |  | sub _get_overloaded_operator_body {
282 |  |  |  |  | my $self = shift;
283 |  |  |  |  | my ($op) = @_;
284 |  |  |  |  | return overload::Method($self->name, $op);
285 |  |  |  |  | }
286 |  |  |  |  |
287 |  |  |  |  | sub _wrap_overload {
288 |  |  |  |  | my $self = shift;
289 |  |  |  |  | my ($op, $body) = @_;
290 |  |  |  |  | return Class::MOP::Method::Overload->wrap(
291 |  |  |  |  | operator => $op,
292 |  |  |  |  | package_name => $self->name,
293 |  |  |  |  | associated_metaclass => $self,
294 |  |  |  |  | body => $body,
295 |  |  |  |  | );
296 |  |  |  |  | }
297 |  |  |  |  |
298 | 1 | 3µs |  |  | 1;
299 |  |  |  |  |
300 |  |  |  |  | # ABSTRACT: Methods for metaclasses which have methods
301 |  |  |  |  |
- - |  |  |  |  |
304 |  |  |  |  | =pod
305 |  |  |  |  |
306 |  |  |  |  | =head1 NAME
307 |  |  |  |  |
308 |  |  |  |  | Class::MOP::Mixin::HasMethods - Methods for metaclasses which have methods
309 |  |  |  |  |
310 |  |  |  |  | =head1 VERSION
311 |  |  |  |  |
312 |  |  |  |  | version 2.0602
313 |  |  |  |  |
314 |  |  |  |  | =head1 DESCRIPTION
315 |  |  |  |  |
316 |  |  |  |  | This class implements methods for metaclasses which have methods
317 |  |  |  |  | (L<Class::MOP::Package> and L<Moose::Meta::Role>). See L<Class::MOP::Package>
318 |  |  |  |  | for API details.
319 |  |  |  |  |
320 |  |  |  |  | =head1 AUTHOR
321 |  |  |  |  |
322 |  |  |  |  | Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
323 |  |  |  |  |
324 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
325 |  |  |  |  |
326 |  |  |  |  | This software is copyright (c) 2012 by Infinity Interactive, Inc..
327 |  |  |  |  |
328 |  |  |  |  | This is free software; you can redistribute it and/or modify it under
329 |  |  |  |  | the same terms as the Perl 5 programming language system itself.
330 |  |  |  |  |
331 |  |  |  |  | =cut
332 |  |  |  |  |
333 |  |  |  |  |
334 |  |  |  |  | __END__
|  |  |  |  | # spent 634µs within Class::MOP::Mixin::HasMethods::CORE:match which was called 390 times, avg 2µs/call: # 390 times (634µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 83, avg 2µs/call sub Class::MOP::Mixin::HasMethods::CORE:match; # opcode