Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Mixin/HasMethods.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For 05.Domain_and_Item.t
Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:22:20 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Mixin/HasMethods.pm
Statements Executed | 32453
Statement Execution Time | 58.0ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1999 | 13 | 8 | 24.4ms | 56.1ms | Class::MOP::Mixin::HasMethods::::get_methodClass::MOP::Mixin::HasMethods::get_method
727 | 27 | 11 | 17.9ms | 52.1ms | Class::MOP::Mixin::HasMethods::::add_methodClass::MOP::Mixin::HasMethods::add_method
961 | 8 | 6 | 3.47ms | 30.5ms | Class::MOP::Mixin::HasMethods::::has_methodClass::MOP::Mixin::HasMethods::has_method
2726 | 2 | 1 | 2.81ms | 2.81ms | Class::MOP::Mixin::HasMethods::::_method_mapClass::MOP::Mixin::HasMethods::_method_map
34 | 5 | 4 | 1.86ms | 24.6ms | Class::MOP::Mixin::HasMethods::::get_method_listClass::MOP::Mixin::HasMethods::get_method_list
301 | 1 | 1 | 1.68ms | 2.16ms | Class::MOP::Mixin::HasMethods::::_code_is_mineClass::MOP::Mixin::HasMethods::_code_is_mine
141 | 1 | 1 | 1.40ms | 5.75ms | Class::MOP::Mixin::HasMethods::::wrap_method_bodyClass::MOP::Mixin::HasMethods::wrap_method_body
727 | 1 | 2 | 993µs | 993µs | Class::MOP::Mixin::HasMethods::::CORE:matchClass::MOP::Mixin::HasMethods::CORE:match (opcode)
1 | 1 | 1 | 251µs | 4.45ms | Class::MOP::Mixin::HasMethods::::BEGIN@12Class::MOP::Mixin::HasMethods::BEGIN@12
104 | 3 | 2 | 156µs | 156µs | Class::MOP::Mixin::HasMethods::::wrapped_method_metaclassClass::MOP::Mixin::HasMethods::wrapped_method_metaclass
73 | 5 | 3 | 107µs | 107µs | Class::MOP::Mixin::HasMethods::::method_metaclassClass::MOP::Mixin::HasMethods::method_metaclass
1 | 1 | 1 | 15µs | 18µs | Class::MOP::Mixin::HasMethods::::BEGIN@3Class::MOP::Mixin::HasMethods::BEGIN@3
1 | 1 | 1 | 8µs | 18µs | Class::MOP::Mixin::HasMethods::::BEGIN@4Class::MOP::Mixin::HasMethods::BEGIN@4
1 | 1 | 1 | 7µs | 33µs | Class::MOP::Mixin::HasMethods::::BEGIN@10Class::MOP::Mixin::HasMethods::BEGIN@10
1 | 1 | 1 | 7µs | 31µs | Class::MOP::Mixin::HasMethods::::BEGIN@11Class::MOP::Mixin::HasMethods::BEGIN@11
1 | 1 | 1 | 7µs | 50µs | Class::MOP::Mixin::HasMethods::::BEGIN@14Class::MOP::Mixin::HasMethods::BEGIN@14
0 | 0 | 0 | 0s | 0s | Class::MOP::Mixin::HasMethods::::remove_methodClass::MOP::Mixin::HasMethods::remove_method

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 |  |  |  |  |
3 | 3 | 29µs | 2 | 21µs | # spent 18µs (15+3) within Class::MOP::Mixin::HasMethods::BEGIN@3 which was called # once (15µs+3µs) by Class::MOP::BEGIN@17 at line 3 use strict; # spent 18µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@3 # spent 3µs making 1 call to strict::import
4 | 3 | 45µs | 2 | 28µs | # spent 18µs (8+10) within Class::MOP::Mixin::HasMethods::BEGIN@4 which was called # once (8µs+10µs) by Class::MOP::BEGIN@17 at line 4 use warnings; # spent 18µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@4 # spent 10µs making 1 call to warnings::import
5 |  |  |  |  |
6 | 1 | 700ns |  |  | our $VERSION = '0.98';
7 | 1 | 19µs |  |  | $VERSION = eval $VERSION;
8 | 1 | 500ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
9 |  |  |  |  |
10 | 3 | 32µs | 2 | 60µs | # spent 33µs (7+26) within Class::MOP::Mixin::HasMethods::BEGIN@10 which was called # once (7µs+26µs) by Class::MOP::BEGIN@17 at line 10 use Scalar::Util 'blessed'; # spent 33µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@10 # spent 26µs making 1 call to Exporter::import
11 | 3 | 24µs | 2 | 55µs | # spent 31µs (7+24) within Class::MOP::Mixin::HasMethods::BEGIN@11 which was called # once (7µs+24µs) by Class::MOP::BEGIN@17 at line 11 use Carp 'confess'; # spent 31µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@11 # spent 24µs making 1 call to Exporter::import
12 | 3 | 123µs | 2 | 4.50ms | # spent 4.45ms (251µs+4.20) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called # once (251µs+4.20ms) by Class::MOP::BEGIN@17 at line 12 use Sub::Name 'subname'; # spent 4.45ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12 # spent 44µs making 1 call to Exporter::import
13 |  |  |  |  |
14 | 3 | 458µs | 2 | 93µs | # spent 50µs (7+43) within Class::MOP::Mixin::HasMethods::BEGIN@14 which was called # once (7µs+43µs) by Class::MOP::BEGIN@17 at line 14 use base 'Class::MOP::Mixin'; # spent 50µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@14 # spent 43µs making 1 call to base::import
15 |  |  |  |  |
16 | 73 | 182µs |  |  | # spent 107µs within Class::MOP::Mixin::HasMethods::method_metaclass which was called 73 times, avg 1µs/call: # 66 times (96µs+0s) by Class::MOP::Mixin::HasMethods::wrap_method_body at line 31, avg 1µs/call # 2 times (4µs+0s) by Class::MOP::Attribute::get_write_method_ref at line 209 of Class/MOP/Attribute.pm, avg 2µs/call # 2 times (3µs+0s) by Moose::Meta::Class::reinitialize at line 151 of Moose/Meta/Class.pm, avg 2µs/call # 2 times (2µs+0s) by List::MoreUtils::all at line 407 of Moose/Meta/Class.pm, avg 1µs/call # once (900ns+0s) by Moose::Meta::Class::_reinitialize_with at line 418 of Moose/Meta/Class.pm sub method_metaclass { $_[0]->{'method_metaclass'} }
17 | 104 | 272µs |  |  | # spent 156µs within Class::MOP::Mixin::HasMethods::wrapped_method_metaclass which was called 104 times, avg 1µs/call: # 100 times (149µs+0s) by Class::MOP::Class::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Class.pm:678] at line 651 of Class/MOP/Class.pm, avg 1µs/call # 2 times (4µs+0s) by Moose::Meta::Class::reinitialize at line 151 of Moose/Meta/Class.pm, avg 2µs/call # 2 times (3µs+0s) by List::MoreUtils::all at line 407 of Moose/Meta/Class.pm, avg 1µs/call sub wrapped_method_metaclass { $_[0]->{'wrapped_method_metaclass'} }
18 |  |  |  |  |
19 |  |  |  |  | # This doesn't always get initialized in a constructor because there is a
20 |  |  |  |  | # weird object construction path for subclasses of Class::MOP::Class. At one
21 |  |  |  |  | # point, this always got initialized by calling into the XS code first, but
22 |  |  |  |  | # that is no longer guaranteed to happen.
23 | 2726 | 5.13ms |  |  | # spent 2.81ms within Class::MOP::Mixin::HasMethods::_method_map which was called 2726 times, avg 1µs/call: # 1999 times (1.92ms+0s) by Class::MOP::Mixin::HasMethods::get_method at line 99, avg 959ns/call # 727 times (894µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 60, avg 1µs/call sub _method_map { $_[0]->{'methods'} ||= {} }
24 |  |  |  |  |
25 |  |  |  |  | # spent 5.75ms (1.40+4.35) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 141 times, avg 41µs/call: # 141 times (1.40ms+4.35ms) by Class::MOP::Mixin::HasMethods::get_method at line 123, avg 41µs/call sub wrap_method_body {
26 | 423 | 1.27ms |  |  | my ( $self, %args ) = @_;
27 |  |  |  |  |
28 |  |  |  |  | ( 'CODE' eq ref $args{body} )
29 |  |  |  |  | || confess "Your code block must be a CODE reference";
30 |  |  |  |  |
31 |  |  |  |  | $self->method_metaclass->wrap( # spent 4.04ms making 141 calls to Class::MOP::Method::wrap, avg 29µs/call # spent 144µs making 75 calls to Moose::Meta::Role::method_metaclass, avg 2µs/call # spent 96µs making 66 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 1µs/call # spent 76µs making 141 calls to Class::MOP::Package::name, avg 540ns/call
32 |  |  |  |  | package_name => $self->name,
33 |  |  |  |  | %args,
34 |  |  |  |  | );
35 |  |  |  |  | }
36 |  |  |  |  |
37 |  |  |  |  | # spent 52.1ms (17.9+34.2) within Class::MOP::Mixin::HasMethods::add_method which was called 727 times, avg 72µs/call: # 216 times (5.55ms+4.36ms) by Class::MOP::Attribute::install_accessors at line 358 of Class/MOP/Attribute.pm, avg 46µs/call # 100 times (2.46ms+1.87ms) by Class::MOP::Class::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Class.pm:678] at line 676 of Class/MOP/Class.pm, avg 43µs/call # 68 times (1.74ms+11.1ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 163 of Moose/Meta/Role/Application/ToClass.pm, avg 188µs/call # 68 times (1.68ms+10.7ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 90 of Moose/Meta/Role/Application/ToRole.pm, avg 182µs/call # 54 times (1.27ms+1.00ms) by Class::MOP::Attribute::install_accessors at line 366 of Class/MOP/Attribute.pm, avg 42µs/call # 52 times (1.38ms+1.12ms) by Class::MOP::Attribute::install_accessors at line 354 of Class/MOP/Attribute.pm, avg 48µs/call # 37 times (961µs+725µs) by Class::MOP::Class::_inline_constructor at line 1064 of Class/MOP/Class.pm, avg 46µs/call # 26 times (513µs+321µs) by Moose::init_meta at line 214 of Moose.pm, avg 32µs/call # 22 times (453µs+313µs) by Moose::Role::init_meta at line 136 of Moose/Role.pm, avg 35µs/call # 20 times (394µs+296µs) by metaclass::import at line 51 of metaclass.pm, avg 34µs/call # 9 times (247µs+1.55ms) by Class::MOP::Class::_immutable_metaclass at line 974 of Class/MOP/Class.pm, avg 200µs/call # 9 times (242µs+177µs) by Class::MOP::Class:::after at line 192 of MooseX/AttributeHelpers/Trait/Base.pm, avg 47µs/call # 8 times (182µs+143µs) by Class::MOP::Attribute::install_accessors at line 362 of Class/MOP/Attribute.pm, avg 41µs/call # 7 times (125µs+92µs) by Moose::BEGIN@37 at line 26 of Moose/Meta/Attribute/Native.pm, avg 31µs/call # 6 times (159µs+106µs) by Class::MOP::Class::_inline_destructor at line 1097 of Class/MOP/Class.pm, avg 44µs/call # 5 times (117µs+73µs) by Class::MOP::Class::create at line 305 of Class/MOP/Class.pm, avg 38µs/call # 3 times (91µs+69µs) by Class::MOP::Attribute::install_accessors at line 370 of Class/MOP/Attribute.pm, avg 54µs/call # 3 times (55µs+34µs) by Moose::BEGIN@26 at line 265 of Moose/Meta/Role.pm, avg 30µs/call # 3 times (50µs+30µs) by Moose::BEGIN@26 at line 273 of Moose/Meta/Role.pm, avg 27µs/call # 3 times (50µs+29µs) by Moose::BEGIN@26 at line 292 of Moose/Meta/Role.pm, avg 26µs/call # 2 times (39µs+22µs) by Moose::BEGIN@26 at line 110 of Moose/Meta/Role.pm, avg 31µs/call # once (23µs+29µs) by Moose::Exporter::BEGIN@11 at line 501 of Class/MOP.pm # once (17µs+16µs) by Moose::Exporter::BEGIN@11 at line 541 of Class/MOP.pm # once (18µs+12µs) by Moose::BEGIN@26 at line 100 of Moose/Meta/Role.pm # once (18µs+11µs) by Moose::BEGIN@26 at line 90 of Moose/Meta/Role.pm # once (17µs+10µs) by Moose::BEGIN@26 at line 115 of Moose/Meta/Role.pm # once (16µs+10µs) by Moose::BEGIN@26 at line 95 of Moose/Meta/Role.pm sub add_method {
38 | 8853 | 21.1ms |  |  | my ( $self, $method_name, $method ) = @_;
39 |  |  |  |  | ( defined $method_name && length $method_name )
40 |  |  |  |  | || confess "You must define a method name";
41 |  |  |  |  |
42 |  |  |  |  | my $body;
43 |  |  |  |  | if ( blessed($method) ) { # spent 482µs making 727 calls to Scalar::Util::blessed, avg 663ns/call
44 |  |  |  |  | $body = $method->body; # spent 379µs making 630 calls to Class::MOP::Method::body, avg 602ns/call
45 |  |  |  |  | if ( $method->package_name ne $self->name ) { # spent 21.1ms making 145 calls to Class::MOP::Method::clone, avg 145µs/call # spent 365µs making 775 calls to Class::MOP::Package::name, avg 470ns/call # spent 311µs making 630 calls to Class::MOP::Method::package_name, avg 493ns/call # spent 122µs making 145 calls to UNIVERSAL::can, avg 838ns/call
46 |  |  |  |  | $method = $method->clone(
47 |  |  |  |  | package_name => $self->name,
48 |  |  |  |  | name => $method_name,
49 |  |  |  |  | ) if $method->can('clone');
50 |  |  |  |  | }
51 |  |  |  |  |
52 |  |  |  |  | $method->attach_to_class($self); # spent 2.77ms making 630 calls to Class::MOP::Method::attach_to_class, avg 4µs/call
53 |  |  |  |  | }
54 |  |  |  |  | else {
55 |  |  |  |  | # If a raw code reference is supplied, its method object is not created.
56 |  |  |  |  | # The method object won't be created until required.
57 |  |  |  |  | $body = $method;
58 |  |  |  |  | }
59 |  |  |  |  |
60 |  |  |  |  | $self->_method_map->{$method_name} = $method; # spent 894µs making 727 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call
61 |  |  |  |  |
62 |  |  |  |  | my ( $current_package, $current_name ) = Class::MOP::get_code_info($body); # spent 887µs making 727 calls to Class::MOP::get_code_info, avg 1µs/call
63 |  |  |  |  |
64 |  |  |  |  | if ( !defined $current_name || $current_name =~ /^__ANON__/ ) { # spent 993µs making 727 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 1µs/call
65 |  |  |  |  | my $full_method_name = ( $self->name . '::' . $method_name ); # spent 346µs making 525 calls to Class::MOP::Package::name, avg 658ns/call
66 |  |  |  |  | subname( $full_method_name => $body ); # spent 1.51ms making 525 calls to Sub::Name::subname, avg 3µs/call
67 |  |  |  |  | }
68 |  |  |  |  |
69 |  |  |  |  | $self->add_package_symbol(
70 |  |  |  |  | { sigil => '&', type => 'CODE', name => $method_name }, # spent 4.08ms making 727 calls to Class::MOP::Package::add_package_symbol, avg 6µs/call
71 |  |  |  |  | $body,
72 |  |  |  |  | );
73 |  |  |  |  | }
74 |  |  |  |  |
75 |  |  |  |  | # spent 2.16ms (1.68+477µs) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 301 times, avg 7µs/call: # 301 times (1.68ms+477µs) by Class::MOP::Mixin::HasMethods::get_method at line 117, avg 7µs/call sub _code_is_mine {
76 | 903 | 2.28ms |  |  | my ( $self, $code ) = @_;
77 |  |  |  |  |
78 |  |  |  |  | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); # spent 320µs making 301 calls to Class::MOP::get_code_info, avg 1µs/call
79 |  |  |  |  |
80 |  |  |  |  | return $code_package && $code_package eq $self->name # spent 157µs making 301 calls to Class::MOP::Package::name, avg 521ns/call
81 |  |  |  |  | || ( $code_package eq 'constant' && $code_name eq '__ANON__' );
82 |  |  |  |  | }
83 |  |  |  |  |
84 |  |  |  |  | # spent 30.5ms (3.47+27.0) within Class::MOP::Mixin::HasMethods::has_method which was called 961 times, avg 32µs/call: # 720 times (2.50ms+20.1ms) by Class::MOP::Mixin::HasMethods::get_method_list at line 151, avg 31µs/call # 69 times (266µs+1.96ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 77 of Moose/Meta/Role/Application/ToRole.pm, avg 32µs/call # 68 times (266µs+1.95ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 156 of Moose/Meta/Role/Application/ToClass.pm, avg 33µs/call # 37 times (155µs+1.10ms) by Class::MOP::Class::_inline_constructor at line 1041 of Class/MOP/Class.pm, avg 34µs/call # 27 times (131µs+752µs) by Moose::init_meta at line 214 of Moose.pm, avg 33µs/call # 24 times (88µs+638µs) by Class::MOP::Class::find_all_methods_by_name at line 763 of Class/MOP/Class.pm, avg 30µs/call # 9 times (33µs+257µs) by Class::MOP::Class:::after at line 177 of MooseX/AttributeHelpers/Trait/Base.pm, avg 32µs/call # 7 times (30µs+229µs) by Class::MOP::Class::_inline_destructor at line 1076 of Class/MOP/Class.pm, avg 37µs/call sub has_method {
85 | 2883 | 3.02ms |  |  | my ( $self, $method_name ) = @_;
86 |  |  |  |  |
87 |  |  |  |  | ( defined $method_name && length $method_name )
88 |  |  |  |  | || confess "You must define a method name";
89 |  |  |  |  |
90 |  |  |  |  | return defined( $self->get_method($method_name) ); # spent 27.0ms making 961 calls to Class::MOP::Mixin::HasMethods::get_method, avg 28µs/call
91 |  |  |  |  | }
92 |  |  |  |  |
93 |  |  |  |  | # spent 56.1ms (24.4+31.7) within Class::MOP::Mixin::HasMethods::get_method which was called 1999 times, avg 28µs/call: # 961 times (11.2ms+15.8ms) by Class::MOP::Mixin::HasMethods::has_method at line 90, avg 28µs/call # 325 times (3.84ms+5.46ms) by Class::MOP::Class::find_method_by_name at line 729 of Class/MOP/Class.pm, avg 29µs/call # 233 times (2.99ms+3.50ms) by Class::MOP::Class::find_next_method_by_name at line 779 of Class/MOP/Class.pm, avg 28µs/call # 110 times (1.49ms+2.08ms) by Moose::Meta::Attribute::_process_accessors at line 569 of Moose/Meta/Attribute.pm, avg 32µs/call # 100 times (1.15ms+1.29ms) by Class::MOP::Class::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Class/MOP/Class.pm:678] at line 653 of Class/MOP/Class.pm, avg 24µs/call # 68 times (848µs+678µs) by Moose::Meta::Role::Application::ToClass::apply_methods at line 163 of Moose/Meta/Role/Application/ToClass.pm, avg 22µs/call # 68 times (818µs+647µs) by Moose::Meta::Role::Application::ToRole::apply_methods at line 90 of Moose/Meta/Role/Application/ToRole.pm, avg 22µs/call # 64 times (743µs+587µs) by Class::MOP::Class::get_all_methods at line 743 of Class/MOP/Class.pm, avg 21µs/call # 31 times (773µs+658µs) by Class::MOP::Attribute::get_read_method_ref at line 184 of Class/MOP/Attribute.pm, avg 46µs/call # 26 times (301µs+236µs) by MooseX::AttributeHelpers::Trait::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/AttributeHelpers/Trait/Base.pm:51] at line 46 of MooseX/AttributeHelpers/Trait/Base.pm, avg 21µs/call # 10 times (200µs+710µs) by Moose::Meta::Role::find_method_by_name at line 387 of Moose/Meta/Role.pm, avg 91µs/call # 2 times (26µs+21µs) by Moose::Meta::Role::Application::ToRole::apply_methods at line 77 of Moose/Meta/Role/Application/ToRole.pm, avg 23µs/call # once (12µs+9µs) by Class::MOP::Class::is_pristine at line 857 of Class/MOP/Class.pm sub get_method {
94 | 15678 | 22.9ms |  |  | my ( $self, $method_name ) = @_;
95 |  |  |  |  |
96 |  |  |  |  | ( defined $method_name && length $method_name )
97 |  |  |  |  | || confess "You must define a method name";
98 |  |  |  |  |
99 |  |  |  |  | my $method_map = $self->_method_map; # spent 1.92ms making 1999 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 959ns/call
100 |  |  |  |  | my $map_entry = $method_map->{$method_name};
101 |  |  |  |  | my $code = $self->get_package_symbol( # spent 19.3ms making 1999 calls to Class::MOP::Package::get_package_symbol, avg 10µs/call
102 |  |  |  |  | {
103 |  |  |  |  | name => $method_name,
104 |  |  |  |  | sigil => '&',
105 |  |  |  |  | type => 'CODE',
106 |  |  |  |  | }
107 |  |  |  |  | );
108 |  |  |  |  |
109 |  |  |  |  | # This seems to happen in some weird cases where methods modifiers are
110 |  |  |  |  | # added via roles or some other such bizareness. Honestly, I don't totally
111 |  |  |  |  | # understand this, but returning the entry works, and keeps various MX
112 |  |  |  |  | # modules from blowing up. - DR
113 |  |  |  |  | return $map_entry if blessed $map_entry && !$code; # spent 1.41ms making 1999 calls to Scalar::Util::blessed, avg 705ns/call
114 |  |  |  |  |
115 |  |  |  |  | return $map_entry if blessed $map_entry && $map_entry->body == $code; # spent 730µs making 1999 calls to Scalar::Util::blessed, avg 365ns/call # spent 402µs making 596 calls to Class::MOP::Method::body, avg 675ns/call
116 |  |  |  |  |
117 |  |  |  |  | unless ($map_entry) { # spent 2.16ms making 301 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 7µs/call
118 |  |  |  |  | return unless $code && $self->_code_is_mine($code);
119 |  |  |  |  | }
120 |  |  |  |  |
121 |  |  |  |  | $code ||= $map_entry;
122 |  |  |  |  |
123 |  |  |  |  | return $method_map->{$method_name} = $self->wrap_method_body( # spent 5.75ms making 141 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 41µs/call
124 |  |  |  |  | body => $code,
125 |  |  |  |  | name => $method_name,
126 |  |  |  |  | associated_metaclass => $self,
127 |  |  |  |  | );
128 |  |  |  |  | }
129 |  |  |  |  |
130 |  |  |  |  | sub remove_method {
131 |  |  |  |  | my ( $self, $method_name ) = @_;
132 |  |  |  |  | ( defined $method_name && length $method_name )
133 |  |  |  |  | || confess "You must define a method name";
134 |  |  |  |  |
135 |  |  |  |  | my $removed_method = delete $self->_full_method_map->{$method_name};
136 |  |  |  |  |
137 |  |  |  |  | $self->remove_package_symbol(
138 |  |  |  |  | { sigil => '&', type => 'CODE', name => $method_name } );
139 |  |  |  |  |
140 |  |  |  |  | $removed_method->detach_from_class
141 |  |  |  |  | if $removed_method && blessed $removed_method;
142 |  |  |  |  |
143 |  |  |  |  | # still valid, since we just removed the method from the map
144 |  |  |  |  | $self->update_package_cache_flag;
145 |  |  |  |  |
146 |  |  |  |  | return $removed_method;
147 |  |  |  |  | }
148 |  |  |  |  |
149 |  |  |  |  | # spent 24.6ms (1.86+22.7) within Class::MOP::Mixin::HasMethods::get_method_list which was called 34 times, avg 722µs/call: # 13 times (707µs+8.63ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 151 of Moose/Meta/Role/Application/ToClass.pm, avg 719µs/call # 13 times (641µs+7.59ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 74 of Moose/Meta/Role/Application/ToRole.pm, avg 633µs/call # 5 times (251µs+3.43ms) by Class::MOP::Class::get_all_methods at line 743 of Class/MOP/Class.pm, avg 735µs/call # 2 times (219µs+2.47ms) by MooseX::AttributeHelpers::Trait::Base::__ANON__[/usr/local/lib/perl5/site_perl/5.10.1/MooseX/AttributeHelpers/Trait/Base.pm:51] at line 49 of MooseX/AttributeHelpers/Trait/Base.pm, avg 1.34ms/call # once (42µs+572µs) by Class::MOP::Class::is_pristine at line 857 of Class/MOP/Class.pm sub get_method_list {
150 | 788 | 1.16ms |  |  | my $self = shift;
151 |  |  |  |  | return grep { $self->has_method($_) } keys %{ $self->namespace }; # spent 22.6ms making 720 calls to Class::MOP::Mixin::HasMethods::has_method, avg 31µs/call # spent 92µs making 34 calls to Class::MOP::Package::namespace, avg 3µs/call
152 |  |  |  |  | }
153 |  |  |  |  |
154 | 1 | 4µs |  |  | 1;
155 |  |  |  |  |
156 |  |  |  |  | __END__
157 |  |  |  |  |
158 |  |  |  |  | =pod
159 |  |  |  |  |
160 |  |  |  |  | =head1 NAME
161 |  |  |  |  |
162 |  |  |  |  | Class::MOP::Mixin::HasMethods - Methods for metaclasses which have methods
163 |  |  |  |  |
164 |  |  |  |  | =head1 DESCRIPTION
165 |  |  |  |  |
166 |  |  |  |  | This class implements methods for metaclasses which have methods
167 |  |  |  |  | (L<Class::MOP::Package> and L<Moose::Meta::Role>). See L<Class::MOP::Package>
168 |  |  |  |  | for API details.
169 |  |  |  |  |
170 |  |  |  |  | =head1 AUTHORS
171 |  |  |  |  |
172 |  |  |  |  | Dave Rolsky E<lt>autarch@urth.orgE<gt>
173 |  |  |  |  |
174 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
175 |  |  |  |  |
176 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
177 |  |  |  |  |
178 |  |  |  |  | L<http://www.iinteractive.com>
179 |  |  |  |  |
180 |  |  |  |  | This library is free software; you can redistribute it and/or modify
181 |  |  |  |  | it under the same terms as Perl itself.
182 |  |  |  |  |
183 |  |  |  |  | =cut
|  |  |  |  | # spent 993µs within Class::MOP::Mixin::HasMethods::CORE:match which was called 727 times, avg 1µs/call: # 727 times (993µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 64 of Class/MOP/Mixin/HasMethods.pm, avg 1µs/call sub Class::MOP::Mixin::HasMethods::CORE:match; # xsub