Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Role/Application.pm |
Statements | Executed 1140 statements in 5.13ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
17 | 2 | 2 | 1.23ms | 8.13ms | apply_methods | Mouse::Meta::Role::Application::
17 | 1 | 1 | 771µs | 9.80ms | apply_attributes (recurses: max depth 1, inclusive time 671µs) | Mouse::Meta::Role::Application::
17 | 2 | 2 | 613µs | 20.9ms | apply (recurses: max depth 1, inclusive time 1.29ms) | Mouse::Meta::Role::Application::
17 | 1 | 1 | 393µs | 609µs | apply_modifiers | Mouse::Meta::Role::Application::
17 | 2 | 2 | 379µs | 544µs | new | Mouse::Meta::Role::Application::
17 | 1 | 1 | 360µs | 608µs | check_required_methods | Mouse::Meta::Role::Application::
17 | 1 | 1 | 352µs | 1.67ms | _append_roles | Mouse::Meta::Role::Application::
1 | 1 | 1 | 26µs | 105µs | BEGIN@2 | Mouse::Meta::Role::Application::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Mouse::Meta::Role::Application; | ||||
2 | 2 | 815µs | 2 | 183µs | # spent 105µs (26+78) within Mouse::Meta::Role::Application::BEGIN@2 which was called:
# once (26µs+78µs) by Mouse::Meta::Role::apply at line 2 # spent 105µs making 1 call to Mouse::Meta::Role::Application::BEGIN@2
# spent 78µs making 1 call to Mouse::Exporter::do_import |
3 | |||||
4 | # spent 544µs (379+166) within Mouse::Meta::Role::Application::new which was called 17 times, avg 32µs/call:
# 14 times (284µs+24µs) by Mouse::Meta::Role::apply at line 71 of Mouse/Meta/Role.pm, avg 22µs/call
# 3 times (95µs+141µs) by Mouse::Meta::Role::Composite::apply at line 105 of Mouse/Meta/Role/Composite.pm, avg 79µs/call | ||||
5 | 153 | 425µs | my $class = shift; | ||
6 | 17 | 29µs | my $args = $class->Mouse::Object::BUILDARGS(@_); # spent 29µs making 17 calls to Mouse::Object::BUILDARGS, avg 2µs/call | ||
7 | |||||
8 | if(exists $args->{exclude} or exists $args->{alias}) { | ||||
9 | warnings::warnif(deprecated => | ||||
10 | 'The alias and excludes options for role application have been' | ||||
11 | . ' renamed -alias and -exclude'); | ||||
12 | |||||
13 | if($args->{alias} && !exists $args->{-alias}){ | ||||
14 | $args->{-alias} = $args->{alias}; | ||||
15 | } | ||||
16 | if($args->{excludes} && !exists $args->{-excludes}){ | ||||
17 | $args->{-excludes} = $args->{excludes}; | ||||
18 | } | ||||
19 | } | ||||
20 | |||||
21 | $args->{aliased_methods} = {}; | ||||
22 | if(my $alias = $args->{-alias}){ | ||||
23 | @{$args->{aliased_methods}}{ values %{$alias} } = (); | ||||
24 | } | ||||
25 | |||||
26 | if(my $excludes = $args->{-excludes}){ | ||||
27 | $args->{-excludes} = {}; # replace with a hash ref | ||||
28 | if(ref $excludes){ | ||||
29 | %{$args->{-excludes}} = (map{ $_ => undef } @{$excludes}); | ||||
30 | } | ||||
31 | else{ | ||||
32 | $args->{-excludes}{$excludes} = undef; | ||||
33 | } | ||||
34 | } | ||||
35 | my $self = bless $args, $class; | ||||
36 | 1 | 28µs | 10 | 184µs | if($class ne __PACKAGE__){ # spent 78µs making 3 calls to Mouse::Meta::Class::_initialize_object, avg 26µs/call
# spent 58µs making 3 calls to Mouse::Util::meta, avg 19µs/call
# spent 41µs making 1 call to Mouse::Meta::Class::_calculate_all_attributes
# spent 3µs making 1 call to Mouse::Meta::Class::strict_constructor
# spent 2µs making 1 call to Mouse::Meta::Class::is_immutable
# spent 1µs making 1 call to Mouse::Meta::Class::is_anon_class |
37 | $self->meta->_initialize_object($self, $args); | ||||
38 | } | ||||
39 | return $self; | ||||
40 | } | ||||
41 | |||||
42 | # spent 20.9ms (613µs+20.3) within Mouse::Meta::Role::Application::apply which was called 17 times, avg 1.23ms/call:
# 14 times (501µs+15.2ms) by Mouse::Meta::Role::apply at line 71 of Mouse/Meta/Role.pm, avg 1.12ms/call
# 3 times (113µs+5.12ms) by Mouse::Meta::Role::Composite::apply at line 105 of Mouse/Meta/Role/Composite.pm, avg 1.74ms/call | ||||
43 | 170 | 630µs | my($self, $role, $consumer, @extra) = @_; | ||
44 | my $instance; | ||||
45 | |||||
46 | 26 | 68µs | if(Mouse::Util::is_a_metaclass($consumer)) { # Application::ToClass # spent 55µs making 17 calls to Mouse::Util::is_a_metaclass, avg 3µs/call
# spent 13µs making 9 calls to Mouse::Util::is_a_metarole, avg 1µs/call | ||
47 | $self->{_to} = 'class'; | ||||
48 | } | ||||
49 | elsif(Mouse::Util::is_a_metarole($consumer)) { # Application::ToRole | ||||
50 | $self->{_to} = 'role'; | ||||
51 | } | ||||
52 | else { # Appplication::ToInstance | ||||
53 | $self->{_to} = 'instance'; | ||||
54 | $instance = $consumer; | ||||
55 | |||||
56 | $consumer = (Mouse::Util::class_of($instance) || 'Mouse::Meta::Class') | ||||
57 | ->create_anon_class( | ||||
58 | superclasses => [ref $instance], | ||||
59 | cache => 1, | ||||
60 | ); | ||||
61 | } | ||||
62 | |||||
63 | #$self->check_role_exclusions($role, $consumer, @extra); | ||||
64 | 17 | 608µs | $self->check_required_methods($role, $consumer, @extra); # spent 608µs making 17 calls to Mouse::Meta::Role::Application::check_required_methods, avg 36µs/call | ||
65 | #$self->check_required_attributes($role, $consumer, @extra); | ||||
66 | |||||
67 | 17 | 9.80ms | $self->apply_attributes($role, $consumer, @extra); # spent 10.5ms making 17 calls to Mouse::Meta::Role::Application::apply_attributes, avg 616µs/call, recursion: max depth 1, sum of overlapping time 671µs | ||
68 | 17 | 8.18ms | $self->apply_methods($role, $consumer, @extra); # spent 7.97ms making 14 calls to Mouse::Meta::Role::Application::apply_methods, avg 569µs/call
# spent 217µs making 3 calls to Mouse::Meta::Role::Application::RoleSummation::apply_methods, avg 72µs/call | ||
69 | #$self->apply_override_method_modifiers($role, $consumer, @extra); | ||||
70 | #$self->apply_before_method_modifiers($role, $consumer, @extra); | ||||
71 | #$self->apply_around_method_modifiers($role, $consumer, @extra); | ||||
72 | #$self->apply_after_method_modifiers($role, $consumer, @extra); | ||||
73 | 17 | 609µs | $self->apply_modifiers($role, $consumer, @extra); # spent 609µs making 17 calls to Mouse::Meta::Role::Application::apply_modifiers, avg 36µs/call | ||
74 | |||||
75 | 17 | 1.67ms | $self->_append_roles($role, $consumer); # spent 1.67ms making 17 calls to Mouse::Meta::Role::Application::_append_roles, avg 98µs/call | ||
76 | |||||
77 | if(defined $instance){ # Application::ToInstance | ||||
78 | # rebless instance | ||||
79 | bless $instance, $consumer->name; | ||||
80 | $consumer->_initialize_object($instance, $instance, 1); | ||||
81 | } | ||||
82 | |||||
83 | return; | ||||
84 | } | ||||
85 | |||||
86 | # spent 608µs (360+248) within Mouse::Meta::Role::Application::check_required_methods which was called 17 times, avg 36µs/call:
# 17 times (360µs+248µs) by Mouse::Meta::Role::Application::apply at line 64, avg 36µs/call | ||||
87 | 113 | 397µs | my($self, $role, $consumer) = @_; | ||
88 | |||||
89 | 18 | 200µs | if($self->{_to} eq 'role'){ # spent 168µs making 9 calls to Mouse::Meta::Role::add_required_methods, avg 19µs/call
# spent 32µs making 9 calls to Mouse::Meta::Role::get_required_method_list, avg 4µs/call | ||
90 | $consumer->add_required_methods($role->get_required_method_list); | ||||
91 | } | ||||
92 | else{ # to class or instance | ||||
93 | 8 | 12µs | my $consumer_class_name = $consumer->name; # spent 12µs making 8 calls to Mouse::Meta::Module::name, avg 2µs/call | ||
94 | |||||
95 | my @missing; | ||||
96 | foreach my $method_name(@{$role->{required_methods}}){ | ||||
97 | next if exists $self->{aliased_methods}{$method_name}; | ||||
98 | next if exists $role->{methods}{$method_name}; | ||||
99 | 10 | 35µs | next if $consumer_class_name->can($method_name); # spent 35µs making 10 calls to UNIVERSAL::can, avg 4µs/call | ||
100 | |||||
101 | push @missing, $method_name; | ||||
102 | } | ||||
103 | if(@missing){ | ||||
104 | $role->throw_error(sprintf "'%s' requires the method%s %s to be implemented by '%s'", | ||||
105 | $role->name, | ||||
106 | (@missing == 1 ? '' : 's'), # method or methods | ||||
107 | Mouse::Util::quoted_english_list(@missing), | ||||
108 | $consumer_class_name); | ||||
109 | } | ||||
110 | } | ||||
111 | |||||
112 | return; | ||||
113 | } | ||||
114 | |||||
115 | # spent 8.13ms (1.23+6.89) within Mouse::Meta::Role::Application::apply_methods which was called 17 times, avg 478µs/call:
# 14 times (1.15ms+6.82ms) by Mouse::Meta::Role::Application::apply at line 68, avg 569µs/call
# 3 times (84µs+75µs) by Mouse::Meta::Role::Application::RoleSummation::apply_methods at line 145 of Mouse/Meta/Role/Composite.pm, avg 53µs/call | ||||
116 | 334 | 1.38ms | my($self, $role, $consumer) = @_; | ||
117 | |||||
118 | my $alias = $self->{-alias}; | ||||
119 | my $excludes = $self->{-excludes}; | ||||
120 | |||||
121 | 17 | 4.99ms | foreach my $method_name($role->get_method_list){ # spent 4.97ms making 14 calls to Mouse::Meta::Module::get_method_list, avg 355µs/call
# spent 16µs making 3 calls to Mouse::Meta::Role::Composite::get_method_list, avg 5µs/call | ||
122 | next if $method_name eq 'meta'; | ||||
123 | |||||
124 | 58 | 587µs | my $code = $role->get_method_body($method_name); # spent 578µs making 56 calls to Mouse::Meta::Module::get_method_body, avg 10µs/call
# spent 10µs making 2 calls to Mouse::Meta::Role::Composite::get_method_body, avg 5µs/call | ||
125 | |||||
126 | 113 | 1.32ms | if(!exists $excludes->{$method_name}){ # spent 1.02ms making 56 calls to Mouse::Meta::Module::has_method, avg 18µs/call
# spent 261µs making 53 calls to Mouse::Meta::Module::add_method, avg 5µs/call
# spent 30µs making 2 calls to Mouse::Meta::Role::Composite::add_method, avg 15µs/call
# spent 5µs making 2 calls to Mouse::Meta::Role::Composite::has_method, avg 2µs/call | ||
127 | if(!$consumer->has_method($method_name)){ | ||||
128 | # The third argument $role is used in Role::Composite | ||||
129 | $consumer->add_method($method_name => $code, $role); | ||||
130 | } | ||||
131 | } | ||||
132 | |||||
133 | if(exists $alias->{$method_name}){ | ||||
134 | my $dstname = $alias->{$method_name}; | ||||
135 | |||||
136 | my $dstcode = $consumer->get_method_body($dstname); | ||||
137 | |||||
138 | if(defined($dstcode) && $dstcode != $code){ | ||||
139 | $role->throw_error("Cannot create a method alias if a local method of the same name exists"); | ||||
140 | } | ||||
141 | else{ | ||||
142 | $consumer->add_method($dstname => $code, $role); | ||||
143 | } | ||||
144 | } | ||||
145 | } | ||||
146 | |||||
147 | return; | ||||
148 | } | ||||
149 | |||||
150 | # spent 9.80ms (771µs+9.03) within Mouse::Meta::Role::Application::apply_attributes which was called 17 times, avg 576µs/call:
# 17 times (771µs+9.03ms) by Mouse::Meta::Role::Application::apply at line 67, avg 576µs/call | ||||
151 | 127 | 656µs | my($self, $role, $consumer) = @_; | ||
152 | |||||
153 | 17 | 65µs | for my $attr_name ($role->get_attribute_list) { # spent 65µs making 17 calls to Mouse::Meta::Module::get_attribute_list, avg 4µs/call | ||
154 | 38 | 122µs | next if $consumer->has_attribute($attr_name); # spent 95µs making 28 calls to Mouse::Meta::Module::has_attribute, avg 3µs/call
# spent 27µs making 10 calls to Mouse::Meta::Role::Composite::has_attribute, avg 3µs/call | ||
155 | |||||
156 | 76 | 8.92ms | $consumer->add_attribute($attr_name # spent 9.11ms making 18 calls to Mouse::Meta::Class::add_attribute, avg 506µs/call, recursion: max depth 1, sum of overlapping time 588µs
# spent 222µs making 10 calls to Mouse::Meta::Role::Composite::add_attribute, avg 22µs/call
# spent 115µs making 38 calls to Mouse::Meta::Module::get_attribute, avg 3µs/call
# spent 63µs making 10 calls to Mouse::Meta::Role::add_attribute, avg 6µs/call | ||
157 | => $role->get_attribute($attr_name)); | ||||
158 | } | ||||
159 | return; | ||||
160 | } | ||||
161 | |||||
162 | # spent 609µs (393+216) within Mouse::Meta::Role::Application::apply_modifiers which was called 17 times, avg 36µs/call:
# 17 times (393µs+216µs) by Mouse::Meta::Role::Application::apply at line 73, avg 36µs/call | ||||
163 | 146 | 418µs | my($self, $role, $consumer) = @_; | ||
164 | |||||
165 | if(my $modifiers = $role->{override_method_modifiers}){ | ||||
166 | foreach my $method_name (keys %{$modifiers}){ | ||||
167 | $consumer->add_override_method_modifier( | ||||
168 | $method_name => $modifiers->{$method_name}); | ||||
169 | } | ||||
170 | } | ||||
171 | |||||
172 | for my $modifier_type (qw/before around after/) { | ||||
173 | my $table = $role->{"${modifier_type}_method_modifiers"} | ||||
174 | or next; | ||||
175 | |||||
176 | my $add_modifier = "add_${modifier_type}_method_modifier"; | ||||
177 | |||||
178 | while(my($method_name, $modifiers) = each %{$table}){ | ||||
179 | foreach my $code(@{ $modifiers }) { | ||||
180 | # skip if the modifier is already applied | ||||
181 | next if $consumer->{"_applied_$modifier_type"}{$method_name, $code}++; | ||||
182 | 7 | 216µs | $consumer->$add_modifier($method_name => $code); # spent 202µs making 3 calls to Mouse::Meta::Class::add_around_method_modifier, avg 67µs/call
# spent 14µs making 4 calls to Mouse::Meta::Role::add_around_method_modifier, avg 3µs/call | ||
183 | } | ||||
184 | } | ||||
185 | } | ||||
186 | return; | ||||
187 | } | ||||
188 | |||||
189 | # spent 1.67ms (352µs+1.32) within Mouse::Meta::Role::Application::_append_roles which was called 17 times, avg 98µs/call:
# 17 times (352µs+1.32ms) by Mouse::Meta::Role::Application::apply at line 75, avg 98µs/call | ||||
190 | 94 | 368µs | my($self, $role, $metaclass_or_role) = @_; | ||
191 | |||||
192 | my $roles = $metaclass_or_role->{roles}; | ||||
193 | 17 | 25µs | foreach my $r($role, @{$role->get_roles}){ # spent 25µs making 17 calls to Mouse::Meta::Role::get_roles, avg 1µs/call | ||
194 | 26 | 1.29ms | if(!$metaclass_or_role->does_role($r)){ # spent 878µs making 15 calls to Mouse::Meta::Class::does_role, avg 59µs/call
# spent 412µs making 11 calls to Mouse::Meta::Role::does_role, avg 37µs/call | ||
195 | push @{$roles}, $r; | ||||
196 | } | ||||
197 | } | ||||
198 | return; | ||||
199 | } | ||||
200 | 1 | 8µs | 1; | ||
201 | __END__ |