← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:11 2016

Filename/usr/local/lib/perl/5.18.2/Moose/Meta/Role/Application/ToRole.pm
StatementsExecuted 2201 statements in 3.82ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
14115.50ms44.2msMoose::Meta::Role::Application::ToRole::::apply_methodsMoose::Meta::Role::Application::ToRole::apply_methods
1411355µs1.86msMoose::Meta::Role::Application::ToRole::::apply_override_method_modifiersMoose::Meta::Role::Application::ToRole::apply_override_method_modifiers
4231329µs1.01msMoose::Meta::Role::Application::ToRole::::apply_method_modifiersMoose::Meta::Role::Application::ToRole::apply_method_modifiers
1411264µs1.85msMoose::Meta::Role::Application::ToRole::::check_required_methodsMoose::Meta::Role::Application::ToRole::check_required_methods
1411135µs292µsMoose::Meta::Role::Application::ToRole::::check_role_exclusionsMoose::Meta::Role::Application::ToRole::check_role_exclusions
141196µs50.8msMoose::Meta::Role::Application::ToRole::::applyMoose::Meta::Role::Application::ToRole::apply
141185µs327µsMoose::Meta::Role::Application::ToRole::::apply_attributesMoose::Meta::Role::Application::ToRole::apply_attributes
141115µs15µsMoose::Meta::Role::Application::ToRole::::check_required_attributesMoose::Meta::Role::Application::ToRole::check_required_attributes
11110µs22µsMoose::Meta::Role::Application::ToRole::::BEGIN@4Moose::Meta::Role::Application::ToRole::BEGIN@4
1118µs130µsMoose::Meta::Role::Application::ToRole::::BEGIN@10Moose::Meta::Role::Application::ToRole::BEGIN@10
1117µs25µsMoose::Meta::Role::Application::ToRole::::BEGIN@8Moose::Meta::Role::Application::ToRole::BEGIN@8
1117µs12µsMoose::Meta::Role::Application::ToRole::::BEGIN@5Moose::Meta::Role::Application::ToRole::BEGIN@5
1116µs381µsMoose::Meta::Role::Application::ToRole::::BEGIN@6Moose::Meta::Role::Application::ToRole::BEGIN@6
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::ToRole;
21500nsour $VERSION = '2.1604';
3
4220µs235µs
# spent 22µs (10+12) within Moose::Meta::Role::Application::ToRole::BEGIN@4 which was called: # once (10µs+12µs) by Moose::BEGIN@37 at line 4
use strict;
# spent 22µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@4 # spent 12µs making 1 call to strict::import
5218µs217µs
# spent 12µs (7+5) within Moose::Meta::Role::Application::ToRole::BEGIN@5 which was called: # once (7µs+5µs) by Moose::BEGIN@37 at line 5
use warnings;
# spent 12µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@5 # spent 5µs making 1 call to warnings::import
6225µs2756µs
# spent 381µs (6+375) within Moose::Meta::Role::Application::ToRole::BEGIN@6 which was called: # once (6µs+375µs) by Moose::BEGIN@37 at line 6
use metaclass;
# spent 381µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@6 # spent 375µs making 1 call to metaclass::import
7
8224µs244µs
# spent 25µs (7+18) within Moose::Meta::Role::Application::ToRole::BEGIN@8 which was called: # once (7µs+18µs) by Moose::BEGIN@37 at line 8
use parent 'Moose::Meta::Role::Application';
# spent 25µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@8 # spent 18µs making 1 call to parent::import
9
102552µs2253µs
# spent 130µs (8+122) within Moose::Meta::Role::Application::ToRole::BEGIN@10 which was called: # once (8µs+122µs) by Moose::BEGIN@37 at line 10
use Moose::Util 'throw_exception';
# spent 130µs making 1 call to Moose::Meta::Role::Application::ToRole::BEGIN@10 # spent 122µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
11
12
# spent 50.8ms (96µs+50.7) within Moose::Meta::Role::Application::ToRole::apply which was called 14 times, avg 3.63ms/call: # 14 times (96µs+50.7ms) by Moose::Meta::Role::apply at line 472 of Moose/Meta/Role.pm, avg 3.63ms/call
sub apply {
13145µs my ($self, $role1, $role2) = @_;
141431µs1436.0ms $self->SUPER::apply($role1, $role2);
# spent 50.5ms making 14 calls to Moose::Meta::Role::Application::apply, avg 3.60ms/call, recursion: max depth 1, sum of overlapping time 14.5ms
151448µs14232µs $role2->add_role($role1);
# spent 232µs making 14 calls to Moose::Meta::Role::add_role, avg 17µs/call
16}
17
18
# spent 292µs (135+157) within Moose::Meta::Role::Application::ToRole::check_role_exclusions which was called 14 times, avg 21µs/call: # 14 times (135µs+157µs) by Moose::Meta::Role::Application::apply at line 54 of Moose/Meta/Role/Application.pm, avg 21µs/call
sub check_role_exclusions {
19145µs my ($self, $role1, $role2) = @_;
201456µs2897µs if ( $role2->excludes_role($role1->name) ) {
# spent 84µs making 14 calls to Moose::Meta::Role::excludes_role, avg 6µs/call # spent 7µs making 9 calls to Class::MOP::Package::name, avg 778ns/call # spent 5µs making 5 calls to Moose::Meta::Role::Composite::name, avg 1µs/call
21 throw_exception( ConflictDetectedInCheckRoleExclusions => role_name => $role2->name,
22 excluded_role_name => $role1->name,
23 );
24 }
251458µs1461µs foreach my $excluded_role_name ($role1->get_excluded_roles_list) {
# spent 61µs making 14 calls to Moose::Meta::Role::get_excluded_roles_list, avg 4µs/call
26 if ( $role2->does_role($excluded_role_name) ) {
27 throw_exception( RoleDoesTheExcludedRole => role_name => $role2->name,
28 excluded_role_name => $excluded_role_name,
29 second_role_name => $role1->name,
30 );
31 }
32 $role2->add_excluded_roles($excluded_role_name);
33 }
34}
35
36
# spent 1.85ms (264µs+1.58) within Moose::Meta::Role::Application::ToRole::check_required_methods which was called 14 times, avg 132µs/call: # 14 times (264µs+1.58ms) by Moose::Meta::Role::Application::apply at line 55 of Moose/Meta/Role/Application.pm, avg 132µs/call
sub check_required_methods {
37145µs my ($self, $role1, $role2) = @_;
381454µs1472µs foreach my $required_method ($role1->get_required_method_list) {
# spent 72µs making 14 calls to Moose::Meta::Role::get_required_method_list, avg 5µs/call
392229µs2234µs my $required_method_name = $required_method->name;
# spent 34µs making 22 calls to Moose::Meta::Role::Method::Required::name, avg 2µs/call
40
412230µs22126µs next if $self->is_aliased_method($required_method_name);
# spent 126µs making 22 calls to Moose::Meta::Role::Application::is_aliased_method, avg 6µs/call
42
432265µs441.35ms $role2->add_required_methods($required_method)
# spent 1.26ms making 22 calls to Moose::Meta::Role::find_method_by_name, avg 57µs/call # spent 73µs making 8 calls to Moose::Meta::Role::add_required_methods, avg 9µs/call # spent 14µs making 14 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 1µs/call
44 unless $role2->find_method_by_name($required_method_name);
45 }
46}
47
481431µs
# spent 15µs within Moose::Meta::Role::Application::ToRole::check_required_attributes which was called 14 times, avg 1µs/call: # 14 times (15µs+0s) by Moose::Meta::Role::Application::apply at line 56 of Moose/Meta/Role/Application.pm, avg 1µs/call
sub check_required_attributes {
49
50}
51
52
# spent 327µs (85+241) within Moose::Meta::Role::Application::ToRole::apply_attributes which was called 14 times, avg 23µs/call: # 14 times (85µs+241µs) by Moose::Meta::Role::Application::apply at line 59 of Moose/Meta/Role/Application.pm, avg 23µs/call
sub apply_attributes {
53145µs my ($self, $role1, $role2) = @_;
541456µs1459µs foreach my $attribute_name ($role1->get_attribute_list) {
# spent 59µs making 14 calls to Class::MOP::Mixin::HasAttributes::get_attribute_list, avg 4µs/call
55 # it if it has one already
5627µs29µs if ($role2->has_attribute($attribute_name) &&
# spent 9µs making 2 calls to Class::MOP::Mixin::HasAttributes::has_attribute, avg 4µ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 my $role2_name = $role2->name;
61
62 throw_exception( AttributeConflictInRoles => role_name => $role1->name,
63 second_role_name => $role2->name,
64 attribute_name => $attribute_name
65 );
66 }
67 else {
68210µs6174µs $role2->add_attribute(
# spent 97µs making 2 calls to Moose::Meta::Role::add_attribute, avg 49µs/call # spent 67µs making 2 calls to Moose::Meta::Role::Attribute::clone, avg 34µs/call # spent 10µs making 2 calls to Class::MOP::Mixin::HasAttributes::get_attribute, avg 5µs/call
69 $role1->get_attribute($attribute_name)->clone
70 );
71 }
72 }
73}
74
75
# spent 44.2ms (5.50+38.7) within Moose::Meta::Role::Application::ToRole::apply_methods which was called 14 times, avg 3.15ms/call: # 14 times (5.50ms+38.7ms) by Moose::Meta::Role::Application::apply at line 60 of Moose/Meta/Role/Application.pm, avg 3.15ms/call
sub apply_methods {
76146µs my ( $self, $role1, $role2 ) = @_;
7714107µs1411.5ms foreach my $method ( $role1->_get_local_methods ) {
# spent 11.4ms making 9 calls to Class::MOP::Mixin::HasMethods::_get_local_methods, avg 1.27ms/call # spent 35µs making 5 calls to Moose::Meta::Role::Composite::_get_local_methods, avg 7µs/call
78
79238479µs238109µs my $method_name = $method->name;
# spent 109µs making 238 calls to Class::MOP::Method::name, avg 457ns/call
80
81238603µs238279µs next if $method->isa('Class::MOP::Method::Meta');
# spent 279µs making 238 calls to UNIVERSAL::isa, avg 1µs/call
82
83229190µs229853µs unless ( $self->is_method_excluded($method_name) ) {
# spent 853µs making 229 calls to Moose::Meta::Role::Application::is_method_excluded, avg 4µs/call
84
85229169µs2298.62ms my $role2_method = $role2->get_method($method_name);
# spent 8.62ms making 229 calls to Class::MOP::Mixin::HasMethods::get_method, avg 38µs/call
86229164µs6028µs if ( $role2_method
# spent 14µs making 20 calls to Class::MOP::Method::__ANON__[Class/MOP/Method.pm:16], avg 710ns/call # spent 14µs making 40 calls to Class::MOP::Method::body, avg 340ns/call
87 && $role2_method->body != $method->body ) {
88
89 # method conflicts between roles used to result in the method
90 # becoming a requirement but now are permitted just like
91 # for classes, hence no code in this branch anymore.
92 }
93 else {
94209181µs20916.5ms $role2->add_method(
# spent 16.5ms making 209 calls to Class::MOP::Mixin::HasMethods::add_method, avg 79µs/call
95 $method_name,
96 $method,
97 );
98 }
99 }
100
101229277µs229818µs next unless $self->is_method_aliased($method_name);
# spent 818µs making 229 calls to Moose::Meta::Role::Application::is_method_aliased, avg 4µs/call
102
103 my $aliased_method_name = $self->get_method_aliases->{$method_name};
104
105 my $role2_method = $role2->get_method($aliased_method_name);
106
107 if ( $role2_method
108 && $role2_method->body != $method->body ) {
109
110 throw_exception( CannotCreateMethodAliasLocalMethodIsPresent => aliased_method_name => $aliased_method_name,
111 method => $method,
112 role_name => $role2->name,
113 role_being_applied_name => $role1->name,
114 );
115 }
116
117 $role2->add_method(
118 $aliased_method_name,
119 $role1->get_method($method_name)
120 );
121
122 if ( !$role2->has_method($method_name) ) {
123 $role2->add_required_methods($method_name)
124 unless $self->is_method_excluded($method_name);
125 }
126 }
127}
128
129
# spent 1.86ms (355µs+1.50) within Moose::Meta::Role::Application::ToRole::apply_override_method_modifiers which was called 14 times, avg 133µs/call: # 14 times (355µs+1.50ms) by Moose::Meta::Role::Application::apply at line 62 of Moose/Meta/Role/Application.pm, avg 133µs/call
sub apply_override_method_modifiers {
130146µs my ($self, $role1, $role2) = @_;
1311459µs14102µs foreach my $method_name ($role1->get_method_modifier_list('override')) {
# spent 102µs making 14 calls to Moose::Meta::Role::get_method_modifier_list, avg 7µs/call
132 # it if it has one already then ...
1333651µs36515µs if ($role2->has_method($method_name)) {
# spent 515µs making 36 calls to Class::MOP::Mixin::HasMethods::has_method, avg 14µs/call
134 # if it is being composed into another role
135 # we have a conflict here, because you cannot
136 # combine an overridden method with a locally
137 # defined one
138 throw_exception( OverrideConflictInComposition => role_name => $role2->name,
139 role_being_applied_name => $role1->name,
140 method_name => $method_name
141 );
142 }
143 else {
144 # if we are a role, we need to make sure
145 # we don't have a conflict with the role
146 # we are composing into
1473643µs36126µs if ($role2->has_override_method_modifier($method_name) &&
# spent 126µs making 36 calls to Moose::Meta::Role::has_override_method_modifier, avg 4µs/call
148 $role1->get_override_method_modifier($method_name) != $role2->get_override_method_modifier($method_name)) {
149
150 throw_exception( OverrideConflictInComposition => role_name => $role2->name,
151 role_being_applied_name => $role1->name,
152 method_name => $method_name,
153 two_overrides_found => 1
154 );
155 }
156 else {
157 # if there is no conflict,
158 # just add it to the role
1593668µs72758µs $role2->add_override_method_modifier(
# spent 648µs making 36 calls to Moose::Meta::Role::add_override_method_modifier, avg 18µs/call # spent 109µs making 36 calls to Moose::Meta::Role::get_override_method_modifier, avg 3µs/call
160 $method_name,
161 $role1->get_override_method_modifier($method_name)
162 );
163 }
164 }
165 }
166}
167
168
# spent 1.01ms (329µs+683µs) within Moose::Meta::Role::Application::ToRole::apply_method_modifiers which was called 42 times, avg 24µs/call: # 14 times (182µs+456µs) by Moose::Meta::Role::Application::apply_around_method_modifiers at line 79 of Moose/Meta/Role/Application.pm, avg 46µs/call # 14 times (106µs+139µs) by Moose::Meta::Role::Application::apply_before_method_modifiers at line 78 of Moose/Meta/Role/Application.pm, avg 18µs/call # 14 times (42µs+88µs) by Moose::Meta::Role::Application::apply_after_method_modifiers at line 80 of Moose/Meta/Role/Application.pm, avg 9µs/call
sub apply_method_modifiers {
1694218µs my ($self, $modifier_type, $role1, $role2) = @_;
1704219µs my $add = "add_${modifier_type}_method_modifier";
1714213µs my $get = "get_${modifier_type}_method_modifiers";
17242116µs42234µs foreach my $method_name ($role1->get_method_modifier_list($modifier_type)) {
# spent 234µs making 42 calls to Moose::Meta::Role::get_method_modifier_list, avg 6µs/call
173 $role2->$add(
174 $method_name,
175 $_
17632115µs64449µs ) foreach $role1->$get($method_name);
# spent 272µs making 28 calls to Moose::Meta::Role::add_around_method_modifier, avg 10µs/call # spent 112µs making 28 calls to Moose::Meta::Role::get_around_method_modifiers, avg 4µs/call # spent 42µs making 4 calls to Moose::Meta::Role::add_before_method_modifier, avg 10µs/call # spent 23µs making 4 calls to Moose::Meta::Role::get_before_method_modifiers, avg 6µs/call
177 }
178}
179
18012µs1;
181
182# ABSTRACT: Compose a role into another role
183
184__END__