← Index
NYTProf Performance Profile   « block view • line view • sub view »
For reply.pl
  Run on Thu Oct 21 22:40:13 2010
Reported on Thu Oct 21 22:44:38 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.47ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.09ms1.20msMouse::Meta::Role::Composite::::BEGIN@4 Mouse::Meta::Role::Composite::BEGIN@4
1011163µs226µsMouse::Meta::Role::Composite::::add_attribute Mouse::Meta::Role::Composite::add_attribute
311140µs5.63msMouse::Meta::Role::Composite::::new Mouse::Meta::Role::Composite::new
52290µs126µsMouse::Meta::Role::Composite::::add_method Mouse::Meta::Role::Composite::add_method
31157µs226µsMouse::Meta::Role::Application::RoleSummation::::apply_methodsMouse::Meta::Role::Application::RoleSummation::apply_methods
31152µs5.59msMouse::Meta::Role::Composite::::apply Mouse::Meta::Role::Composite::apply
11131µs85µsMouse::Meta::Role::Composite::::BEGIN@2 Mouse::Meta::Role::Composite::BEGIN@2
122231µs31µsMouse::Meta::Role::Composite::::has_method Mouse::Meta::Role::Composite::has_method
101128µs28µ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
21110µs10µsMouse::Meta::Role::Composite::::get_method_body Mouse::Meta::Role::Composite::get_method_body
1118µs8µ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;
2233µs2140µ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
use Mouse::Util; # enables strict and warnings
# spent 85µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@2 # spent 54µs making 1 call to Mouse::Exporter::do_import
3226µs18µ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
use Mouse::Meta::Role;
# spent 8µs making 1 call to Mouse::Meta::Role::Composite::BEGIN@3
42738µs11.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
use Mouse::Meta::Role::Application;
# spent 1.20ms 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.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
sub new {
1330142µs my $class = shift;
1438µs my $args = $class->Mouse::Object::BUILDARGS(@_);
# spent 8µs making 3 calls to Mouse::Object::BUILDARGS, avg 3µs/call
15 my $roles = delete $args->{roles};
163658µ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 foreach my $role_spec(@{$roles}) {
18 my($role, $args) = ref($role_spec) eq 'ARRAY'
19 ? @{$role_spec}
20 : ($role_spec, {});
2164.82ms $role->apply($self, %{$args});
# spent 4.82ms making 6 calls to Mouse::Meta::Role::apply, avg 803µ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 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
sub add_method {
3228130µ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
39336µ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 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 {
55416µ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 (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
sub has_method {
60 # my($self, $method_name) = @_;
611245µ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
sub has_attribute {
65 # my($self, $method_name) = @_;
661041µ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 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
sub add_attribute {
7570157µ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 }
841063µ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 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.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
sub apply {
1021247µs my $self = shift;
103 my $consumer = shift;
104
10565.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 return;
107}
108
109package Mouse::Meta::Role::Application::RoleSummation;
11014µsour @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
sub apply_methods {
1131258µ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
1453170µ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 return;
147}
148
149package Mouse::Meta::Role::Composite;
15014µs1;
151__END__