← 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:22:35 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/x86_64-linux/Moose/Meta/Role/Application/RoleSummation.pm
StatementsExecuted 23 statements in 1.26ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11137µs77µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@13Moose::Meta::Role::Application::RoleSummation::BEGIN@13
11110µs10µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@2Moose::Meta::Role::Application::RoleSummation::BEGIN@2
1119µs25µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@10Moose::Meta::Role::Application::RoleSummation::BEGIN@10
1119µs14µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@9Moose::Meta::Role::Application::RoleSummation::BEGIN@9
1119µs570µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@11Moose::Meta::Role::Application::RoleSummation::BEGIN@11
1118µs87µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@17Moose::Meta::Role::Application::RoleSummation::BEGIN@17
1116µs6µsMoose::Meta::Role::Application::RoleSummation::::BEGIN@15Moose::Meta::Role::Application::RoleSummation::BEGIN@15
0000s0sMoose::Meta::Role::Application::RoleSummation::::__ANON__[:21]Moose::Meta::Role::Application::RoleSummation::__ANON__[:21]
0000s0sMoose::Meta::Role::Application::RoleSummation::::apply_attributesMoose::Meta::Role::Application::RoleSummation::apply_attributes
0000s0sMoose::Meta::Role::Application::RoleSummation::::apply_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_method_modifiers
0000s0sMoose::Meta::Role::Application::RoleSummation::::apply_methodsMoose::Meta::Role::Application::RoleSummation::apply_methods
0000s0sMoose::Meta::Role::Application::RoleSummation::::apply_override_method_modifiersMoose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers
0000s0sMoose::Meta::Role::Application::RoleSummation::::check_required_attributesMoose::Meta::Role::Application::RoleSummation::check_required_attributes
0000s0sMoose::Meta::Role::Application::RoleSummation::::check_required_methodsMoose::Meta::Role::Application::RoleSummation::check_required_methods
0000s0sMoose::Meta::Role::Application::RoleSummation::::check_role_exclusionsMoose::Meta::Role::Application::RoleSummation::check_role_exclusions
0000s0sMoose::Meta::Role::Application::RoleSummation::::get_exclusions_for_roleMoose::Meta::Role::Application::RoleSummation::get_exclusions_for_role
0000s0sMoose::Meta::Role::Application::RoleSummation::::get_method_aliases_for_roleMoose::Meta::Role::Application::RoleSummation::get_method_aliases_for_role
0000s0sMoose::Meta::Role::Application::RoleSummation::::is_aliased_methodMoose::Meta::Role::Application::RoleSummation::is_aliased_method
0000s0sMoose::Meta::Role::Application::RoleSummation::::is_method_aliasedMoose::Meta::Role::Application::RoleSummation::is_method_aliased
0000s0sMoose::Meta::Role::Application::RoleSummation::::is_method_excludedMoose::Meta::Role::Application::RoleSummation::is_method_excluded
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Moose::Meta::Role::Application::RoleSummation;
2
# spent 10µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@2 which was called: # once (10µs+0s) by Moose::BEGIN@39 at line 4
BEGIN {
314µs $Moose::Meta::Role::Application::RoleSummation::AUTHORITY = 'cpan:STEVAN';
4124µs110µs}
5{
621µs $Moose::Meta::Role::Application::RoleSummation::VERSION = '2.0602';
7}
8
9320µs218µs
# spent 14µs (9+5) within Moose::Meta::Role::Application::RoleSummation::BEGIN@9 which was called: # once (9µs+5µs) by Moose::BEGIN@39 at line 9
use strict;
# spent 14µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@9 # spent 5µs making 1 call to strict::import
10319µs241µs
# spent 25µs (9+16) within Moose::Meta::Role::Application::RoleSummation::BEGIN@10 which was called: # once (9µs+16µs) by Moose::BEGIN@39 at line 10
use warnings;
# spent 25µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@10 # spent 16µs making 1 call to warnings::import
11330µs21.13ms
# spent 570µs (9+561) within Moose::Meta::Role::Application::RoleSummation::BEGIN@11 which was called: # once (9µs+561µs) by Moose::BEGIN@39 at line 11
use metaclass;
# spent 570µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@11 # spent 561µs making 1 call to metaclass::import
12
13323µs2117µs
# spent 77µs (37+40) within Moose::Meta::Role::Application::RoleSummation::BEGIN@13 which was called: # once (37µs+40µs) by Moose::BEGIN@39 at line 13
use Scalar::Util 'blessed';
# spent 77µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@13 # spent 40µs making 1 call to Exporter::import
14
15320µs16µs
# spent 6µs within Moose::Meta::Role::Application::RoleSummation::BEGIN@15 which was called: # once (6µs+0s) by Moose::BEGIN@39 at line 15
use Moose::Meta::Role::Composite;
16
1731.10ms2166µs
# spent 87µs (8+79) within Moose::Meta::Role::Application::RoleSummation::BEGIN@17 which was called: # once (8µs+79µs) by Moose::BEGIN@39 at line 17
use base 'Moose::Meta::Role::Application';
# spent 87µs making 1 call to Moose::Meta::Role::Application::RoleSummation::BEGIN@17 # spent 79µs making 1 call to base::import
18
19__PACKAGE__->meta->add_attribute('role_params' => (
20 reader => 'role_params',
21 default => sub { {} },
2218µs3535µs Class::MOP::_definition_context(),
# spent 502µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 23µs making 1 call to Moose::Meta::Role::Application::RoleSummation::meta # spent 10µs making 1 call to Class::MOP::_definition_context
23));
24
25sub get_exclusions_for_role {
26 my ($self, $role) = @_;
27 $role = $role->name if blessed $role;
28 my $excludes_key = exists $self->role_params->{$role}->{'-excludes'} ?
29 '-excludes' : 'excludes';
30 if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$excludes_key}) {
31 if (ref $self->role_params->{$role}->{$excludes_key} eq 'ARRAY') {
32 return $self->role_params->{$role}->{$excludes_key};
33 }
34 return [ $self->role_params->{$role}->{$excludes_key} ];
35 }
36 return [];
37}
38
39sub get_method_aliases_for_role {
40 my ($self, $role) = @_;
41 $role = $role->name if blessed $role;
42 my $alias_key = exists $self->role_params->{$role}->{'-alias'} ?
43 '-alias' : 'alias';
44 if ($self->role_params->{$role} && defined $self->role_params->{$role}->{$alias_key}) {
45 return $self->role_params->{$role}->{$alias_key};
46 }
47 return {};
48}
49
50sub is_method_excluded {
51 my ($self, $role, $method_name) = @_;
52 foreach ($self->get_exclusions_for_role($role->name)) {
53 return 1 if $_ eq $method_name;
54 }
55 return 0;
56}
57
58sub is_method_aliased {
59 my ($self, $role, $method_name) = @_;
60 exists $self->get_method_aliases_for_role($role->name)->{$method_name} ? 1 : 0
61}
62
63sub is_aliased_method {
64 my ($self, $role, $method_name) = @_;
65 my %aliased_names = reverse %{$self->get_method_aliases_for_role($role->name)};
66 exists $aliased_names{$method_name} ? 1 : 0;
67}
68
69sub check_role_exclusions {
70 my ($self, $c) = @_;
71
72 my %excluded_roles;
73 for my $role (@{ $c->get_roles }) {
74 my $name = $role->name;
75
76 for my $excluded ($role->get_excluded_roles_list) {
77 push @{ $excluded_roles{$excluded} }, $name;
78 }
79 }
80
81 foreach my $role (@{$c->get_roles}) {
82 foreach my $excluded (keys %excluded_roles) {
83 next unless $role->does_role($excluded);
84
85 my @excluding = @{ $excluded_roles{$excluded} };
86
87 require Moose;
88 Moose->throw_error(sprintf "Conflict detected: Role%s %s exclude%s role '%s'", (@excluding == 1 ? '' : 's'), join(', ', @excluding), (@excluding == 1 ? 's' : ''), $excluded);
89 }
90 }
91
92 $c->add_excluded_roles(keys %excluded_roles);
93}
94
95sub check_required_methods {
96 my ($self, $c) = @_;
97
98 my %all_required_methods =
99 map { $_->name => $_ }
100 map { $_->get_required_method_list }
101 @{$c->get_roles};
102
103 foreach my $role (@{$c->get_roles}) {
104 foreach my $required (keys %all_required_methods) {
105
106 delete $all_required_methods{$required}
107 if $role->has_method($required)
108 || $self->is_aliased_method($role, $required);
109 }
110 }
111
112 $c->add_required_methods(values %all_required_methods);
113}
114
115sub check_required_attributes {
116
117}
118
119sub apply_attributes {
120 my ($self, $c) = @_;
121
122 my @all_attributes;
123
124 for my $role ( @{ $c->get_roles } ) {
125 push @all_attributes,
126 map { $role->get_attribute($_) } $role->get_attribute_list;
127 }
128
129 my %seen;
130 foreach my $attr (@all_attributes) {
131 my $name = $attr->name;
132
133 if ( exists $seen{$name} ) {
134 next if $seen{$name}->is_same_as($attr);
135
136 my $role1 = $seen{$name}->associated_role->name;
137 my $role2 = $attr->associated_role->name;
138
139 require Moose;
140 Moose->throw_error(
141 "We have encountered an attribute conflict with '$name' "
142 . "during role composition. "
143 . " This attribute is defined in both $role1 and $role2."
144 . " This is a fatal error and cannot be disambiguated." );
145 }
146
147 $seen{$name} = $attr;
148 }
149
150 foreach my $attr (@all_attributes) {
151 $c->add_attribute( $attr->clone );
152 }
153}
154
155sub apply_methods {
156 my ($self, $c) = @_;
157
158 my @all_methods = map {
159 my $role = $_;
160 my $aliases = $self->get_method_aliases_for_role($role);
161 my %excludes = map { $_ => undef } @{ $self->get_exclusions_for_role($role) };
162 (
163 (map {
164 exists $excludes{$_} ? () :
165 +{
166 role => $role,
167 name => $_,
168 method => $role->get_method($_),
169 }
170 } map { $_->name }
171 grep { !$_->isa('Class::MOP::Method::Meta') }
172 $role->_get_local_methods),
173 (map {
174 +{
175 role => $role,
176 name => $aliases->{$_},
177 method => $role->get_method($_),
178 }
179 } keys %$aliases)
180 );
181 } @{$c->get_roles};
182
183 my (%seen, %conflicts, %method_map);
184 foreach my $method (@all_methods) {
185 next if $conflicts{$method->{name}};
186 my $seen = $seen{$method->{name}};
187
188 if ($seen) {
189 if ($seen->{method}->body != $method->{method}->body) {
190 $c->add_conflicting_method(
191 name => $method->{name},
192 roles => [$method->{role}->name, $seen->{role}->name],
193 );
194
195 delete $method_map{$method->{name}};
196 $conflicts{$method->{name}} = 1;
197 next;
198 }
199 }
200
201 $seen{$method->{name}} = $method;
202 $method_map{$method->{name}} = $method->{method};
203 }
204
205 $c->add_method($_ => $method_map{$_}) for keys %method_map;
206}
207
208sub apply_override_method_modifiers {
209 my ($self, $c) = @_;
210
211 my @all_overrides = map {
212 my $role = $_;
213 map {
214 +{
215 name => $_,
216 method => $role->get_override_method_modifier($_),
217 }
218 } $role->get_method_modifier_list('override');
219 } @{$c->get_roles};
220
221 my %seen;
222 foreach my $override (@all_overrides) {
223 if ( $c->has_method($override->{name}) ){
224 require Moose;
225 Moose->throw_error( "Role '" . $c->name . "' has encountered an 'override' method conflict " .
226 "during composition (A local method of the same name as been found). This " .
227 "is fatal error." )
228 }
229 if (exists $seen{$override->{name}}) {
230 if ( $seen{$override->{name}} != $override->{method} ) {
231 require Moose;
232 Moose->throw_error( "We have encountered an 'override' method conflict during " .
233 "composition (Two 'override' methods of the same name encountered). " .
234 "This is fatal error.")
235 }
236 }
237 $seen{$override->{name}} = $override->{method};
238 }
239
240 $c->add_override_method_modifier(
241 $_->{name}, $_->{method}
242 ) for @all_overrides;
243
244}
245
246sub apply_method_modifiers {
247 my ($self, $modifier_type, $c) = @_;
248 my $add = "add_${modifier_type}_method_modifier";
249 my $get = "get_${modifier_type}_method_modifiers";
250 foreach my $role (@{$c->get_roles}) {
251 foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
252 $c->$add(
253 $method_name,
254 $_
255 ) foreach $role->$get($method_name);
256 }
257 }
258}
259
26017µs1;
261
262# ABSTRACT: Combine two or more roles
263
- -
266=pod
267
268=head1 NAME
269
270Moose::Meta::Role::Application::RoleSummation - Combine two or more roles
271
272=head1 VERSION
273
274version 2.0602
275
276=head1 DESCRIPTION
277
278Summation composes two traits, forming the union of non-conflicting
279bindings and 'disabling' the conflicting bindings
280
281=head2 METHODS
282
283=over 4
284
285=item B<new>
286
287=item B<meta>
288
289=item B<role_params>
290
291=item B<get_exclusions_for_role>
292
293=item B<get_method_aliases_for_role>
294
295=item B<is_aliased_method>
296
297=item B<is_method_aliased>
298
299=item B<is_method_excluded>
300
301=item B<apply>
302
303=item B<check_role_exclusions>
304
305=item B<check_required_methods>
306
307=item B<check_required_attributes>
308
309=item B<apply_attributes>
310
311=item B<apply_methods>
312
313=item B<apply_method_modifiers>
314
315=item B<apply_override_method_modifiers>
316
317=back
318
319=head1 BUGS
320
321See L<Moose/BUGS> for details on reporting bugs.
322
323=head1 AUTHOR
324
325Moose is maintained by the Moose Cabal, along with the help of many contributors. See L<Moose/CABAL> and L<Moose/CONTRIBUTORS> for details.
326
327=head1 COPYRIGHT AND LICENSE
328
329This software is copyright (c) 2012 by Infinity Interactive, Inc..
330
331This is free software; you can redistribute it and/or modify it under
332the same terms as the Perl 5 programming language system itself.
333
334=cut
335
336
337__END__