← 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:15 2013

Filename/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Application/ToClass.pm
StatementsExecuted 1925 statements in 3.51ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10112.17ms32.7msMoose::Meta::Role::Application::ToClass::::apply_methodsMoose::Meta::Role::Application::ToClass::apply_methods
3031272µs4.76msMoose::Meta::Role::Application::ToClass::::apply_method_modifiersMoose::Meta::Role::Application::ToClass::apply_method_modifiers
1011230µs232msMoose::Meta::Role::Application::ToClass::::apply_attributesMoose::Meta::Role::Application::ToClass::apply_attributes (recurses: max depth 1, inclusive time 8.01ms)
1011210µs4.24msMoose::Meta::Role::Application::ToClass::::apply_override_method_modifiersMoose::Meta::Role::Application::ToClass::apply_override_method_modifiers
1011116µs240msMoose::Meta::Role::Application::ToClass::::applyMoose::Meta::Role::Application::ToClass::apply (recurses: max depth 1, inclusive time 45.1ms)
101176µs2.16msMoose::Meta::Role::Application::ToClass::::check_role_exclusionsMoose::Meta::Role::Application::ToClass::check_role_exclusions
101173µs444µsMoose::Meta::Role::Application::ToClass::::check_required_methodsMoose::Meta::Role::Application::ToClass::check_required_methods
11119µs40µsMoose::Meta::Role::Application::ToClass::::BEGIN@13Moose::Meta::Role::Application::ToClass::BEGIN@13
1119µs9µsMoose::Meta::Role::Application::ToClass::::BEGIN@2Moose::Meta::Role::Application::ToClass::BEGIN@2
10118µs8µsMoose::Meta::Role::Application::ToClass::::check_required_attributesMoose::Meta::Role::Application::ToClass::check_required_attributes
1116µs30µsMoose::Meta::Role::Application::ToClass::::BEGIN@15Moose::Meta::Role::Application::ToClass::BEGIN@15
1116µs122µsMoose::Meta::Role::Application::ToClass::::BEGIN@14Moose::Meta::Role::Application::ToClass::BEGIN@14
1116µs9µsMoose::Meta::Role::Application::ToClass::::BEGIN@10Moose::Meta::Role::Application::ToClass::BEGIN@10
1116µs16µsMoose::Meta::Role::Application::ToClass::::BEGIN@9Moose::Meta::Role::Application::ToClass::BEGIN@9
1116µs51µsMoose::Meta::Role::Application::ToClass::::BEGIN@17Moose::Meta::Role::Application::ToClass::BEGIN@17
1116µs2.95msMoose::Meta::Role::Application::ToClass::::BEGIN@11Moose::Meta::Role::Application::ToClass::BEGIN@11
0000s0sMoose::Meta::Role::Application::ToClass::::__ANON__[:127]Moose::Meta::Role::Application::ToClass::__ANON__[:127]
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::ToClass;
2
# spent 9µs within Moose::Meta::Role::Application::ToClass::BEGIN@2 which was called: # once (9µs+0s) by Moose::BEGIN@39 at line 4
BEGIN {
318µs $Moose::Meta::Role::Application::ToClass::AUTHORITY = 'cpan:STEVAN';
4128µs19µs}
# spent 9µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@2
5{
62800ns $Moose::Meta::Role::Application::ToClass::VERSION = '2.1005';
7}
8
9220µs226µs
# spent 16µs (6+10) within Moose::Meta::Role::Application::ToClass::BEGIN@9 which was called: # once (6µs+10µs) by Moose::BEGIN@39 at line 9
use strict;
# spent 16µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@9 # spent 10µs making 1 call to strict::import
10219µs212µs
# spent 9µs (6+3) within Moose::Meta::Role::Application::ToClass::BEGIN@10 which was called: # once (6µs+3µs) by Moose::BEGIN@39 at line 10
use warnings;
# spent 9µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@10 # spent 3µs making 1 call to warnings::import
11227µs25.90ms
# spent 2.95ms (6µs+2.95) within Moose::Meta::Role::Application::ToClass::BEGIN@11 which was called: # once (6µs+2.95ms) by Moose::BEGIN@39 at line 11
use metaclass;
# spent 2.95ms making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@11 # spent 2.95ms making 1 call to metaclass::import
12
13224µs262µs
# spent 40µs (19+21) within Moose::Meta::Role::Application::ToClass::BEGIN@13 which was called: # once (19µs+21µs) by Moose::BEGIN@39 at line 13
use List::MoreUtils 'firstval';
# spent 40µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14227µs2238µs
# spent 122µs (6+116) within Moose::Meta::Role::Application::ToClass::BEGIN@14 which was called: # once (6µs+116µs) by Moose::BEGIN@39 at line 14
use Moose::Util 'english_list';
# spent 122µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@14 # spent 116µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
15224µs254µs
# spent 30µs (6+24) within Moose::Meta::Role::Application::ToClass::BEGIN@15 which was called: # once (6µs+24µs) by Moose::BEGIN@39 at line 15
use Scalar::Util 'weaken', 'blessed';
# spent 30µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@15 # spent 24µs making 1 call to Exporter::import
16
172860µs297µs
# spent 51µs (6+45) within Moose::Meta::Role::Application::ToClass::BEGIN@17 which was called: # once (6µs+45µs) by Moose::BEGIN@39 at line 17
use base 'Moose::Meta::Role::Application';
# spent 51µs making 1 call to Moose::Meta::Role::Application::ToClass::BEGIN@17 # spent 45µs making 1 call to base::import
18
1914µs3291µs__PACKAGE__->meta->add_attribute('role' => (
# spent 272µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 14µs making 1 call to Moose::Meta::Role::Application::ToClass::meta # spent 5µs making 1 call to Class::MOP::_definition_context
20 reader => 'role',
21 Class::MOP::_definition_context(),
22));
23
2413µs3269µs__PACKAGE__->meta->add_attribute('class' => (
# spent 256µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::Role::Application::ToClass::meta # spent 5µs making 1 call to Class::MOP::_definition_context
25 accessor => 'class',
26 Class::MOP::_definition_context(),
27));
28
29
# spent 240ms (116µs+240) within Moose::Meta::Role::Application::ToClass::apply which was called 10 times, avg 24.0ms/call: # 10 times (116µs+240ms) by Moose::Meta::Role::apply at line 470 of Moose/Meta/Role.pm, avg 24.0ms/call
sub apply {
30103µs my ($self, $role, $class) = @_;
31
32 # We need weak_ref in CMOP :(
331026µs107µs weaken($self->{role} = $role);
# spent 7µs making 10 calls to Scalar::Util::weaken, avg 710ns/call
341021µs106µs weaken($self->{class} = $class);
# spent 6µs making 10 calls to Scalar::Util::weaken, avg 550ns/call
35
361014µs10240ms $self->SUPER::apply($role, $class);
# spent 285ms making 10 calls to Moose::Meta::Role::Application::apply, avg 28.5ms/call, recursion: max depth 1, sum of overlapping time 44.9ms
37
381013µs1093µs $class->add_role($role);
# spent 93µs making 10 calls to Moose::Meta::Class::add_role, avg 9µs/call
391025µs1095µs $class->add_role_application($self);
# spent 95µs making 10 calls to Moose::Meta::Class::add_role_application, avg 10µs/call
40}
41
42
# spent 2.16ms (76µs+2.09) within Moose::Meta::Role::Application::ToClass::check_role_exclusions which was called 10 times, avg 216µs/call: # 10 times (76µs+2.09ms) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 216µs/call
sub check_role_exclusions {
43102µs my ($self, $role, $class) = @_;
441032µs202.04ms if ($class->excludes_role($role->name)) {
# spent 2.03ms making 10 calls to Moose::Meta::Class::excludes_role, avg 203µs/call # spent 5µs making 9 calls to Class::MOP::Package::name, avg 556ns/call # spent 1µs making 1 call to Moose::Meta::Role::Composite::name
45 $class->throw_error("Conflict detected: " . $class->name . " excludes role '" . $role->name . "'");
46 }
471035µs1048µs foreach my $excluded_role_name ($role->get_excluded_roles_list) {
# spent 48µs making 10 calls to Moose::Meta::Role::get_excluded_roles_list, avg 5µs/call
48 if ($class->does_role($excluded_role_name)) {
49 $class->throw_error("The class " . $class->name . " does the excluded role '$excluded_role_name'");
50 }
51 }
52}
53
54
# spent 444µs (73+371) within Moose::Meta::Role::Application::ToClass::check_required_methods which was called 10 times, avg 44µs/call: # 10 times (73µs+371µs) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 44µs/call
sub check_required_methods {
55103µs my ($self, $role, $class) = @_;
56
57102µs my @missing;
5810800ns my @is_attr;
59
60 # NOTE:
61 # we might need to move this down below the
62 # the attributes so that we can require any
63 # attribute accessors. However I am thinking
64 # that maybe those are somehow exempt from
65 # the require methods stuff.
661015µs1043µs foreach my $required_method ($role->get_required_method_list) {
# spent 43µs making 10 calls to Moose::Meta::Role::get_required_method_list, avg 4µs/call
6745µs46µs my $required_method_name = $required_method->name;
# spent 6µs making 4 calls to Moose::Meta::Role::Method::Required::name, avg 1µs/call
68
6948µs4323µs if (!$class->find_method_by_name($required_method_name)) {
# spent 323µs making 4 calls to Class::MOP::Class::find_method_by_name, avg 81µs/call
70
71 next if $self->is_aliased_method($required_method_name);
72
73 push @missing, $required_method;
74 }
75 }
76
771028µs return unless @missing;
78
79 my $error = '';
80
81 @missing = sort { $a->name cmp $b->name } @missing;
82 my @conflicts = grep { $_->isa('Moose::Meta::Role::Method::Conflicting') } @missing;
83
84 if (@conflicts) {
85 my $conflict = $conflicts[0];
86 my $roles = $conflict->roles_as_english_list;
87
88 my @same_role_conflicts = grep { $_->roles_as_english_list eq $roles } @conflicts;
89
90 if (@same_role_conflicts == 1) {
91 $error
92 .= "Due to a method name conflict in roles "
93 . $roles
94 . ", the method '"
95 . $conflict->name
96 . "' must be implemented or excluded by '"
97 . $class->name
98 . q{'};
99 }
100 else {
101 my $methods
102 = Moose::Util::english_list( map { q{'} . $_->name . q{'} } @same_role_conflicts );
103
104 $error
105 .= "Due to method name conflicts in roles "
106 . $roles
107 . ", the methods "
108 . $methods
109 . " must be implemented or excluded by '"
110 . $class->name
111 . q{'};
112 }
113 }
114 elsif (@missing) {
115 my $noun = @missing == 1 ? 'method' : 'methods';
116
117 my $list
118 = Moose::Util::english_list( map { q{'} . $_ . q{'} } @missing );
119
120 $error
121 .= q{'}
122 . $role->name
123 . "' requires the $noun $list "
124 . "to be implemented by '"
125 . $class->name . q{'};
126
127 if (my $meth = firstval { $class->name->can($_) } @missing) {
128 $error .= ". If you imported functions intending to use them as "
129 . "methods, you need to explicitly mark them as such, via "
130 . $class->name . "->meta->add_method($meth => \\\&$meth)";
131 }
132 }
133
134 $class->throw_error($error);
135}
136
1371014µs
# spent 8µs within Moose::Meta::Role::Application::ToClass::check_required_attributes which was called 10 times, avg 830ns/call: # 10 times (8µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 830ns/call
sub check_required_attributes {
138
139}
140
141
# spent 232ms (230µs+232) within Moose::Meta::Role::Application::ToClass::apply_attributes which was called 10 times, avg 23.2ms/call: # 10 times (230µs+232ms) by Moose::Meta::Role::Application::apply at line 58 of Moose/Meta/Role/Application.pm, avg 23.2ms/call
sub apply_attributes {
142103µs my ($self, $role, $class) = @_;
143
1441034µs1036µs foreach my $attribute_name ($role->get_attribute_list) {
# spent 36µs making 10 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 4µs/call
145 # it if it has one already
1461959µs1974µs if ($class->has_attribute($attribute_name) &&
# spent 74µs making 19 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 4µs/call
147 # make sure we haven't seen this one already too
148 $class->get_attribute($attribute_name) != $role->get_attribute($attribute_name)) {
149 next;
150 }
151 else {
1521955µs57239ms $class->add_attribute(
# spent 207ms making 19 calls to Moose::Meta::Class::add_attribute, avg 10.9ms/call # spent 33.3ms making 19 calls to Moose::Meta::Role::Attribute::attribute_for_class, avg 1.75ms/call, recursion: max depth 1, sum of overlapping time 472µs # spent 60µs making 19 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 3µs/call
153 $role->get_attribute($attribute_name)->attribute_for_class
154 );
155 }
156 }
157}
158
159
# spent 32.7ms (2.17+30.5) within Moose::Meta::Role::Application::ToClass::apply_methods which was called 10 times, avg 3.27ms/call: # 10 times (2.17ms+30.5ms) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 3.27ms/call
sub apply_methods {
160102µs my ( $self, $role, $class ) = @_;
161
1621045µs103.34ms foreach my $method ( $role->_get_local_methods ) {
# spent 3.33ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 371µs/call # spent 10µs making 1 call to Moose::Meta::Role::Composite::_get_local_methods
163208455µs208109µs my $method_name = $method->name;
# spent 109µs making 208 calls to Class::MOP::Method::name, avg 523ns/call
164
165208485µs208216µs next if $method->isa('Class::MOP::Method::Meta');
# spent 216µs making 208 calls to UNIVERSAL::isa, avg 1µs/call
166
167199152µs199818µs unless ( $self->is_method_excluded($method_name) ) {
# spent 818µs making 199 calls to Moose::Meta::Role::Application::is_method_excluded, avg 4µs/call
168
169199144µs1998.75ms my $class_method = $class->get_method($method_name);
# spent 8.75ms making 199 calls to Class::MOP::Mixin::HasMethods::get_method, avg 44µs/call
170
171199400ns next if $class_method && $class_method->body != $method->body;
172
173199173µs19916.5ms $class->add_method(
# spent 16.5ms making 199 calls to Class::MOP::Mixin::HasMethods::add_method, avg 83µs/call
174 $method_name,
175 $method,
176 );
177 }
178
179199217µs199752µs next unless $self->is_method_aliased($method_name);
# spent 752µs making 199 calls to Moose::Meta::Role::Application::is_method_aliased, avg 4µs/call
180
181 my $aliased_method_name = $self->get_method_aliases->{$method_name};
182
183 my $class_method = $class->get_method($aliased_method_name);
184
185 if ( $class_method && $class_method->body != $method->body ) {
186 $class->throw_error(
187 "Cannot create a method alias if a local method of the same name exists"
188 );
189 }
190
191 $class->add_method(
192 $aliased_method_name,
193 $method,
194 );
195 }
196
197 # we must reset the cache here since
198 # we are just aliasing methods, otherwise
199 # the modifiers go wonky.
2001027µs1010µs $class->reset_package_cache_flag;
# spent 10µs making 10 calls to Class::MOP::Mixin::HasMethods::reset_package_cache_flag, avg 1µs/call
201}
202
203
# spent 4.24ms (210µs+4.03) within Moose::Meta::Role::Application::ToClass::apply_override_method_modifiers which was called 10 times, avg 424µs/call: # 10 times (210µs+4.03ms) by Moose::Meta::Role::Application::apply at line 61 of Moose/Meta/Role/Application.pm, avg 424µs/call
sub apply_override_method_modifiers {
204103µs my ($self, $role, $class) = @_;
2051030µs1057µs foreach my $method_name ($role->get_method_modifier_list('override')) {
# spent 57µs making 10 calls to Moose::Meta::Role::get_method_modifier_list, avg 6µs/call
206 # it if it has one already then ...
2072127µs21669µs if ($class->has_method($method_name)) {
# spent 669µs making 21 calls to Class::MOP::Mixin::HasMethods::has_method, avg 32µs/call
208 next;
209 }
210 else {
211 # if this is not a role, then we need to
212 # find the original package of the method
213 # so that we can tell the class were to
214 # find the right super() method
2152118µs2182µs my $method = $role->get_override_method_modifier($method_name);
# spent 82µs making 21 calls to Moose::Meta::Role::get_override_method_modifier, avg 4µs/call
2162162µs2124µs my ($package) = Class::MOP::get_code_info($method);
# spent 24µs making 21 calls to Class::MOP::get_code_info, avg 1µs/call
217 # if it is a class, we just add it
2182123µs213.20ms $class->add_override_method_modifier($method_name, $method, $package);
# spent 3.20ms making 21 calls to Moose::Meta::Class::add_override_method_modifier, avg 152µs/call
219 }
220 }
221}
222
223
# spent 4.76ms (272µs+4.49) within Moose::Meta::Role::Application::ToClass::apply_method_modifiers which was called 30 times, avg 159µs/call: # 10 times (153µs+3.73ms) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 388µs/call # 10 times (66µs+616µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 77 of Moose/Meta/Role/Application.pm, avg 68µs/call # 10 times (53µs+150µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 20µs/call
sub apply_method_modifiers {
224309µs my ($self, $modifier_type, $role, $class) = @_;
225309µs my $add = "add_${modifier_type}_method_modifier";
226306µs my $get = "get_${modifier_type}_method_modifiers";
2273082µs30145µs foreach my $method_name ($role->get_method_modifier_list($modifier_type)) {
# spent 145µs making 30 calls to Moose::Meta::Role::get_method_modifier_list, avg 5µs/call
228 $class->$add(
229 $method_name,
230 $_
2312490µs484.35ms ) foreach $role->$get($method_name);
# spent 3.59ms making 21 calls to Class::MOP::Class::add_around_method_modifier, avg 171µs/call # spent 559µs making 2 calls to Class::MOP::Class::add_before_method_modifier, avg 280µs/call # spent 98µs making 1 call to Class::MOP::Class::add_after_method_modifier # spent 87µs making 21 calls to Moose::Meta::Role::get_around_method_modifiers, avg 4µs/call # spent 10µs making 2 calls to Moose::Meta::Role::get_before_method_modifiers, avg 5µs/call # spent 5µs making 1 call to Moose::Meta::Role::get_after_method_modifiers
232 }
233}
234
23515µs1;
236
237# ABSTRACT: Compose a role into a class
238
239__END__