← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/hailo
  Run on Thu Oct 21 22:50:37 2010
Reported on Thu Oct 21 22:52:10 2010

Filename/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Role/Composite.pm
StatementsExecuted 193 statements in 1.36ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1011160µs222µsMouse::Meta::Role::Composite::::add_attribute Mouse::Meta::Role::Composite::add_attribute
311130µs5.27msMouse::Meta::Role::Composite::::new Mouse::Meta::Role::Composite::new
52291µs125µsMouse::Meta::Role::Composite::::add_method Mouse::Meta::Role::Composite::add_method
31158µs217µsMouse::Meta::Role::Application::RoleSummation::::apply_methodsMouse::Meta::Role::Application::RoleSummation::apply_methods
31157µs5.53msMouse::Meta::Role::Composite::::apply Mouse::Meta::Role::Composite::apply
122231µs31µsMouse::Meta::Role::Composite::::has_method Mouse::Meta::Role::Composite::has_method
11128µs68µsMouse::Meta::Role::Composite::::BEGIN@2 Mouse::Meta::Role::Composite::BEGIN@2
101127µs27µsMouse::Meta::Role::Composite::::has_attribute Mouse::Meta::Role::Composite::has_attribute
31116µs16µsMouse::Meta::Role::Composite::::get_method_list Mouse::Meta::Role::Composite::get_method_list
11112µs12µsMouse::Meta::Role::Composite::::BEGIN@4 Mouse::Meta::Role::Composite::BEGIN@4
21110µs10µsMouse::Meta::Role::Composite::::get_method_body Mouse::Meta::Role::Composite::get_method_body
1119µs9µsMouse::Meta::Role::Composite::::BEGIN@3 Mouse::Meta::Role::Composite::BEGIN@3
0000s0sMouse::Meta::Role::Composite::::add_override_method_modifier Mouse::Meta::Role::Composite::add_override_method_modifier
0000s0sMouse::Meta::Role::Composite::::has_override_method_modifier Mouse::Meta::Role::Composite::has_override_method_modifier
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Mouse::Meta::Role::Composite;
2232µs2108µ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
use Mouse::Util; # enables strict and warnings
# spent 68µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@2 # spent 40µs making 1 call to Mouse::Exporter::do_import
3226µs19µ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
use Mouse::Meta::Role;
# spent 9µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@3
42641µs112µ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
use Mouse::Meta::Role::Application;
# spent 12µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@4
517µsour @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
sub new {
131880µs my $class = shift;
1438µ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};
163626µ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'
191254µs ? @{$role_spec}
20 : ($role_spec, {});
2164.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
sub get_method_list {
27622µ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
sub add_method {
3220117µ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
39813µs334µ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
sub get_method_body {
55413µ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
sub has_method {
60 # my($self, $method_name) = @_;
611249µ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
sub has_attribute {
65 # my($self, $method_name) = @_;
661038µs return 0; # to fool appply_attributes() in combine()
67}
68
69sub 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
sub add_attribute {
7570155µ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 }
841062µ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
88sub 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
sub apply {
1021252µs my $self = shift;
103 my $consumer = shift;
104
10565.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
109package Mouse::Meta::Role::Application::RoleSummation;
11014µsour @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
sub apply_methods {
1131256µ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
1453159µ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
149package Mouse::Meta::Role::Composite;
15014µs1;
151__END__