Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Mixin/HasMethods.pm |
Statements | Executed 12523 statements in 31.2ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
401 | 21 | 8 | 17.6ms | 27.6ms | add_method | Class::MOP::Mixin::HasMethods::
585 | 7 | 4 | 4.28ms | 15.8ms | get_method | Class::MOP::Mixin::HasMethods::
629 | 2 | 1 | 2.11ms | 10.4ms | _get_maybe_raw_method | Class::MOP::Mixin::HasMethods::
401 | 1 | 1 | 1.10ms | 1.39ms | update_package_cache_flag | Class::MOP::Mixin::HasMethods::
67 | 1 | 1 | 434µs | 1.34ms | wrap_method_body | Class::MOP::Mixin::HasMethods::
401 | 1 | 1 | 399µs | 399µs | CORE:match (opcode) | Class::MOP::Mixin::HasMethods::
25 | 5 | 4 | 327µs | 12.4ms | _add_meta_method | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 322µs | 1.52ms | BEGIN@7 | Class::MOP::Mixin::HasMethods::
106 | 1 | 1 | 315µs | 398µs | _code_is_mine | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 172µs | 359µs | BEGIN@10 | Class::MOP::Mixin::HasMethods::
15 | 1 | 1 | 142µs | 4.75ms | _full_method_map | Class::MOP::Mixin::HasMethods::
44 | 4 | 2 | 113µs | 596µs | has_method | Class::MOP::Mixin::HasMethods::
15 | 1 | 1 | 49µs | 4.79ms | _get_local_methods | Class::MOP::Mixin::HasMethods::
25 | 2 | 1 | 26µs | 26µs | _meta_method_class | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 8µs | 10µs | BEGIN@4 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 6µs | 35µs | BEGIN@9 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 5µs | 21µs | BEGIN@12 | Class::MOP::Mixin::HasMethods::
1 | 1 | 1 | 5µs | 8µs | BEGIN@5 | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | _restore_metamethods_from | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | get_method_list | Class::MOP::Mixin::HasMethods::
0 | 0 | 0 | 0s | 0s | remove_method | 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 | 1 | 400ns | our $VERSION = '2.1605'; | ||
3 | |||||
4 | 2 | 16µs | 2 | 12µs | # spent 10µs (8+2) within Class::MOP::Mixin::HasMethods::BEGIN@4 which was called:
# once (8µs+2µs) by Class::MOP::BEGIN@16 at line 4 # spent 10µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@4
# spent 2µs making 1 call to strict::import |
5 | 2 | 13µs | 2 | 11µs | # spent 8µs (5+3) within Class::MOP::Mixin::HasMethods::BEGIN@5 which was called:
# once (5µs+3µs) by Class::MOP::BEGIN@16 at line 5 # spent 8µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@5
# spent 3µs making 1 call to warnings::import |
6 | |||||
7 | 2 | 78µs | 1 | 1.52ms | # spent 1.52ms (322µs+1.20) within Class::MOP::Mixin::HasMethods::BEGIN@7 which was called:
# once (322µs+1.20ms) by Class::MOP::BEGIN@16 at line 7 # spent 1.52ms making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@7 |
8 | |||||
9 | 2 | 18µs | 2 | 65µs | # spent 35µs (6+30) within Class::MOP::Mixin::HasMethods::BEGIN@9 which was called:
# once (6µs+30µs) by Class::MOP::BEGIN@16 at line 9 # spent 35µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@9
# spent 30µs making 1 call to Exporter::import |
10 | 2 | 88µs | 2 | 383µs | # spent 359µs (172+187) within Class::MOP::Mixin::HasMethods::BEGIN@10 which was called:
# once (172µs+187µs) by Class::MOP::BEGIN@16 at line 10 # spent 359µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@10
# spent 24µs making 1 call to Exporter::import |
11 | |||||
12 | 2 | 570µs | 2 | 37µs | # spent 21µs (5+16) within Class::MOP::Mixin::HasMethods::BEGIN@12 which was called:
# once (5µs+16µs) by Class::MOP::BEGIN@16 at line 12 # spent 21µs making 1 call to Class::MOP::Mixin::HasMethods::BEGIN@12
# spent 16µs making 1 call to parent::import |
13 | |||||
14 | 25 | 35µs | # spent 26µs within Class::MOP::Mixin::HasMethods::_meta_method_class which was called 25 times, avg 1µs/call:
# 23 times (24µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24, avg 1µs/call
# 2 times (2µs+0s) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 22, avg 750ns/call | ||
15 | |||||
16 | # spent 12.4ms (327µs+12.1) within Class::MOP::Mixin::HasMethods::_add_meta_method which was called 25 times, avg 495µs/call:
# 20 times (249µs+10.2ms) by metaclass::import at line 39 of metaclass.pm, avg 523µs/call
# 2 times (24µs+606µs) by Class::MOP::Class::create at line 446 of Class/MOP/Class.pm, avg 315µs/call
# once (24µs+666µs) by Moose::Exporter::BEGIN@8 at line 721 of Class/MOP.pm
# once (13µs+349µs) by Moose::init_meta at line 221 of Moose.pm
# once (18µs+223µs) by Moose::Exporter::BEGIN@8 at line 727 of Class/MOP.pm | ||||
17 | 25 | 6µs | my $self = shift; | ||
18 | 25 | 10µs | my ($name) = @_; | ||
19 | 25 | 100µs | 50 | 1.62ms | my $existing_method = $self->can('find_method_by_name') # spent 1.60ms making 25 calls to Class::MOP::Class::find_method_by_name, avg 64µs/call
# spent 23µs making 25 calls to UNIVERSAL::can, avg 904ns/call |
20 | ? $self->find_method_by_name($name) | ||||
21 | : $self->get_method($name); | ||||
22 | 25 | 17µs | 6 | 5µs | return if $existing_method # spent 2µ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 750ns/call
# spent 1µs making 2 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 650ns/call |
23 | && $existing_method->isa($self->_meta_method_class); | ||||
24 | 25 | 183µs | 100 | 10.4ms | $self->add_method( # spent 5.61ms making 2 calls to Moose::Meta::Method::Meta::wrap, avg 2.80ms/call
# spent 3.61ms making 23 calls to Class::MOP::Method::Meta::wrap, avg 157µs/call
# spent 1.18ms making 25 calls to Class::MOP::Mixin::HasMethods::add_method, avg 47µs/call
# spent 24µs making 23 calls to Class::MOP::Mixin::HasMethods::_meta_method_class, avg 1µs/call
# spent 6µs making 25 calls to Class::MOP::Package::name, avg 232ns/call
# spent 2µs making 2 calls to Moose::Meta::Class::_meta_method_class, avg 1µs/call |
25 | $name => $self->_meta_method_class->wrap( | ||||
26 | name => $name, | ||||
27 | package_name => $self->name, | ||||
28 | associated_metaclass => $self, | ||||
29 | ) | ||||
30 | ); | ||||
31 | } | ||||
32 | |||||
33 | # spent 1.34ms (434µs+911µs) within Class::MOP::Mixin::HasMethods::wrap_method_body which was called 67 times, avg 20µs/call:
# 67 times (434µs+911µs) by Class::MOP::Mixin::HasMethods::get_method at line 116, avg 20µs/call | ||||
34 | 67 | 52µs | my ( $self, %args ) = @_; | ||
35 | |||||
36 | ( $args{body} && 'CODE' eq reftype $args{body} ) | ||||
37 | 67 | 108µs | 67 | 18µs | || $self->_throw_exception( CodeBlockMustBeACodeRef => instance => $self, # spent 18µs making 67 calls to Scalar::Util::reftype, avg 261ns/call |
38 | params => \%args | ||||
39 | ); | ||||
40 | 67 | 331µs | 201 | 893µs | $self->method_metaclass->wrap( # spent 857µs making 67 calls to Class::MOP::Method::wrap, avg 13µs/call
# spent 23µs making 67 calls to Class::MOP::Mixin::HasMethods::method_metaclass, avg 342ns/call
# spent 13µs making 67 calls to Class::MOP::Package::name, avg 196ns/call |
41 | package_name => $self->name, | ||||
42 | %args, | ||||
43 | ); | ||||
44 | } | ||||
45 | |||||
46 | # spent 27.6ms (17.6+9.97) within Class::MOP::Mixin::HasMethods::add_method which was called 401 times, avg 69µs/call:
# 162 times (6.95ms+4.06ms) by Class::MOP::Attribute::install_accessors at line 450 of Class/MOP/Attribute.pm, avg 68µs/call
# 47 times (783µs+1.34ms) by Class::MOP::Attribute::install_accessors at line 446 of Class/MOP/Attribute.pm, avg 45µs/call
# 45 times (4.77ms+1.03ms) by Class::MOP::Attribute::install_accessors at line 458 of Class/MOP/Attribute.pm, avg 129µs/call
# 43 times (675µs+1.06ms) by Class::MOP::Class::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Class.pm:1082] at line 1080 of Class/MOP/Class.pm, avg 40µs/call
# 31 times (3.39ms+795µs) by Class::MOP::Class::_inline_constructor at line 1467 of Class/MOP/Class.pm, avg 135µs/call
# 25 times (470µs+708µs) by Class::MOP::Mixin::HasMethods::_add_meta_method at line 24, avg 47µs/call
# 13 times (204µs+328µs) by Class::MOP::MiniTrait::apply at line 25 of Class/MOP/MiniTrait.pm, avg 41µs/call
# 8 times (119µs+175µs) by Class::MOP::Attribute::install_accessors at line 454 of Class/MOP/Attribute.pm, avg 37µs/call
# 7 times (66µs+116µs) by Moose::BEGIN@43 at line 26 of Moose/Meta/Attribute/Native.pm, avg 26µs/call
# 3 times (31µs+49µs) by Moose::BEGIN@32 at line 315 of Moose/Meta/Role.pm, avg 26µs/call
# 3 times (28µs+42µs) by Moose::BEGIN@32 at line 323 of Moose/Meta/Role.pm, avg 23µs/call
# 3 times (26µs+42µs) by Moose::BEGIN@32 at line 342 of Moose/Meta/Role.pm, avg 23µs/call
# 2 times (35µs+47µs) by Moose::Meta::Attribute::install_delegation at line 1105 of Moose/Meta/Attribute.pm, avg 41µs/call
# 2 times (18µs+28µs) by Moose::BEGIN@32 at line 112 of Moose/Meta/Role.pm, avg 23µs/call
# once (22µs+41µs) by Class::MOP::Attribute::install_accessors at line 462 of Class/MOP/Attribute.pm
# once (18µs+23µs) by Class::MOP::Class::_inline_destructor at line 1509 of Class/MOP/Class.pm
# once (12µs+26µs) by Moose::Exporter::BEGIN@8 at line 507 of Class/MOP.pm
# once (10µs+18µs) by Moose::BEGIN@32 at line 92 of Moose/Meta/Role.pm
# once (10µs+15µs) by Moose::BEGIN@32 at line 102 of Moose/Meta/Role.pm
# once (9µs+14µs) by Moose::BEGIN@32 at line 97 of Moose/Meta/Role.pm
# once (9µs+13µs) by Moose::BEGIN@32 at line 117 of Moose/Meta/Role.pm | ||||
47 | 401 | 100µs | my ( $self, $method_name, $method ) = @_; | ||
48 | 401 | 112µs | ( defined $method_name && length $method_name ) | ||
49 | || $self->_throw_exception( MustDefineAMethodName => instance => $self ); | ||||
50 | |||||
51 | 401 | 587µs | 401 | 127µs | my $package_name = $self->name; # spent 127µs making 401 calls to Class::MOP::Package::name, avg 318ns/call |
52 | |||||
53 | 401 | 34µs | my $body; | ||
54 | 401 | 1.15ms | 779 | 316µs | if ( blessed($method) && $method->isa('Class::MOP::Method') ) { # spent 164µs making 378 calls to UNIVERSAL::isa, avg 434ns/call
# spent 152µs making 401 calls to Scalar::Util::blessed, avg 380ns/call |
55 | 378 | 555µs | 378 | 113µs | $body = $method->body; # spent 113µs making 378 calls to Class::MOP::Method::body, avg 299ns/call |
56 | 378 | 542µs | 391 | 174µs | if ( $method->package_name ne $package_name ) { # spent 93µs making 378 calls to Class::MOP::Method::package_name, avg 246ns/call
# spent 81µs making 13 calls to Class::MOP::Method::clone, avg 6µs/call |
57 | $method = $method->clone( | ||||
58 | package_name => $package_name, | ||||
59 | name => $method_name, | ||||
60 | ); | ||||
61 | } | ||||
62 | |||||
63 | 378 | 281µs | 378 | 891µs | $method->attach_to_class($self); # spent 891µs making 378 calls to Class::MOP::Method::attach_to_class, avg 2µs/call |
64 | } | ||||
65 | else { | ||||
66 | # If a raw code reference is supplied, its method object is not created. | ||||
67 | # The method object won't be created until required. | ||||
68 | 23 | 4µs | $body = $method; | ||
69 | } | ||||
70 | |||||
71 | 401 | 4.15ms | 424 | 625µs | $self->_method_map->{$method_name} = $method; # spent 621µs making 401 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 2µs/call
# spent 4µs making 23 calls to Class::MOP::Method::body, avg 187ns/call |
72 | |||||
73 | 401 | 761µs | 401 | 256µs | my ($current_package, $current_name) = Class::MOP::get_code_info($body); # spent 256µs making 401 calls to Class::MOP::get_code_info, avg 639ns/call |
74 | |||||
75 | 401 | 6.84ms | 720 | 1.62ms | subname($package_name . '::' . $method_name, $body) # spent 1.22ms making 319 calls to Sub::Name::subname, avg 4µs/call
# spent 399µs making 401 calls to Class::MOP::Mixin::HasMethods::CORE:match, avg 994ns/call |
76 | unless defined $current_name && $current_name !~ /^__ANON__/; | ||||
77 | |||||
78 | 401 | 484µs | 401 | 4.46ms | $self->add_package_symbol("&$method_name", $body); # spent 4.46ms making 401 calls to Class::MOP::Package::add_package_symbol, avg 11µs/call |
79 | |||||
80 | # we added the method to the method map too, so it's still valid | ||||
81 | 401 | 826µs | 401 | 1.39ms | $self->update_package_cache_flag; # spent 1.39ms making 401 calls to Class::MOP::Mixin::HasMethods::update_package_cache_flag, avg 3µs/call |
82 | } | ||||
83 | |||||
84 | # spent 398µs (315+83) within Class::MOP::Mixin::HasMethods::_code_is_mine which was called 106 times, avg 4µs/call:
# 106 times (315µs+83µs) by Class::MOP::Mixin::HasMethods::_get_maybe_raw_method at line 131, avg 4µs/call | ||||
85 | 106 | 19µs | my ( $self, $code ) = @_; | ||
86 | |||||
87 | 106 | 181µs | 106 | 59µs | my ( $code_package, $code_name ) = Class::MOP::get_code_info($code); # spent 59µs making 106 calls to Class::MOP::get_code_info, avg 554ns/call |
88 | |||||
89 | 106 | 261µs | 106 | 25µs | return ( $code_package && $code_package eq $self->name ) # spent 25µs making 106 calls to Class::MOP::Package::name, avg 234ns/call |
90 | || ( $code_package eq 'constant' && $code_name eq '__ANON__' ); | ||||
91 | } | ||||
92 | |||||
93 | # spent 596µs (113+483) within Class::MOP::Mixin::HasMethods::has_method which was called 44 times, avg 14µs/call:
# 31 times (79µs+388µs) by Class::MOP::Class::_inline_constructor at line 1436 of Class/MOP/Class.pm, avg 15µs/call
# 6 times (22µs+39µs) by Moose::Meta::Attribute::_process_accessors at line 1048 of Moose/Meta/Attribute.pm, avg 10µs/call
# 6 times (10µs+47µs) by Class::MOP::Class::find_all_methods_by_name at line 1165 of Class/MOP/Class.pm, avg 10µs/call
# once (2µs+9µs) by Class::MOP::Class::_inline_destructor at line 1480 of Class/MOP/Class.pm | ||||
94 | 44 | 9µs | my ( $self, $method_name ) = @_; | ||
95 | |||||
96 | 44 | 15µs | ( defined $method_name && length $method_name ) | ||
97 | || $self->_throw_exception( MustDefineAMethodName => instance => $self ); | ||||
98 | |||||
99 | 44 | 31µs | 44 | 483µs | my $method = $self->_get_maybe_raw_method($method_name); # spent 483µs making 44 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 11µs/call |
100 | 44 | 54µs | 1 | 200ns | return if not $method; # spent 200ns making 1 call to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16] |
101 | |||||
102 | 1 | 4µs | 1 | 200ns | return defined($self->_method_map->{$method_name} = $method); # spent 200ns making 1 call to Class::MOP::Mixin::HasMethods::_method_map |
103 | } | ||||
104 | |||||
105 | # spent 15.8ms (4.28+11.5) within Class::MOP::Mixin::HasMethods::get_method which was called 585 times, avg 27µs/call:
# 345 times (864µs+4.69ms) by Class::MOP::Class::find_method_by_name at line 1133 of Class/MOP/Class.pm, avg 16µs/call
# 150 times (3.14ms+1.98ms) by Class::MOP::Class::find_next_method_by_name at line 1181 of Class/MOP/Class.pm, avg 34µs/call
# 43 times (65µs+348µs) by Class::MOP::Class::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Class/MOP/Class.pm:1082] at line 1055 of Class/MOP/Class.pm, avg 10µs/call
# 38 times (187µs+4.35ms) by Class::MOP::Mixin::HasMethods::_full_method_map at line 220, avg 119µs/call
# 6 times (25µs+86µs) by Moose::Meta::Attribute::_process_accessors at line 1021 of Moose/Meta/Attribute.pm, avg 18µs/call
# 2 times (4µs+19µs) by Moose::Meta::Attribute::install_delegation at line 1084 of Moose/Meta/Attribute.pm, avg 12µs/call
# once (3µs+14µs) by Moose::init_meta at line 211 of Moose.pm | ||||
106 | 585 | 81µs | my ( $self, $method_name ) = @_; | ||
107 | |||||
108 | 585 | 79µs | ( defined $method_name && length $method_name ) | ||
109 | || $self->_throw_exception( MustDefineAMethodName => instance => $self ); | ||||
110 | |||||
111 | 585 | 288µs | 585 | 9.87ms | my $method = $self->_get_maybe_raw_method($method_name); # spent 9.87ms making 585 calls to Class::MOP::Mixin::HasMethods::_get_maybe_raw_method, avg 17µs/call |
112 | 585 | 564µs | 88 | 48µs | return if not $method; # spent 48µs making 88 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 544ns/call |
113 | |||||
114 | 155 | 3.04ms | 243 | 106µs | return $method if blessed($method) && $method->isa('Class::MOP::Method'); # spent 55µs making 155 calls to Scalar::Util::blessed, avg 355ns/call
# spent 51µs making 88 calls to UNIVERSAL::isa, avg 576ns/call |
115 | |||||
116 | 67 | 245µs | 134 | 1.46ms | return $self->_method_map->{$method_name} = $self->wrap_method_body( # spent 1.34ms making 67 calls to Class::MOP::Mixin::HasMethods::wrap_method_body, avg 20µs/call
# spent 89µs making 13 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 7µs/call
# spent 24µs making 54 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 446ns/call |
117 | body => $method, | ||||
118 | name => $method_name, | ||||
119 | associated_metaclass => $self, | ||||
120 | ); | ||||
121 | } | ||||
122 | |||||
123 | # spent 10.4ms (2.11+8.25) within Class::MOP::Mixin::HasMethods::_get_maybe_raw_method which was called 629 times, avg 16µs/call:
# 585 times (1.94ms+7.94ms) by Class::MOP::Mixin::HasMethods::get_method at line 111, avg 17µs/call
# 44 times (171µs+312µs) by Class::MOP::Mixin::HasMethods::has_method at line 99, avg 11µs/call | ||||
124 | 629 | 87µs | my ( $self, $method_name ) = @_; | ||
125 | |||||
126 | 629 | 1.07ms | 636 | 2.05ms | my $map_entry = $self->_method_map->{$method_name}; # spent 1.66ms making 233 calls to Class::MOP::Class::Immutable::Class::MOP::Class::_method_map, avg 7µs/call
# spent 390µs making 396 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 984ns/call
# spent 3µs making 7 calls to Class::MOP::Method::body, avg 429ns/call |
127 | 629 | 152µs | return $map_entry if defined $map_entry; | ||
128 | |||||
129 | 540 | 470µs | 540 | 5.80ms | my $code = $self->get_package_symbol("&$method_name"); # spent 5.80ms making 540 calls to Class::MOP::Package::get_package_symbol, avg 11µs/call |
130 | |||||
131 | 540 | 571µs | 106 | 398µs | return unless $code && $self->_code_is_mine($code); # spent 398µs making 106 calls to Class::MOP::Mixin::HasMethods::_code_is_mine, avg 4µs/call |
132 | |||||
133 | 67 | 69µs | return $code; | ||
134 | } | ||||
135 | |||||
136 | sub remove_method { | ||||
137 | my ( $self, $method_name ) = @_; | ||||
138 | |||||
139 | ( defined $method_name && length $method_name ) | ||||
140 | || $self->_throw_exception( MustDefineAMethodName => instance => $self ); | ||||
141 | |||||
142 | my $removed_method = delete $self->_method_map->{$method_name}; | ||||
143 | |||||
144 | $self->remove_package_symbol("&$method_name"); | ||||
145 | |||||
146 | $removed_method->detach_from_class | ||||
147 | if blessed($removed_method) && $removed_method->isa('Class::MOP::Method'); | ||||
148 | |||||
149 | # still valid, since we just removed the method from the map | ||||
150 | $self->update_package_cache_flag; | ||||
151 | |||||
152 | return $removed_method; | ||||
153 | } | ||||
154 | |||||
155 | sub get_method_list { | ||||
156 | my $self = shift; | ||||
157 | |||||
158 | return keys %{ $self->_full_method_map }; | ||||
159 | } | ||||
160 | |||||
161 | # spent 4.79ms (49µs+4.75) within Class::MOP::Mixin::HasMethods::_get_local_methods which was called 15 times, avg 320µs/call:
# 15 times (49µs+4.75ms) by Class::MOP::Class::get_all_methods at line 1146 of Class/MOP/Class.pm, avg 320µs/call | ||||
162 | 15 | 3µs | my $self = shift; | ||
163 | |||||
164 | 15 | 45µs | 15 | 4.75ms | return values %{ $self->_full_method_map }; # spent 4.75ms making 15 calls to Class::MOP::Mixin::HasMethods::_full_method_map, avg 316µs/call |
165 | } | ||||
166 | |||||
167 | sub _restore_metamethods_from { | ||||
168 | my $self = shift; | ||||
169 | my ($old_meta) = @_; | ||||
170 | |||||
171 | my $package_name = $self->name; | ||||
172 | |||||
173 | # Check if Perl debugger is enabled | ||||
174 | my $debugger_enabled = ($^P & 0x10); | ||||
175 | my $debug_method_info; | ||||
176 | |||||
177 | for my $method ($old_meta->_get_local_methods) { | ||||
178 | my $method_name = $method->name; | ||||
179 | |||||
180 | # Track DB::sub information for this method if debugger is enabled. | ||||
181 | # This contains original method filename and line numbers. | ||||
182 | $debug_method_info = ''; | ||||
183 | if ($debugger_enabled) { | ||||
184 | $debug_method_info = $DB::sub{$package_name . "::" . $method_name} | ||||
185 | } | ||||
186 | |||||
187 | $method->_make_compatible_with($self->method_metaclass); | ||||
188 | $self->add_method($method_name => $method); | ||||
189 | |||||
190 | # Restore method debug information, which can be clobbered by add_method. | ||||
191 | # Note that we handle this here instead of in add_method, because we | ||||
192 | # only want to preserve the original debug info in cases where we are | ||||
193 | # restoring a method, not overwriting a method. | ||||
194 | if ($debugger_enabled && $debug_method_info) { | ||||
195 | $DB::sub{$package_name . "::" . $method_name} = $debug_method_info; | ||||
196 | } | ||||
197 | } | ||||
198 | } | ||||
199 | |||||
200 | sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef } | ||||
201 | # spent 1.39ms (1.10+288µs) within Class::MOP::Mixin::HasMethods::update_package_cache_flag which was called 401 times, avg 3µs/call:
# 401 times (1.10ms+288µs) by Class::MOP::Mixin::HasMethods::add_method at line 81, avg 3µs/call | ||||
202 | 401 | 60µs | my $self = shift; | ||
203 | # NOTE: | ||||
204 | # we can manually update the cache number | ||||
205 | # since we are actually adding the method | ||||
206 | # to our cache as well. This avoids us | ||||
207 | # having to regenerate the method_map. | ||||
208 | # - SL | ||||
209 | 401 | 5.65ms | 802 | 288µs | $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name); # spent 196µs making 401 calls to mro::get_pkg_gen, avg 488ns/call
# spent 92µs making 401 calls to Class::MOP::Package::name, avg 230ns/call |
210 | } | ||||
211 | |||||
212 | # spent 4.75ms (142µs+4.60) within Class::MOP::Mixin::HasMethods::_full_method_map which was called 15 times, avg 316µs/call:
# 15 times (142µs+4.60ms) by Class::MOP::Mixin::HasMethods::_get_local_methods at line 164, avg 316µs/call | ||||
213 | 15 | 3µs | my $self = shift; | ||
214 | |||||
215 | 15 | 46µs | 30 | 12µs | my $pkg_gen = Class::MOP::check_package_cache_flag($self->name); # spent 8µs making 15 calls to mro::get_pkg_gen, avg 533ns/call
# spent 4µs making 15 calls to Class::MOP::Package::name, avg 247ns/call |
216 | |||||
217 | 15 | 9µs | if (($self->{_package_cache_flag_full} || -1) != $pkg_gen) { | ||
218 | # forcibly reify all method map entries | ||||
219 | $self->get_method($_) | ||||
220 | 4 | 36µs | 42 | 4.58ms | for $self->list_all_package_symbols('CODE'); # spent 4.54ms making 38 calls to Class::MOP::Mixin::HasMethods::get_method, avg 119µs/call
# spent 41µs making 4 calls to Class::MOP::Package::list_all_package_symbols, avg 10µs/call |
221 | 4 | 3µs | $self->{_package_cache_flag_full} = $pkg_gen; | ||
222 | } | ||||
223 | |||||
224 | 15 | 54µs | 15 | 12µs | return $self->_method_map; # spent 12µs making 15 calls to Class::MOP::Mixin::HasMethods::_method_map, avg 800ns/call |
225 | } | ||||
226 | |||||
227 | 1 | 2µs | 1; | ||
228 | |||||
229 | # ABSTRACT: Methods for metaclasses which have methods | ||||
230 | |||||
231 | __END__ | ||||
# spent 399µs within Class::MOP::Mixin::HasMethods::CORE:match which was called 401 times, avg 994ns/call:
# 401 times (399µs+0s) by Class::MOP::Mixin::HasMethods::add_method at line 75, avg 994ns/call |