← Index
NYTProf Performance Profile   « line view »
For examples/Atom-timer.pl
  Run on Mon Aug 12 14:45:28 2013
Reported on Mon Aug 12 14:46:14 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Mixin/HasMethods.pm
StatementsExecuted 31703 statements in 66.2ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
913241223.9ms71.3msClass::MOP::Mixin::HasMethods::::add_methodClass::MOP::Mixin::HasMethods::add_method
19972111.1ms44.9msClass::MOP::Mixin::HasMethods::::_get_maybe_raw_methodClass::MOP::Mixin::HasMethods::_get_maybe_raw_method
16611396.28ms54.0msClass::MOP::Mixin::HasMethods::::get_methodClass::MOP::Mixin::HasMethods::get_method
913116.15ms7.49msClass::MOP::Mixin::HasMethods::::update_package_cache_flagClass::MOP::Mixin::HasMethods::update_package_cache_flag
44214.35ms15.1msClass::MOP::Mixin::HasMethods::::_full_method_mapClass::MOP::Mixin::HasMethods::_full_method_map
183111.52ms5.35msClass::MOP::Mixin::HasMethods::::wrap_method_bodyClass::MOP::Mixin::HasMethods::wrap_method_body
305111.32ms1.69msClass::MOP::Mixin::HasMethods::::_code_is_mineClass::MOP::Mixin::HasMethods::_code_is_mine
3361071.21ms4.72msClass::MOP::Mixin::HasMethods::::has_methodClass::MOP::Mixin::HasMethods::has_method
91311671µs671µsClass::MOP::Mixin::HasMethods::::CORE:matchClass::MOP::Mixin::HasMethods::CORE:match (opcode)
5565667µs30.8msClass::MOP::Mixin::HasMethods::::_add_meta_methodClass::MOP::Mixin::HasMethods::_add_meta_method
111438µs2.01msClass::MOP::Mixin::HasMethods::::BEGIN@12Class::MOP::Mixin::HasMethods::BEGIN@12
111307µs418µsClass::MOP::Mixin::HasMethods::::BEGIN@13Class::MOP::Mixin::HasMethods::BEGIN@13
4344152µs14.3msClass::MOP::Mixin::HasMethods::::_get_local_methodsClass::MOP::Mixin::HasMethods::_get_local_methods
252123µs23µsClass::MOP::Mixin::HasMethods::::_meta_method_classClass::MOP::Mixin::HasMethods::_meta_method_class
212222µs22µsClass::MOP::Mixin::HasMethods::::reset_package_cache_flagClass::MOP::Mixin::HasMethods::reset_package_cache_flag
11110µs10µsClass::MOP::Mixin::HasMethods::::BEGIN@2Class::MOP::Mixin::HasMethods::BEGIN@2
1119µs1.01msClass::MOP::Mixin::HasMethods::::get_method_listClass::MOP::Mixin::HasMethods::get_method_list
1116µs31µsClass::MOP::Mixin::HasMethods::::BEGIN@15Class::MOP::Mixin::HasMethods::BEGIN@15
1116µs23µsClass::MOP::Mixin::HasMethods::::BEGIN@16Class::MOP::Mixin::HasMethods::BEGIN@16
1116µs9µsClass::MOP::Mixin::HasMethods::::BEGIN@10Class::MOP::Mixin::HasMethods::BEGIN@10
1116µs51µsClass::MOP::Mixin::HasMethods::::BEGIN@21Class::MOP::Mixin::HasMethods::BEGIN@21
1115µs27µsClass::MOP::Mixin::HasMethods::::BEGIN@17Class::MOP::Mixin::HasMethods::BEGIN@17
1115µs16µsClass::MOP::Mixin::HasMethods::::BEGIN@9Class::MOP::Mixin::HasMethods::BEGIN@9
1113µs3µsClass::MOP::Mixin::HasMethods::::BEGIN@19Class::MOP::Mixin::HasMethods::BEGIN@19
0000s0sClass::MOP::Mixin::HasMethods::::_get_overloaded_operator_bodyClass::MOP::Mixin::HasMethods::_get_overloaded_operator_body
0000s0sClass::MOP::Mixin::HasMethods::::_overload_mapClass::MOP::Mixin::HasMethods::_overload_map
0000s0sClass::MOP::Mixin::HasMethods::::_restore_metamethods_fromClass::MOP::Mixin::HasMethods::_restore_metamethods_from
0000s0sClass::MOP::Mixin::HasMethods::::_wrap_overloadClass::MOP::Mixin::HasMethods::_wrap_overload
0000s0sClass::MOP::Mixin::HasMethods::::add_overloaded_operatorClass::MOP::Mixin::HasMethods::add_overloaded_operator
0000s0sClass::MOP::Mixin::HasMethods::::get_all_overloaded_operatorsClass::MOP::Mixin::HasMethods::get_all_overloaded_operators
0000s0sClass::MOP::Mixin::HasMethods::::get_overload_listClass::MOP::Mixin::HasMethods::get_overload_list
0000s0sClass::MOP::Mixin::HasMethods::::get_overloaded_operatorClass::MOP::Mixin::HasMethods::get_overloaded_operator
0000s0sClass::MOP::Mixin::HasMethods::::has_overloaded_operatorClass::MOP::Mixin::HasMethods::has_overloaded_operator
0000s0sClass::MOP::Mixin::HasMethods::::is_overloadedClass::MOP::Mixin::HasMethods::is_overloaded
0000s0sClass::MOP::Mixin::HasMethods::::overload_operatorsClass::MOP::Mixin::HasMethods::overload_operators
0000s0sClass::MOP::Mixin::HasMethods::::remove_methodClass::MOP::Mixin::HasMethods::remove_method
0000s0sClass::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
1package Class::MOP::Mixin::HasMethods;
2
# spent 10µs within Class::MOP::Mixin::HasMethods::BEGIN@2 which was called: # once (10µs+0s) by Class::MOP::BEGIN@25 at line 4
BEGIN {
314µs $Class::MOP::Mixin::HasMethods::AUTHORITY = 'cpan:STEVAN';
4130µs110µs}
# spent 10µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@2
5{
62800ns $Class::MOP::Mixin::HasMethods::VERSION = '2.1005';
7}
8
9219µs226µs
# spent 16µs (5+10) within Class::MOP::Mixin::HasMethods::BEGIN@9 which was called: # once (5µs+10µs) by Class::MOP::BEGIN@25 at line 9
use strict;
# spent 16µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@9 # spent 10µs making 1 call to strict::import
10218µs212µs
# spent 9µs (6+3) within Class::MOP::Mixin::HasMethods::BEGIN@10 which was called: # once (6µs+3µs) by Class::MOP::BEGIN@25 at line 10
use warnings;
# spent 9µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@10 # spent 3µs making 1 call to warnings::import
11
12286µs12.01ms
# spent 2.01ms (438µs+1.58) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called: # once (438µs+1.58ms) by Class::MOP::BEGIN@25 at line 12
use Class::MOP::Method::Meta;
# spent 2.01ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12
13288µs1418µs
# spent 418µs (307+112) within Class::MOP::Mixin::HasMethods::BEGIN@13 which was called: # once (307µs+112µs) by Class::MOP::BEGIN@25 at line 13
use Class::MOP::Method::Overload;
# spent 418µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@13
14
15221µs255µs
# spent 31µs (6+24) within Class::MOP::Mixin::HasMethods::BEGIN@15 which was called: # once (6µs+24µs) by Class::MOP::BEGIN@25 at line 15
use Scalar::Util 'blessed', 'reftype';
# spent 31µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@15 # spent 24µs making 1 call to Exporter::import
16220µs241µs
# spent 23µ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 23µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@16 # spent 18µs making 1 call to Exporter::import
17219µs249µs
# spent 27µs (5+22) within Class::MOP::Mixin::HasMethods::BEGIN@17 which was called: # once (5µs+22µs) by Class::MOP::BEGIN@25 at line 17
use Sub::Name 'subname';
# spent 27µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@17 # spent 22µs making 1 call to Exporter::import
18
19219µs13µs
# spent 3µs within Class::MOP::Mixin::HasMethods::BEGIN@19 which was called: # once (3µs+0s) by Class::MOP::BEGIN@25 at line 19
use overload ();
# spent 3µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@19
20
2121.11ms296µs
# spent 51µs (6+45) within Class::MOP::Mixin::HasMethods::BEGIN@21 which was called: # once (6µs+45µs) by Class::MOP::BEGIN@25 at line 21
use base 'Class::MOP::Mixin';
# spent 51µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@21 # spent 45µs making 1 call to base::import
22
232538µs
# spent 23µs within Class::MOP::Mixin::HasMethods::_meta_method_class which was called 25 times, avg 924ns/call: # 23 times (20µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 891ns/call # 2 times (3µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 31, avg 1µs/call
sub _meta_method_class { 'Class::MOP::Method::Meta' }
24
25
# spent 30.8ms (667µs+30.1) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 55 times, avg 560µs/call: # 20 times (224µs+8.33ms) by metaclass::import at line 49 of metaclass.pm, avg 428µs/call # 19 times (212µs+8.91ms) by Moose::Role::init_meta at line 155 of Moose/Role.pm, avg 480µs/call # 10 times (127µs+6.84ms) by Class::MOP::Class::create at line 448 of Class/MOP/Class.pm, avg 697µs/call # 4 times (46µs+4.72ms) by Moose::init_meta at line 217 of Moose.pm, avg 1.19ms/call # once (35µs+908µs) by Moose::Exporter::BEGIN@13 at line 660 of Class/MOP.pm # once (23µs+413µs) by Moose::Exporter::BEGIN@13 at line 666 of Class/MOP.pm
sub _add_meta_method {
26557µs my $self = shift;
275514µs my ($name) = @_;
2855182µs1106.64ms my $existing_method = $self->can('find_method_by_name')
# spent 6.27ms making 36 calls to Class::MOP::Class::find_method_by_name, avg 174µs/call # spent 330µs making 19 calls to Moose::Meta::Role::find_method_by_name, avg 17µs/call # spent 39µs making 55 calls to UNIVERSAL::can, avg 704ns/call
29 ? $self->find_method_by_name($name)
30 : $self->get_method($name);
315519µs45µs return if $existing_method
# spent 3µs making 2 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 1µs/call # spent 2µs making 2 calls to UNIVERSAL::isa, avg 1µs/call
32 && $existing_method->isa($self->_meta_method_class);
3355347µs22023.5ms $self->add_method(
# spent 13.9ms making 32 calls to Moose::Meta::Method::Meta::wrap, avg 434µs/call # spent 6.52ms making 23 calls to Class::MOP::Method::Meta::wrap, avg 283µs/call # spent 3.00ms making 55 calls to Class::MOP::Mixin::HasMethods::add_method, avg 55µs/call # spent 28µs making 55 calls to Class::MOP::Package::name, avg 504ns/call # spent 20µs making 23 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 891ns/call # spent 16µs making 19 calls to Moose::Meta::Role::_meta_method_class, avg 826ns/call # spent 12µs making 13 calls to Moose::Meta::Class::_meta_method_class, avg 962ns/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 5.35ms (1.52+3.83) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 183 times, avg 29µs/call: # 183 times (1.52ms+3.83ms) by Class::MOP::Mixin::HasMethods::get_method at line 124, avg 29µs/call
sub wrap_method_body {
43183179µs my ( $self, %args ) = @_;
44
45183335µs18370µs ( 'CODE' eq reftype $args{body} )
# spent 70µs making 183 calls to Scalar::Util::reftype, avg 384ns/call
46 || confess "Your code block must be a CODE reference";
47
481831.03ms5493.76ms $self->method_metaclass->wrap(
# spent 3.52ms making 183 calls to Class::MOP::Method::wrap, avg 19µs/call # spent 122µs making 96 calls to Moose::Meta::Role::method_metaclass, avg 1µs/call # spent 77µs making 183 calls to Class::MOP::Package::name, avg 420ns/call # spent 46µs making 87 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 532ns/call
49 package_name => $self->name,
50 %args,
51 );
52}
53
54
# spent 71.3ms (23.9+47.4) within Class::MOP::Mixin::HasMethods::add_method which was called 913 times, avg 78µs/call: # 199 times (6.41ms+10.1ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 173 of Moose/Meta/Role/Application/ToClass.pm, avg 83µs/call # 194 times (6.76ms+10.7ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 99 of Moose/Meta/Role/Application/ToRole.pm, avg 90µs/call # 155 times (3.30ms+14.9ms) by Class::MOP::Attribute::install_accessors at line 428 of Class/MOP/Attribute.pm, avg 118µs/call # 68 times (1.37ms+2.14ms) by Class::MOP::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Class.pm:1072] at line 1070 of Class/MOP/Class.pm, avg 52µs/call # 67 times (1.40ms+2.26ms) by Class::MOP::Attribute::install_accessors at line 424 of Class/MOP/Attribute.pm, avg 55µs/call # 55 times (1.19ms+1.81ms) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 33, avg 55µs/call # 50 times (1.01ms+1.55ms) by Class::MOP::Attribute::install_accessors at line 436 of Class/MOP/Attribute.pm, avg 51µs/call # 31 times (637µs+1.01ms) by Class::MOP::Class::_inline_constructor at line 1452 of Class/MOP/Class.pm, avg 53µs/call # 26 times (586µs+849µs) by Moose::Meta::Attribute::install_delegation at line 1125 of Moose/Meta/Attribute.pm, avg 55µs/call # 21 times (435µs+656µs) by Moose::Meta::Class::add_override_method_modifier at line 595 of Moose/Meta/Class.pm, avg 52µs/call # 14 times (286µs+561µs) by Class::MOP::MiniTrait::apply at line 29 of Class/MOP/MiniTrait.pm, avg 61µs/call # 8 times (162µs+249µs) by Class::MOP::Attribute::install_accessors at line 432 of Class/MOP/Attribute.pm, avg 51µs/call # 7 times (102µs+179µs) by Moose::BEGIN@46 at line 30 of Moose/Meta/Attribute/Native.pm, avg 40µs/call # 3 times (43µs+69µs) by Moose::BEGIN@35 at line 318 of Moose/Meta/Role.pm, avg 37µs/call # 3 times (41µs+70µs) by Moose::BEGIN@35 at line 326 of Moose/Meta/Role.pm, avg 37µs/call # 3 times (41µs+65µs) by Moose::BEGIN@35 at line 345 of Moose/Meta/Role.pm, avg 35µs/call # 2 times (27µs+44µs) by Moose::BEGIN@35 at line 119 of Moose/Meta/Role.pm, avg 35µs/call # once (28µs+52µs) by MooseX::Storage::import at line 23 of MooseX/Storage.pm # once (25µs+30µs) by Class::MOP::Class::_inline_destructor at line 1490 of Class/MOP/Class.pm # once (17µs+31µs) by Moose::Exporter::BEGIN@13 at line 486 of Class/MOP.pm # once (15µs+24µs) by Moose::BEGIN@35 at line 99 of Moose/Meta/Role.pm # once (14µs+24µs) by Moose::BEGIN@35 at line 109 of Moose/Meta/Role.pm # once (14µs+23µs) by Moose::BEGIN@35 at line 124 of Moose/Meta/Role.pm # once (14µs+23µs) by Moose::BEGIN@35 at line 104 of Moose/Meta/Role.pm
sub add_method {
55913241µs my ( $self, $method_name, $method ) = @_;
56913201µs ( defined $method_name && length $method_name )
57 || confess "You must define a method name";
58
599131.75ms913436µs my $package_name = $self->name;
# spent 436µs making 913 calls to Class::MOP::Package::name, avg 478ns/call
60
61913400ns my $body;
629133.24ms18031.01ms if ( blessed($method) && $method->isa('Class::MOP::Method') ) {
# spent 556µs making 913 calls to Scalar::Util::blessed, avg 609ns/call # spent 450µs making 890 calls to UNIVERSAL::isa, avg 506ns/call
638901.55ms890361µs $body = $method->body;
# spent 361µs making 890 calls to Class::MOP::Method::body, avg 405ns/call
648901.86ms12984.89ms if ( $method->package_name ne $package_name ) {
# spent 4.54ms making 408 calls to Class::MOP::Method::clone, avg 11µs/call # spent 352µs making 890 calls to Class::MOP::Method::package_name, avg 396ns/call
65 $method = $method->clone(
66 package_name => $package_name,
67 name => $method_name,
68 );
69 }
70
71890761µs8902.83ms $method->attach_to_class($self);
# spent 2.83ms making 890 calls to Class::MOP::Method::attach_to_class, avg 3µ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.
76234µs $body = $method;
77 }
78
799133.29ms9371.63ms $self->_method_map->{$method_name} = $method;
# spent 1.62ms making 913 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call # spent 11µs making 24 calls to Class::MOP::Method::body, avg 475ns/call
80
819134.93ms913812µs my ($current_package, $current_name) = Class::MOP::get_code_info($body);
# spent 812µs making 913 calls to Class::MOP::get_code_info, avg 889ns/call
82
839133.59ms13611.70ms subname($package_name . '::' . $method_name, $body)
# spent 1.03ms making 448 calls to Sub::Name::subname, avg 2µs/call # spent 671µs making 913 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 735ns/call
84 unless defined $current_name && $current_name !~ /^__ANON__/;
85
869131.17ms91326.2ms $self->add_package_symbol("&$method_name", $body);
# spent 26.2ms making 913 calls to Class::MOP::Package::add_package_symbol, avg 29µs/call
87
88 # we added the method to the method map too, so it's still valid
899132.12ms9137.49ms $self->update_package_cache_flag;
# spent 7.49ms making 913 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 8µs/call
90}
91
92
# spent 1.69ms (1.32+373µs) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 305 times, avg 6µs/call: # 305 times (1.32ms+373µs) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 139, avg 6µs/call
sub _code_is_mine {
9330558µs my ( $self, $code ) = @_;
94
95305711µs305224µs my ( $code_package, $code_name ) = Class::MOP::get_code_info($code);
# spent 224µs making 305 calls to Class::MOP::get_code_info, avg 733ns/call
96
973051.04ms305149µs return ( $code_package && $code_package eq $self->name )
# spent 149µs making 305 calls to Class::MOP::Package::name, avg 490ns/call
98 || ( $code_package eq 'constant' && $code_name eq '__ANON__' );
99}
100
101
# spent 4.72ms (1.21+3.51) within Class::MOP::Mixin::HasMethods::has_method which was called 336 times, avg 14µs/call: # 148 times (723µs+734µs) by Moose::Meta::Class::_inline_create_error at line 850 of Moose/Meta/Class.pm, avg 10µs/call # 35 times (98µs+397µs) by Moose::Meta::Attribute::_process_accessors at line 1070 of Moose/Meta/Attribute.pm, avg 14µs/call # 33 times (74µs+401µs) by Moose::Meta::Role::add_override_method_modifier at line 366 of Moose/Meta/Role.pm, avg 14µs/call # 31 times (84µs+482µs) by Class::MOP::Class::_inline_constructor at line 1424 of Class/MOP/Class.pm, avg 18µs/call # 30 times (76µs+362µs) by Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers at line 137 of Moose/Meta/Role/Application/ToRole.pm, avg 15µs/call # 21 times (58µs+611µs) by Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers at line 207 of Moose/Meta/Role/Application/ToClass.pm, avg 32µs/call # 21 times (46µs+252µs) by Moose::Meta::Class::add_override_method_modifier at line 592 of Moose/Meta/Class.pm, avg 14µs/call # 10 times (31µs+193µs) by Moose::Meta::Role::Application::RoleSummation::check_required_methods at line 106 of Moose/Meta/Role/Application/RoleSummation.pm, avg 22µs/call # 6 times (17µs+66µs) by Class::MOP::Class::find_all_methods_by_name at line 1155 of Class/MOP/Class.pm, avg 14µs/call # once (3µs+13µs) by Class::MOP::Class::_inline_destructor at line 1464 of Class/MOP/Class.pm
sub has_method {
10233666µs my ( $self, $method_name ) = @_;
103
10433671µs ( defined $method_name && length $method_name )
105 || confess "You must define a method name";
106
107336419µs3363.38ms my $method = $self->_get_maybe_raw_method($method_name)
# spent 3.38ms making 336 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 10µs/call
108 or return;
109
110152585µs152129µs return defined($self->_method_map->{$method_name} = $method);
# spent 129µs making 152 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 851ns/call
111}
112
113
# spent 54.0ms (6.28+47.8) within Class::MOP::Mixin::HasMethods::get_method which was called 1661 times, avg 33µs/call: # 438 times (2.17ms+8.21ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 205, avg 24µs/call # 367 times (1.21ms+14.0ms) by Class::MOP::Class::find_method_by_name at line 1123 of Class/MOP/Class.pm, avg 41µs/call # 216 times (650µs+7.46ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 90 of Moose/Meta/Role/Application/ToRole.pm, avg 38µs/call # 199 times (500µs+8.25ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 169 of Moose/Meta/Role/Application/ToClass.pm, avg 44µs/call # 186 times (832µs+3.12ms) by Class::MOP::Class::find_next_method_by_name at line 1171 of Class/MOP/Class.pm, avg 21µs/call # 68 times (187µs+850µs) by Class::MOP::Class::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Class/MOP/Class.pm:1072] at line 1047 of Class/MOP/Class.pm, avg 15µs/call # 63 times (317µs+275µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 163 of Moose/Meta/Role/Application/RoleSummation.pm, avg 9µs/call # 39 times (161µs+1.14ms) by Moose::Meta::Role::find_method_by_name at line 436 of Moose/Meta/Role.pm, avg 33µs/call # 35 times (103µs+655µs) by Moose::Meta::Attribute::_process_accessors at line 1043 of Moose/Meta/Attribute.pm, avg 22µs/call # 26 times (78µs+3.14ms) by Moose::Meta::Attribute::install_delegation at line 1106 of Moose/Meta/Attribute.pm, avg 124µs/call # 19 times (58µs+601µs) by Moose::Role::init_meta at line 145 of Moose/Role.pm, avg 35µs/call # 4 times (11µs+63µs) by Moose::init_meta at line 207 of Moose.pm, avg 18µs/call # once (6µs+5µs) by Class::MOP::Class::find_all_methods_by_name at line 1155 of Class/MOP/Class.pm
sub get_method {
1141661362µs my ( $self, $method_name ) = @_;
115
1161661291µs ( defined $method_name && length $method_name )
117 || confess "You must define a method name";
118
11916612.18ms166141.5ms my $method = $self->_get_maybe_raw_method($method_name)
# spent 41.5ms making 1661 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 25µs/call
120 or return;
121
1226252.36ms1067570µs return $method if blessed($method) && $method->isa('Class::MOP::Method');
# spent 360µs making 625 calls to Scalar::Util::blessed, avg 577ns/call # spent 209µs making 442 calls to UNIVERSAL::isa, avg 474ns/call
123
124183929µs3665.69ms return $self->_method_map->{$method_name} = $self->wrap_method_body(
# spent 5.35ms making 183 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 29µs/call # spent 200µs making 160 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call # spent 133µs making 23 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 44.9ms (11.1+33.8) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 1997 times, avg 22µs/call: # 1661 times (9.83ms+31.7ms) by Class::MOP::Mixin::HasMethods::get_method at line 119, avg 25µs/call # 336 times (1.26ms+2.12ms) by Class::MOP::Mixin::HasMethods::has_method at line 107, avg 10µs/call
sub _get_maybe_raw_method {
1321997238µs my ( $self, $method_name ) = @_;
133
13419978.97ms25459.26ms my $map_entry = $self->_method_map->{$method_name};
# spent 5.81ms making 268 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 22µs/call # spent 3.27ms making 1729 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call # spent 178µs making 548 calls to Class::MOP::Method::body, avg 325ns/call
1351997929µs return $map_entry if defined $map_entry;
136
13714041.53ms140423.0ms my $code = $self->get_package_symbol("&$method_name");
# spent 23.0ms making 1404 calls to Class::MOP::Package::get_package_symbol, avg 16µs/call
138
13914041.83ms3051.69ms return unless $code && $self->_code_is_mine($code);
# spent 1.69ms making 305 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 6µs/call
140
141184233µs return $code;
142}
143
144sub 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
# spent 1.01ms (9µs+999µs) within Class::MOP::Mixin::HasMethods::get_method_list which was called: # once (9µs+999µs) by namespace::autoclean::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/namespace/autoclean.pm:57] at line 45 of namespace/autoclean.pm
sub get_method_list {
1641300ns my $self = shift;
165
16618µs1999µs return keys %{ $self->_full_method_map };
# spent 999µs making 1 call to Class::MOP::Mixin::HasMethods::_full_method_map
167}
168
169
# spent 14.3ms (152µs+14.1) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 43 times, avg 332µs/call: # 17 times (56µs+2.11ms) by Class::MOP::Class::get_all_methods at line 1136 of Class/MOP/Class.pm, avg 128µs/call # 9 times (37µs+5.62ms) by Moose::Meta::Role::Application::ToRole::apply_methods at line 82 of Moose/Meta/Role/Application/ToRole.pm, avg 629µs/call # 9 times (34µs+3.30ms) by Moose::Meta::Role::Application::ToClass::apply_methods at line 162 of Moose/Meta/Role/Application/ToClass.pm, avg 371µs/call # 8 times (24µs+3.08ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 174 of Moose/Meta/Role/Application/RoleSummation.pm, avg 389µs/call
sub _get_local_methods {
170435µs my $self = shift;
171
17243138µs4314.1ms return values %{ $self->_full_method_map };
# spent 14.1ms making 43 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 328µs/call
173}
174
175sub _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
1852137µs
# spent 22µs within Class::MOP::Mixin::HasMethods::reset_package_cache_flag which was called 21 times, avg 1µs/call: # 11 times (12µs+0s) by Moose::Meta::Role::add_role at line 409 of Moose/Meta/Role.pm, avg 1µs/call # 10 times (10µs+0s) by Moose::Meta::Role::Application::ToClass::apply_methods at line 200 of Moose/Meta/Role/Application/ToClass.pm, avg 1µs/call
sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
186
# spent 7.49ms (6.15+1.35) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 913 times, avg 8µs/call: # 913 times (6.15ms+1.35ms) by Class::MOP::Mixin::HasMethods::add_method at line 89, avg 8µs/call
sub update_package_cache_flag {
187913141µ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
19491310.7ms18261.35ms $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
# spent 960µs making 913 calls to mro::get_pkg_gen, avg 1µs/call # spent 388µs making 913 calls to Class::MOP::Package::name, avg 425ns/call
195}
196
197
# spent 15.1ms (4.35+10.8) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 44 times, avg 344µs/call: # 43 times (4.29ms+9.83ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 172, avg 328µs/call # once (60µs+940µs) by Class::MOP::Mixin::HasMethods::get_method_list at line 166
sub _full_method_map {
198443µs my $self = shift;
199
200443.45ms8872µs my $pkg_gen = Class::MOP::check_package_cache_flag($self->name);
# spent 54µs making 44 calls to mro::get_pkg_gen, avg 1µs/call # spent 18µs making 44 calls to Class::MOP::Package::name, avg 409ns/call
201
2024421µs if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) {
203 # forcibly reify all method map entries
204 $self->get_method($_)
20524452µs46210.6ms for $self->list_all_package_symbols('CODE');
# spent 10.4ms making 438 calls to Class::MOP::Mixin::HasMethods::get_method, avg 24µs/call # spent 276µs making 24 calls to Class::MOP::Package::list_all_package_symbols, avg 11µs/call
2062414µs $self->{_package_cache_flag_full} = $pkg_gen;
207 }
208
20944179µs4450µs return $self->_method_map;
# spent 50µs making 44 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 1µs/call
210}
211
212# overloading
213
21410smy $overload_operators;
215sub overload_operators {
216 $overload_operators ||= [map { split /\s+/ } values %overload::ops];
217 return @$overload_operators;
218}
219
220sub 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
227sub _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
242sub get_overload_list {
243 my $self = shift;
244 return keys %{ $self->_overload_map };
245}
246
247sub 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
253sub has_overloaded_operator {
254 my $self = shift;
255 my ($op) = @_;
256 return defined $self->_get_overloaded_operator_body($op);
257}
258
259sub 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
267sub add_overloaded_operator {
268 my $self = shift;
269 my ($op, $body) = @_;
270 $self->name->overload::OVERLOAD($op => $body);
271}
272
273sub 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
286sub _get_overloaded_operator_body {
287 my $self = shift;
288 my ($op) = @_;
289 return overload::Method($self->name, $op);
290}
291
292sub _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
30313µs1;
304
305# ABSTRACT: Methods for metaclasses which have methods
306
307__END__
 
# spent 671µs within Class::MOP::Mixin::HasMethods::CORE:match which was called 913 times, avg 735ns/call: # 913 times (671µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 83, avg 735ns/call
sub Class::MOP::Mixin::HasMethods::CORE:match; # opcode