Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Role/Composite.pm |
Statements | Executed 193 statements in 1.36ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
10 | 1 | 1 | 160µs | 222µs | add_attribute | Mouse::Meta::Role::Composite::
3 | 1 | 1 | 130µs | 5.27ms | new | Mouse::Meta::Role::Composite::
5 | 2 | 2 | 91µs | 125µs | add_method | Mouse::Meta::Role::Composite::
3 | 1 | 1 | 58µs | 217µs | apply_methods | Mouse::Meta::Role::Application::RoleSummation::
3 | 1 | 1 | 57µs | 5.53ms | apply | Mouse::Meta::Role::Composite::
12 | 2 | 2 | 31µs | 31µs | has_method | Mouse::Meta::Role::Composite::
1 | 1 | 1 | 28µs | 68µs | BEGIN@2 | Mouse::Meta::Role::Composite::
10 | 1 | 1 | 27µs | 27µs | has_attribute | Mouse::Meta::Role::Composite::
3 | 1 | 1 | 16µs | 16µs | get_method_list | Mouse::Meta::Role::Composite::
1 | 1 | 1 | 12µs | 12µs | BEGIN@4 | Mouse::Meta::Role::Composite::
2 | 1 | 1 | 10µs | 10µs | get_method_body | Mouse::Meta::Role::Composite::
1 | 1 | 1 | 9µs | 9µs | BEGIN@3 | Mouse::Meta::Role::Composite::
0 | 0 | 0 | 0s | 0s | add_override_method_modifier | Mouse::Meta::Role::Composite::
0 | 0 | 0 | 0s | 0s | has_override_method_modifier | Mouse::Meta::Role::Composite::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Mouse::Meta::Role::Composite; | ||||
2 | 2 | 32µs | 2 | 108µs | # spent 68µs (28+40) within Mouse::Meta::Role::Composite::BEGIN@2 which was called:
# once (28µs+40µs) by Mouse::Meta::Role::combine at line 2 # spent 68µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@2
# spent 40µs making 1 call to Mouse::Exporter::do_import |
3 | 2 | 26µs | 1 | 9µs | # spent 9µs within Mouse::Meta::Role::Composite::BEGIN@3 which was called:
# once (9µs+0s) by Mouse::Meta::Role::combine at line 3 # spent 9µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@3 |
4 | 2 | 641µs | 1 | 12µs | # spent 12µs within Mouse::Meta::Role::Composite::BEGIN@4 which was called:
# once (12µs+0s) by Mouse::Meta::Role::combine at line 4 # spent 12µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@4 |
5 | 1 | 7µs | our @ISA = qw(Mouse::Meta::Role); | ||
6 | |||||
7 | # FIXME: Mouse::Meta::Role::Composite does things in different way from Moose's | ||||
8 | # Moose: creates a new class for the consumer, and applies roles to it. | ||||
9 | # Mouse: creates a coposite role and apply roles to the role, | ||||
10 | # and then applies it to the consumer. | ||||
11 | |||||
12 | # spent 5.27ms (130µs+5.14) within Mouse::Meta::Role::Composite::new which was called 3 times, avg 1.76ms/call:
# 3 times (130µs+5.14ms) by Mouse::Meta::Role::combine at line 78 of Mouse/Meta/Role.pm, avg 1.76ms/call | ||||
13 | 30 | 134µs | my $class = shift; | ||
14 | 3 | 8µs | my $args = $class->Mouse::Object::BUILDARGS(@_); # spent 8µs making 3 calls to Mouse::Object::BUILDARGS, avg 2µs/call | ||
15 | my $roles = delete $args->{roles}; | ||||
16 | 3 | 626µs | my $self = $class->create_anon_role(%{$args}); # spent 626µs making 3 calls to Mouse::Meta::Role::create_anon_role, avg 209µs/call | ||
17 | foreach my $role_spec(@{$roles}) { | ||||
18 | my($role, $args) = ref($role_spec) eq 'ARRAY' | ||||
19 | ? @{$role_spec} | ||||
20 | : ($role_spec, {}); | ||||
21 | 6 | 4.50ms | $role->apply($self, %{$args}); # spent 4.50ms making 6 calls to Mouse::Meta::Role::apply, avg 750µs/call | ||
22 | } | ||||
23 | return $self; | ||||
24 | } | ||||
25 | |||||
26 | # spent 16µs within Mouse::Meta::Role::Composite::get_method_list which was called 3 times, avg 5µs/call:
# 3 times (16µs+0s) by Mouse::Meta::Role::Application::apply_methods at line 121 of Mouse/Meta/Role/Application.pm, avg 5µs/call | ||||
27 | 6 | 22µs | my($self) = @_; | ||
28 | return keys %{ $self->{methods} }; | ||||
29 | } | ||||
30 | |||||
31 | # spent 125µs (91+33) within Mouse::Meta::Role::Composite::add_method which was called 5 times, avg 25µs/call:
# 3 times (61µs+33µs) by Mouse::Meta::Module::create at line 236 of Mouse/Meta/Module.pm, avg 32µs/call
# 2 times (30µs+0s) by Mouse::Meta::Role::Application::apply_methods at line 126 of Mouse/Meta/Role/Application.pm, avg 15µs/call | ||||
32 | 28 | 130µs | my($self, $method_name, $code, $role) = @_; | ||
33 | |||||
34 | if( ($self->{methods}{$method_name} || 0) == $code){ | ||||
35 | # This role already has the same method. | ||||
36 | return; | ||||
37 | } | ||||
38 | |||||
39 | 3 | 34µs | if($method_name eq 'meta'){ # spent 34µs making 3 calls to Mouse::Meta::Module::add_method, avg 11µs/call | ||
40 | $self->SUPER::add_method($method_name => $code); | ||||
41 | } | ||||
42 | else{ | ||||
43 | # no need to add a subroutine to the stash | ||||
44 | my $roles = $self->{composed_roles_by_method}{$method_name} ||= []; | ||||
45 | push @{$roles}, $role; | ||||
46 | if(@{$roles} > 1){ | ||||
47 | $self->{conflicting_methods}{$method_name}++; | ||||
48 | } | ||||
49 | $self->{methods}{$method_name} = $code; | ||||
50 | } | ||||
51 | return; | ||||
52 | } | ||||
53 | |||||
54 | # spent 10µs within Mouse::Meta::Role::Composite::get_method_body which was called 2 times, avg 5µs/call:
# 2 times (10µs+0s) by Mouse::Meta::Role::Application::apply_methods at line 124 of Mouse/Meta/Role/Application.pm, avg 5µs/call | ||||
55 | 4 | 13µs | my($self, $method_name) = @_; | ||
56 | return $self->{methods}{$method_name}; | ||||
57 | } | ||||
58 | |||||
59 | # spent 31µs within Mouse::Meta::Role::Composite::has_method which was called 12 times, avg 3µs/call:
# 10 times (26µs+0s) by Mouse::Meta::Role::add_required_methods at line 49 of Mouse/Meta/Role.pm, avg 3µs/call
# 2 times (5µs+0s) by Mouse::Meta::Role::Application::apply_methods at line 126 of Mouse/Meta/Role/Application.pm, avg 2µs/call | ||||
60 | # my($self, $method_name) = @_; | ||||
61 | 12 | 49µs | return 0; # to fool apply_methods() in combine() | ||
62 | } | ||||
63 | |||||
64 | # spent 27µs within Mouse::Meta::Role::Composite::has_attribute which was called 10 times, avg 3µs/call:
# 10 times (27µs+0s) by Mouse::Meta::Role::Application::apply_attributes at line 154 of Mouse/Meta/Role/Application.pm, avg 3µs/call | ||||
65 | # my($self, $method_name) = @_; | ||||
66 | 10 | 38µs | return 0; # to fool appply_attributes() in combine() | ||
67 | } | ||||
68 | |||||
69 | sub has_override_method_modifier { | ||||
70 | # my($self, $method_name) = @_; | ||||
71 | return 0; # to fool apply_modifiers() in combine() | ||||
72 | } | ||||
73 | |||||
74 | # spent 222µs (160+62) within Mouse::Meta::Role::Composite::add_attribute which was called 10 times, avg 22µs/call:
# 10 times (160µs+62µs) by Mouse::Meta::Role::Application::apply_attributes at line 156 of Mouse/Meta/Role/Application.pm, avg 22µs/call | ||||
75 | 70 | 155µs | my $self = shift; | ||
76 | my $attr_name = shift; | ||||
77 | my $spec = (@_ == 1 ? $_[0] : {@_}); | ||||
78 | |||||
79 | my $existing = $self->{attributes}{$attr_name}; | ||||
80 | if($existing && $existing != $spec){ | ||||
81 | $self->throw_error("We have encountered an attribute conflict with '$attr_name' " | ||||
82 | . "during composition. This is fatal error and cannot be disambiguated."); | ||||
83 | } | ||||
84 | 10 | 62µs | $self->SUPER::add_attribute($attr_name, $spec); # spent 62µs making 10 calls to Mouse::Meta::Role::add_attribute, avg 6µs/call | ||
85 | return; | ||||
86 | } | ||||
87 | |||||
88 | sub add_override_method_modifier { | ||||
89 | my($self, $method_name, $code) = @_; | ||||
90 | |||||
91 | my $existing = $self->{override_method_modifiers}{$method_name}; | ||||
92 | if($existing && $existing != $code){ | ||||
93 | $self->throw_error( "We have encountered an 'override' method conflict with '$method_name' during " | ||||
94 | . "composition (Two 'override' methods of the same name encountered). " | ||||
95 | . "This is fatal error.") | ||||
96 | } | ||||
97 | $self->SUPER::add_override_method_modifier($method_name, $code); | ||||
98 | return; | ||||
99 | } | ||||
100 | |||||
101 | # spent 5.53ms (57µs+5.47) within Mouse::Meta::Role::Composite::apply which was called 3 times, avg 1.84ms/call:
# 3 times (57µs+5.47ms) by Mouse::Util::apply_all_roles at line 310 of Mouse/Util.pm, avg 1.84ms/call | ||||
102 | 12 | 52µs | my $self = shift; | ||
103 | my $consumer = shift; | ||||
104 | |||||
105 | 6 | 5.47ms | Mouse::Meta::Role::Application::RoleSummation->new(@_)->apply($self, $consumer); # spent 5.23ms making 3 calls to Mouse::Meta::Role::Application::apply, avg 1.74ms/call
# spent 236µs making 3 calls to Mouse::Meta::Role::Application::new, avg 79µs/call | ||
106 | return; | ||||
107 | } | ||||
108 | |||||
109 | package Mouse::Meta::Role::Application::RoleSummation; | ||||
110 | 1 | 4µs | our @ISA = qw(Mouse::Meta::Role::Application); | ||
111 | |||||
112 | # spent 217µs (58+159) within Mouse::Meta::Role::Application::RoleSummation::apply_methods which was called 3 times, avg 72µs/call:
# 3 times (58µs+159µs) by Mouse::Meta::Role::Application::apply at line 68 of Mouse/Meta/Role/Application.pm, avg 72µs/call | ||||
113 | 12 | 56µs | my($self, $role, $consumer, @extra) = @_; | ||
114 | |||||
115 | if(exists $role->{conflicting_methods}){ | ||||
116 | my $consumer_class_name = $consumer->name; | ||||
117 | |||||
118 | my @conflicting = grep{ !$consumer_class_name->can($_) } | ||||
119 | keys %{ $role->{conflicting_methods} }; | ||||
120 | |||||
121 | if(@conflicting) { | ||||
122 | my $method_name_conflict = (@conflicting == 1 | ||||
123 | ? 'a method name conflict' | ||||
124 | : 'method name conflicts'); | ||||
125 | |||||
126 | my %seen; | ||||
127 | my $roles = Mouse::Util::quoted_english_list( | ||||
128 | grep{ !$seen{$_}++ } # uniq | ||||
129 | map { $_->name } | ||||
130 | map { @{$_} } | ||||
131 | @{ $role->{composed_roles_by_method} }{@conflicting} | ||||
132 | ); | ||||
133 | |||||
134 | $self->throw_error(sprintf | ||||
135 | q{Due to %s in roles %s,} | ||||
136 | . q{ the method%s %s must be implemented or excluded by '%s'}, | ||||
137 | $method_name_conflict, | ||||
138 | $roles, | ||||
139 | (@conflicting > 1 ? 's' : ''), | ||||
140 | Mouse::Util::quoted_english_list(@conflicting), | ||||
141 | $consumer_class_name); | ||||
142 | } | ||||
143 | } | ||||
144 | |||||
145 | 3 | 159µs | $self->SUPER::apply_methods($role, $consumer, @extra); # spent 159µs making 3 calls to Mouse::Meta::Role::Application::apply_methods, avg 53µs/call | ||
146 | return; | ||||
147 | } | ||||
148 | |||||
149 | package Mouse::Meta::Role::Composite; | ||||
150 | 1 | 4µs | 1; | ||
151 | __END__ |