Profile of /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Role/Application/ToRole.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:23:17 2010

File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Meta/Role/Application/ToRole.pm
Statements Executed | 808
Statement Execution Time | 2.19ms

Subroutines — ordered by exclusive time
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
13 | 1 | 1 | 906µs | 26.2ms | Moose::Meta::Role::Application::ToRole::::apply_methodsMoose::Meta::Role::Application::ToRole::apply_methods
39 | 3 | 1 | 354µs | 1.12ms | Moose::Meta::Role::Application::ToRole::::apply_method_modifiersMoose::Meta::Role::Application::ToRole::apply_method_modifiers
13 | 1 | 1 | 350µs | 2.63ms | Moose::Meta::Role::Application::ToRole::::apply_attributesMoose::Meta::Role::Application::ToRole::apply_attributes
13 | 1 | 1 | 162µs | 1.32ms | Moose::Meta::Role::Application::ToRole::::check_required_methodsMoose::Meta::Role::Application::ToRole::check_required_methods
13 | 1 | 1 | 134µs | 32.6ms | Moose::Meta::Role::Application::ToRole::::applyMoose::Meta::Role::Application::ToRole::apply
13 | 1 | 1 | 129µs | 301µs | Moose::Meta::Role::Application::ToRole::::check_role_exclusionsMoose::Meta::Role::Application::ToRole::check_role_exclusions
13 | 1 | 1 | 60µs | 156µs | Moose::Meta::Role::Application::ToRole::::apply_override_method_modifiersMoose::Meta::Role::Application::ToRole::apply_override_method_modifiers
1 | 1 | 1 | 15µs | 18µs | Moose::Meta::Role::Application::ToRole::::BEGIN@3Moose::Meta::Role::Application::ToRole::BEGIN@3
13 | 1 | 1 | 13µs | 13µs | Moose::Meta::Role::Application::ToRole::::check_required_attributesMoose::Meta::Role::Application::ToRole::check_required_attributes
1 | 1 | 1 | 8µs | 34µs | Moose::Meta::Role::Application::ToRole::::BEGIN@7Moose::Meta::Role::Application::ToRole::BEGIN@7
1 | 1 | 1 | 8µs | 17µs | Moose::Meta::Role::Application::ToRole::::BEGIN@4Moose::Meta::Role::Application::ToRole::BEGIN@4
1 | 1 | 1 | 7µs | 47µs | Moose::Meta::Role::Application::ToRole::::BEGIN@13Moose::Meta::Role::Application::ToRole::BEGIN@13
1 | 1 | 1 | 7µs | 103µs | Moose::Meta::Role::Application::ToRole::::BEGIN@5Moose::Meta::Role::Application::ToRole::BEGIN@5

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Moose::Meta::Role::Application::ToRole;
2 |  |  |  |  |
3 | 3 | 21µs | 2 | 21µs | # spent 18µs (15+3) within Moose::Meta::Role::Application::ToRole::BEGIN@3 which was called # once (15µs+3µs) by Moose::BEGIN@31 at line 3 use strict; # spent 18µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@3 # spent 3µs making 1 call to strict::import
4 | 3 | 19µs | 2 | 26µs | # spent 17µs (8+9) within Moose::Meta::Role::Application::ToRole::BEGIN@4 which was called # once (8µs+9µs) by Moose::BEGIN@31 at line 4 use warnings; # spent 17µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@4 # spent 9µs making 1 call to warnings::import
5 | 3 | 33µs | 2 | 200µs | # spent 103µs (7+96) within Moose::Meta::Role::Application::ToRole::BEGIN@5 which was called # once (7µs+96µs) by Moose::BEGIN@31 at line 5 use metaclass; # spent 103µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@5 # spent 96µs making 1 call to metaclass::import
6 |  |  |  |  |
7 | 3 | 45µs | 2 | 61µs | # spent 34µs (8+27) within Moose::Meta::Role::Application::ToRole::BEGIN@7 which was called # once (8µs+27µs) by Moose::BEGIN@31 at line 7 use Scalar::Util 'blessed'; # spent 34µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@7 # spent 27µs making 1 call to Exporter::import
8 |  |  |  |  |
9 | 1 | 700ns |  |  | our $VERSION = '0.98';
10 | 1 | 18µs |  |  | $VERSION = eval $VERSION;
11 | 1 | 400ns |  |  | our $AUTHORITY = 'cpan:STEVAN';
12 |  |  |  |  |
13 | 3 | 542µs | 2 | 88µs | # spent 47µs (7+40) within Moose::Meta::Role::Application::ToRole::BEGIN@13 which was called # once (7µs+40µs) by Moose::BEGIN@31 at line 13 use base 'Moose::Meta::Role::Application'; # spent 47µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@13 # spent 40µs making 1 call to base::import
14 |  |  |  |  |
15 |  |  |  |  | # spent 32.6ms (134µs+32.5) within Moose::Meta::Role::Application::ToRole::apply which was called 13 times, avg 2.51ms/call: # 13 times (134µs+32.5ms) by Moose::Meta::Role::apply at line 419 of Moose/Meta/Role.pm, avg 2.51ms/call sub apply {
16 | 13 | 8µs |  |  | my ($self, $role1, $role2) = @_;
17 | 13 | 68µs | 13 | 32.3ms | $self->SUPER::apply($role1, $role2); # spent 32.3ms making 13 calls to Moose::Meta::Role::Application::apply, avg 2.48ms/call
18 | 13 | 41µs | 13 | 208µs | $role2->add_role($role1); # spent 208µs making 13 calls to Moose::Meta::Role::add_role, avg 16µs/call
19 |  |  |  |  | }
20 |  |  |  |  |
21 |  |  |  |  | # spent 301µs (129+173) within Moose::Meta::Role::Application::ToRole::check_role_exclusions which was called 13 times, avg 23µs/call: # 13 times (129µs+173µs) by Moose::Meta::Role::Application::apply at line 68 of Moose/Meta/Role/Application.pm, avg 23µs/call sub check_role_exclusions {
22 | 13 | 7µs |  |  | my ($self, $role1, $role2) = @_;
23 | 13 | 59µs | 26 | 102µs | if ( $role2->excludes_role($role1->name) ) { # spent 92µs making 13 calls to Moose::Meta::Role::excludes_role, avg 7µs/call # spent 10µs making 13 calls to Class::MOP::Package::name, avg 738ns/call
24 |  |  |  |  | require Moose;
25 |  |  |  |  | Moose->throw_error("Conflict detected: " . $role2->name . " excludes role '" . $role1->name . "'");
26 |  |  |  |  | }
27 | 13 | 54µs | 13 | 70µs | foreach my $excluded_role_name ($role1->get_excluded_roles_list) { # spent 70µs making 13 calls to Moose::Meta::Role::get_excluded_roles_list, avg 5µs/call
28 |  |  |  |  | if ( $role2->does_role($excluded_role_name) ) {
29 |  |  |  |  | require Moose;
30 |  |  |  |  | Moose->throw_error("The class " . $role2->name . " does the excluded role '$excluded_role_name'");
31 |  |  |  |  | }
32 |  |  |  |  | $role2->add_excluded_roles($excluded_role_name);
33 |  |  |  |  | }
34 |  |  |  |  | }
35 |  |  |  |  |
36 |  |  |  |  | # spent 1.32ms (162µs+1.16) within Moose::Meta::Role::Application::ToRole::check_required_methods which was called 13 times, avg 102µs/call: # 13 times (162µs+1.16ms) by Moose::Meta::Role::Application::apply at line 69 of Moose/Meta/Role/Application.pm, avg 102µs/call sub check_required_methods {
37 | 13 | 7µs |  |  | my ($self, $role1, $role2) = @_;
38 | 13 | 47µs | 13 | 83µs | foreach my $required_method ($role1->get_required_method_list) { # spent 83µs making 13 calls to Moose::Meta::Role::get_required_method_list, avg 6µs/call
39 | 10 | 19µs | 10 | 26µs | my $required_method_name = $required_method->name; # spent 26µs making 10 calls to Moose::Meta::Role::Method::Required::name, avg 3µs/call
40 |  |  |  |  |
41 | 10 | 20µs | 10 | 81µs | next if $self->is_aliased_method($required_method_name); # spent 81µs making 10 calls to Moose::Meta::Role::Application::is_aliased_method, avg 8µs/call
42 |  |  |  |  |
43 | 10 | 33µs | 11 | 968µs | $role2->add_required_methods($required_method) # spent 951µs making 10 calls to Moose::Meta::Role::find_method_by_name, avg 95µs/call # spent 18µs making 1 call to Moose::Meta::Role::add_required_methods
44 |  |  |  |  | unless $role2->find_method_by_name($required_method_name);
45 |  |  |  |  | }
46 |  |  |  |  | }
47 |  |  |  |  |
48 | 13 | 23µs |  |  | # spent 13µs within Moose::Meta::Role::Application::ToRole::check_required_attributes which was called 13 times, avg 985ns/call: # 13 times (13µs+0s) by Moose::Meta::Role::Application::apply at line 70 of Moose/Meta/Role/Application.pm, avg 985ns/call sub check_required_attributes {
49 |  |  |  |  |
50 |  |  |  |  | }
51 |  |  |  |  |
52 |  |  |  |  | # spent 2.63ms (350µs+2.27) within Moose::Meta::Role::Application::ToRole::apply_attributes which was called 13 times, avg 202µs/call: # 13 times (350µs+2.27ms) by Moose::Meta::Role::Application::apply at line 72 of Moose/Meta/Role/Application.pm, avg 202µs/call sub apply_attributes {
53 | 13 | 7µs |  |  | my ($self, $role1, $role2) = @_;
54 | 13 | 53µs | 13 | 74µs | foreach my $attribute_name ($role1->get_attribute_list) { # spent 74µs making 13 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 6µs/call
55 |  |  |  |  | # it if it has one already
56 | 30 | 69µs | 30 | 138µs | if ($role2->has_attribute($attribute_name) && # spent 138µs making 30 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 5µs/call
57 |  |  |  |  | # make sure we haven't seen this one already too
58 |  |  |  |  | $role2->get_attribute($attribute_name) != $role1->get_attribute($attribute_name)) {
59 |  |  |  |  |
60 |  |  |  |  | require Moose;
61 |  |  |  |  | Moose->throw_error("Role '" . $role1->name . "' has encountered an attribute conflict " .
62 |  |  |  |  | "during composition. This is fatal error and cannot be disambiguated.");
63 |  |  |  |  | }
64 |  |  |  |  | else {
65 | 30 | 99µs | 90 | 2.06ms | $role2->add_attribute( # spent 1.42ms making 30 calls to Moose::Meta::Role::add_attribute, avg 47µs/call # spent 495µs making 30 calls to Moose::Meta::Role::Attribute::clone, avg 16µs/call # spent 144µs making 30 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 5µs/call
66 |  |  |  |  | $role1->get_attribute($attribute_name)->clone
67 |  |  |  |  | );
68 |  |  |  |  | }
69 |  |  |  |  | }
70 |  |  |  |  | }
71 |  |  |  |  |
72 |  |  |  |  | # spent 26.2ms (906µs+25.3) within Moose::Meta::Role::Application::ToRole::apply_methods which was called 13 times, avg 2.02ms/call: # 13 times (906µs+25.3ms) by Moose::Meta::Role::Application::apply at line 73 of Moose/Meta/Role/Application.pm, avg 2.02ms/call sub apply_methods {
73 | 13 | 8µs |  |  | my ($self, $role1, $role2) = @_;
74 | 13 | 51µs | 13 | 8.23ms | foreach my $method_name ($role1->get_method_list) { # spent 8.23ms making 13 calls to Class::MOP::Mixin::HasMethods::get_method_list, avg 633µs/call
75 | 82 | 18µs |  |  | next if $method_name eq 'meta';
76 |  |  |  |  |
77 | 69 | 243µs | 145 | 2.85ms | unless ( $self->is_method_excluded($method_name) ) { # spent 2.23ms making 69 calls to Class::MOP::Mixin::HasMethods::has_method, avg 32µs/call # spent 422µs making 69 calls to Moose::Meta::Role::Application::is_method_excluded, avg 6µs/call # spent 153µs making 1 call to Moose::Meta::Role::add_conflicting_method # spent 47µs making 2 calls to Class::MOP::Mixin::HasMethods::get_method, avg 23µs/call # spent 1µs making 2 calls to Class::MOP::Method::body, avg 500ns/call # spent 900ns making 2 calls to Class::MOP::Package::name, avg 450ns/call
78 |  |  |  |  | if ( $role2->has_method($method_name)
79 |  |  |  |  | && $role2->get_method($method_name)->body
80 |  |  |  |  | != $role1->get_method($method_name)->body ) {
81 |  |  |  |  |
82 |  |  |  |  | # method conflicts between roles result in the method becoming
83 |  |  |  |  | # a requirement
84 |  |  |  |  | $role2->add_conflicting_method(
85 |  |  |  |  | name => $method_name,
86 |  |  |  |  | roles => [ $role1->name, $role2->name ],
87 |  |  |  |  | );
88 |  |  |  |  | }
89 |  |  |  |  | else {
90 | 68 | 130µs | 136 | 13.9ms | $role2->add_method( # spent 12.4ms making 68 calls to Class::MOP::Mixin::HasMethods::add_method, avg 182µs/call # spent 1.46ms making 68 calls to Class::MOP::Mixin::HasMethods::get_method, avg 22µs/call
91 |  |  |  |  | $method_name,
92 |  |  |  |  | $role1->get_method($method_name)
93 |  |  |  |  | );
94 |  |  |  |  | }
95 |  |  |  |  | }
96 |  |  |  |  |
97 | 69 | 120µs | 69 | 377µs | if ($self->is_method_aliased($method_name)) { # spent 377µs making 69 calls to Moose::Meta::Role::Application::is_method_aliased, avg 5µs/call
98 |  |  |  |  | my $aliased_method_name = $self->get_method_aliases->{$method_name};
99 |  |  |  |  |
100 |  |  |  |  | if ($role2->has_method($aliased_method_name) &&
101 |  |  |  |  | $role2->get_method($aliased_method_name)->body != $role1->get_method($method_name)->body) {
102 |  |  |  |  |
103 |  |  |  |  | require Moose;
104 |  |  |  |  | Moose->throw_error("Cannot create a method alias if a local method of the same name exists");
105 |  |  |  |  | }
106 |  |  |  |  |
107 |  |  |  |  | $role2->add_method(
108 |  |  |  |  | $aliased_method_name,
109 |  |  |  |  | $role1->get_method($method_name)
110 |  |  |  |  | );
111 |  |  |  |  |
112 |  |  |  |  | if (!$role2->has_method($method_name)) {
113 |  |  |  |  | $role2->add_required_methods($method_name)
114 |  |  |  |  | unless $self->is_method_excluded($method_name);
115 |  |  |  |  | }
116 |  |  |  |  | }
117 |  |  |  |  | }
118 |  |  |  |  | }
119 |  |  |  |  |
120 |  |  |  |  | # spent 156µs (60+96) within Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers which was called 13 times, avg 12µs/call: # 13 times (60µs+96µs) by Moose::Meta::Role::Application::apply at line 75 of Moose/Meta/Role/Application.pm, avg 12µs/call sub apply_override_method_modifiers {
121 | 13 | 6µs |  |  | my ($self, $role1, $role2) = @_;
122 | 13 | 55µs | 13 | 96µs | foreach my $method_name ($role1->get_method_modifier_list('override')) { # spent 96µs making 13 calls to Moose::Meta::Role::get_method_modifier_list, avg 7µs/call
123 |  |  |  |  | # it if it has one already then ...
124 |  |  |  |  | if ($role2->has_method($method_name)) {
125 |  |  |  |  | # if it is being composed into another role
126 |  |  |  |  | # we have a conflict here, because you cannot
127 |  |  |  |  | # combine an overridden method with a locally
128 |  |  |  |  | # defined one
129 |  |  |  |  | require Moose;
130 |  |  |  |  | Moose->throw_error("Role '" . $role1->name . "' has encountered an 'override' method conflict " .
131 |  |  |  |  | "during composition (A local method of the same name as been found). This " .
132 |  |  |  |  | "is fatal error.");
133 |  |  |  |  | }
134 |  |  |  |  | else {
135 |  |  |  |  | # if we are a role, we need to make sure
136 |  |  |  |  | # we dont have a conflict with the role
137 |  |  |  |  | # we are composing into
138 |  |  |  |  | if ($role2->has_override_method_modifier($method_name) &&
139 |  |  |  |  | $role2->get_override_method_modifier($method_name) != $role2->get_override_method_modifier($method_name)) {
140 |  |  |  |  |
141 |  |  |  |  | require Moose;
142 |  |  |  |  | Moose->throw_error("Role '" . $role1->name . "' has encountered an 'override' method conflict " .
143 |  |  |  |  | "during composition (Two 'override' methods of the same name encountered). " .
144 |  |  |  |  | "This is fatal error.");
145 |  |  |  |  | }
146 |  |  |  |  | else {
147 |  |  |  |  | # if there is no conflict,
148 |  |  |  |  | # just add it to the role
149 |  |  |  |  | $role2->add_override_method_modifier(
150 |  |  |  |  | $method_name,
151 |  |  |  |  | $role1->get_override_method_modifier($method_name)
152 |  |  |  |  | );
153 |  |  |  |  | }
154 |  |  |  |  | }
155 |  |  |  |  | }
156 |  |  |  |  | }
157 |  |  |  |  |
158 |  |  |  |  | # spent 1.12ms (354µs+766µs) within Moose::Meta::Role::Application::ToRole::apply_method_modifiers which was called 39 times, avg 29µs/call: # 13 times (163µs+410µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 93 of Moose/Meta/Role/Application.pm, avg 44µs/call # 13 times (138µs+283µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 91 of Moose/Meta/Role/Application.pm, avg 32µs/call # 13 times (54µs+73µs) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 92 of Moose/Meta/Role/Application.pm, avg 10µs/call sub apply_method_modifiers {
159 | 39 | 20µs |  |  | my ($self, $modifier_type, $role1, $role2) = @_;
160 | 39 | 14µs |  |  | my $add = "add_${modifier_type}_method_modifier";
161 | 39 | 9µs |  |  | my $get = "get_${modifier_type}_method_modifiers";
162 | 39 | 110µs | 39 | 218µs | foreach my $method_name ($role1->get_method_modifier_list($modifier_type)) { # spent 218µs making 39 calls to Moose::Meta::Role::get_method_modifier_list, avg 6µs/call
163 |  |  |  |  | $role2->$add(
164 |  |  |  |  | $method_name,
165 |  |  |  |  | $_
166 | 60 | 112µs | 60 | 548µs | ) foreach $role1->$get($method_name); # spent 236µs making 20 calls to Moose::Meta::Role::add_after_method_modifier, avg 12µs/call # spent 142µs making 10 calls to Moose::Meta::Role::add_before_method_modifier, avg 14µs/call # spent 102µs making 20 calls to Moose::Meta::Role::get_after_method_modifiers, avg 5µs/call # spent 68µs making 10 calls to Moose::Meta::Role::get_before_method_modifiers, avg 7µs/call
167 |  |  |  |  | }
168 |  |  |  |  | }
169 |  |  |  |  |
170 |  |  |  |  |
171 | 1 | 8µs |  |  | 1;
172 |  |  |  |  |
173 |  |  |  |  | __END__
174 |  |  |  |  |
175 |  |  |  |  | =pod
176 |  |  |  |  |
177 |  |  |  |  | =head1 NAME
178 |  |  |  |  |
179 |  |  |  |  | Moose::Meta::Role::Application::ToRole - Compose a role into another role
180 |  |  |  |  |
181 |  |  |  |  | =head1 DESCRIPTION
182 |  |  |  |  |
183 |  |  |  |  | =head2 METHODS
184 |  |  |  |  |
185 |  |  |  |  | =over 4
186 |  |  |  |  |
187 |  |  |  |  | =item B<new>
188 |  |  |  |  |
189 |  |  |  |  | =item B<meta>
190 |  |  |  |  |
191 |  |  |  |  | =item B<apply>
192 |  |  |  |  |
193 |  |  |  |  | =item B<check_role_exclusions>
194 |  |  |  |  |
195 |  |  |  |  | =item B<check_required_methods>
196 |  |  |  |  |
197 |  |  |  |  | =item B<check_required_attributes>
198 |  |  |  |  |
199 |  |  |  |  | =item B<apply_attributes>
200 |  |  |  |  |
201 |  |  |  |  | =item B<apply_methods>
202 |  |  |  |  |
203 |  |  |  |  | =item B<apply_method_modifiers>
204 |  |  |  |  |
205 |  |  |  |  | =item B<apply_override_method_modifiers>
206 |  |  |  |  |
207 |  |  |  |  | =back
208 |  |  |  |  |
209 |  |  |  |  | =head1 BUGS
210 |  |  |  |  |
211 |  |  |  |  | See L<Moose/BUGS> for details on reporting bugs.
212 |  |  |  |  |
213 |  |  |  |  | =head1 AUTHOR
214 |  |  |  |  |
215 |  |  |  |  | Stevan Little E<lt>stevan@iinteractive.comE<gt>
216 |  |  |  |  |
217 |  |  |  |  | =head1 COPYRIGHT AND LICENSE
218 |  |  |  |  |
219 |  |  |  |  | Copyright 2006-2010 by Infinity Interactive, Inc.
220 |  |  |  |  |
221 |  |  |  |  | L<http://www.iinteractive.com>
222 |  |  |  |  |
223 |  |  |  |  | This library is free software; you can redistribute it and/or modify
224 |  |  |  |  | it under the same terms as Perl itself.
225 |  |  |  |  |
226 |  |  |  |  | =cut
227 |  |  |  |  |