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.47ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 1.09ms | 1.20ms | BEGIN@4 | Mouse::Meta::Role::Composite::
10 | 1 | 1 | 163µs | 226µs | add_attribute | Mouse::Meta::Role::Composite::
3 | 1 | 1 | 140µs | 5.63ms | new | Mouse::Meta::Role::Composite::
5 | 2 | 2 | 90µs | 126µs | add_method | Mouse::Meta::Role::Composite::
3 | 1 | 1 | 57µs | 226µs | apply_methods | Mouse::Meta::Role::Application::RoleSummation::
3 | 1 | 1 | 52µs | 5.59ms | apply | Mouse::Meta::Role::Composite::
1 | 1 | 1 | 31µs | 85µs | BEGIN@2 | Mouse::Meta::Role::Composite::
12 | 2 | 2 | 31µs | 31µs | has_method | Mouse::Meta::Role::Composite::
10 | 1 | 1 | 28µs | 28µs | has_attribute | Mouse::Meta::Role::Composite::
3 | 1 | 1 | 16µs | 16µs | get_method_list | Mouse::Meta::Role::Composite::
2 | 1 | 1 | 10µs | 10µs | get_method_body | Mouse::Meta::Role::Composite::
1 | 1 | 1 | 8µs | 8µ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 | 33µs | 2 | 140µs | # spent 85µs (31+55) within Mouse::Meta::Role::Composite::BEGIN@2 which was called:
# once (31µs+55µs) by Mouse::Meta::Role::combine at line 2 # spent 85µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@2
# spent 54µs making 1 call to Mouse::Exporter::do_import |
3 | 2 | 26µs | 1 | 8µs | # spent 8µs within Mouse::Meta::Role::Composite::BEGIN@3 which was called:
# once (8µs+0s) by Mouse::Meta::Role::combine at line 3 # spent 8µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@3 |
4 | 2 | 738µs | 1 | 1.20ms | # spent 1.20ms (1.09+112µs) within Mouse::Meta::Role::Composite::BEGIN@4 which was called:
# once (1.09ms+112µs) by Mouse::Meta::Role::combine at line 4 # spent 1.20ms 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.63ms (140µs+5.49) within Mouse::Meta::Role::Composite::new which was called 3 times, avg 1.88ms/call:
# 3 times (140µs+5.49ms) by Mouse::Meta::Role::combine at line 78 of Mouse/Meta/Role.pm, avg 1.88ms/call | ||||
13 | 3 | 5µs | my $class = shift; | ||
14 | 3 | 32µs | 3 | 8µs | my $args = $class->Mouse::Object::BUILDARGS(@_); # spent 8µs making 3 calls to Mouse::Object::BUILDARGS, avg 3µs/call |
15 | 3 | 6µs | my $roles = delete $args->{roles}; | ||
16 | 3 | 26µs | 3 | 658µs | my $self = $class->create_anon_role(%{$args}); # spent 658µs making 3 calls to Mouse::Meta::Role::create_anon_role, avg 219µs/call |
17 | 3 | 9µs | foreach my $role_spec(@{$roles}) { | ||
18 | my($role, $args) = ref($role_spec) eq 'ARRAY' | ||||
19 | 6 | 11µs | ? @{$role_spec} | ||
20 | : ($role_spec, {}); | ||||
21 | 6 | 42µs | 6 | 4.82ms | $role->apply($self, %{$args}); # spent 4.82ms making 6 calls to Mouse::Meta::Role::apply, avg 803µs/call |
22 | } | ||||
23 | 3 | 11µs | 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 | 3 | 4µs | my($self) = @_; | ||
28 | 3 | 18µs | return keys %{ $self->{methods} }; | ||
29 | } | ||||
30 | |||||
31 | # spent 126µs (90+36) within Mouse::Meta::Role::Composite::add_method which was called 5 times, avg 25µs/call:
# 3 times (61µs+36µs) by Mouse::Meta::Module::create at line 236 of Mouse/Meta/Module.pm, avg 32µs/call
# 2 times (29µs+0s) by Mouse::Meta::Role::Application::apply_methods at line 126 of Mouse/Meta/Role/Application.pm, avg 15µs/call | ||||
32 | 5 | 10µs | my($self, $method_name, $code, $role) = @_; | ||
33 | |||||
34 | 5 | 10µs | if( ($self->{methods}{$method_name} || 0) == $code){ | ||
35 | # This role already has the same method. | ||||
36 | return; | ||||
37 | } | ||||
38 | |||||
39 | 5 | 77µs | 3 | 36µs | if($method_name eq 'meta'){ # spent 36µs making 3 calls to Mouse::Meta::Module::add_method, avg 12µs/call |
40 | $self->SUPER::add_method($method_name => $code); | ||||
41 | } | ||||
42 | else{ | ||||
43 | # no need to add a subroutine to the stash | ||||
44 | 2 | 5µs | my $roles = $self->{composed_roles_by_method}{$method_name} ||= []; | ||
45 | 2 | 3µs | push @{$roles}, $role; | ||
46 | 2 | 3µs | if(@{$roles} > 1){ | ||
47 | $self->{conflicting_methods}{$method_name}++; | ||||
48 | } | ||||
49 | 2 | 3µs | $self->{methods}{$method_name} = $code; | ||
50 | } | ||||
51 | 5 | 20µs | 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 | 2 | 3µs | my($self, $method_name) = @_; | ||
56 | 2 | 13µs | 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 (25µ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 3µs/call | ||||
60 | # my($self, $method_name) = @_; | ||||
61 | 12 | 45µs | return 0; # to fool apply_methods() in combine() | ||
62 | } | ||||
63 | |||||
64 | # spent 28µs within Mouse::Meta::Role::Composite::has_attribute which was called 10 times, avg 3µs/call:
# 10 times (28µ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 | 41µ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 226µs (163+63) within Mouse::Meta::Role::Composite::add_attribute which was called 10 times, avg 23µs/call:
# 10 times (163µs+63µs) by Mouse::Meta::Role::Application::apply_attributes at line 156 of Mouse/Meta/Role/Application.pm, avg 23µs/call | ||||
75 | 10 | 12µs | my $self = shift; | ||
76 | 10 | 12µs | my $attr_name = shift; | ||
77 | 10 | 14µs | my $spec = (@_ == 1 ? $_[0] : {@_}); | ||
78 | |||||
79 | 10 | 13µs | my $existing = $self->{attributes}{$attr_name}; | ||
80 | 10 | 11µs | 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 | 60µs | 10 | 63µs | $self->SUPER::add_attribute($attr_name, $spec); # spent 63µs making 10 calls to Mouse::Meta::Role::add_attribute, avg 6µs/call |
85 | 10 | 35µs | 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.59ms (52µs+5.54) within Mouse::Meta::Role::Composite::apply which was called 3 times, avg 1.86ms/call:
# 3 times (52µs+5.54ms) by Mouse::Util::apply_all_roles at line 310 of Mouse/Util.pm, avg 1.86ms/call | ||||
102 | 3 | 4µs | my $self = shift; | ||
103 | 3 | 3µs | my $consumer = shift; | ||
104 | |||||
105 | 3 | 29µs | 6 | 5.54ms | Mouse::Meta::Role::Application::RoleSummation->new(@_)->apply($self, $consumer); # spent 5.31ms making 3 calls to Mouse::Meta::Role::Application::apply, avg 1.77ms/call
# spent 224µs making 3 calls to Mouse::Meta::Role::Application::new, avg 75µs/call |
106 | 3 | 10µs | return; | ||
107 | } | ||||
108 | |||||
109 | package Mouse::Meta::Role::Application::RoleSummation; | ||||
110 | 1 | 4µs | our @ISA = qw(Mouse::Meta::Role::Application); | ||
111 | |||||
112 | # spent 226µs (57+170) within Mouse::Meta::Role::Application::RoleSummation::apply_methods which was called 3 times, avg 75µs/call:
# 3 times (57µs+170µs) by Mouse::Meta::Role::Application::apply at line 68 of Mouse/Meta/Role/Application.pm, avg 75µs/call | ||||
113 | 3 | 6µs | my($self, $role, $consumer, @extra) = @_; | ||
114 | |||||
115 | 3 | 4µs | 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 | 32µs | 3 | 170µs | $self->SUPER::apply_methods($role, $consumer, @extra); # spent 170µs making 3 calls to Mouse::Meta::Role::Application::apply_methods, avg 57µs/call |
146 | 3 | 16µs | return; | ||
147 | } | ||||
148 | |||||
149 | package Mouse::Meta::Role::Composite; | ||||
150 | 1 | 4µs | 1; | ||
151 | __END__ |