← 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:43 2010

Filename/home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Role/Application.pm
StatementsExecuted 494 statements in 2.78ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
911396µs4.57msMouse::Meta::Role::Application::::apply_attributesMouse::Meta::Role::Application::apply_attributes
922342µs9.91msMouse::Meta::Role::Application::::applyMouse::Meta::Role::Application::apply
922254µs3.29msMouse::Meta::Role::Application::::apply_methodsMouse::Meta::Role::Application::apply_methods
911235µs436µsMouse::Meta::Role::Application::::check_required_methodsMouse::Meta::Role::Application::check_required_methods
922211µs360µsMouse::Meta::Role::Application::::newMouse::Meta::Role::Application::new
911192µs1.03msMouse::Meta::Role::Application::::_append_rolesMouse::Meta::Role::Application::_append_roles
911141µs141µsMouse::Meta::Role::Application::::apply_modifiersMouse::Meta::Role::Application::apply_modifiers
11126µs112µsMouse::Meta::Role::Application::::BEGIN@2Mouse::Meta::Role::Application::BEGIN@2
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::Application;
22973µs2198µs
# spent 112µs (26+86) within Mouse::Meta::Role::Application::BEGIN@2 which was called: # once (26µs+86µs) by Mouse::Meta::Role::Composite::BEGIN@4 at line 2
use Mouse::Util qw(:meta);
# spent 112µs making 1 call to Mouse::Meta::Role::Application::BEGIN@2 # spent 86µs making 1 call to Mouse::Exporter::do_import
3
4
# spent 360µs (211+149) within Mouse::Meta::Role::Application::new which was called 9 times, avg 40µs/call: # 6 times (127µs+9µs) by Mouse::Meta::Role::apply at line 71 of Mouse/Meta/Role.pm, avg 23µs/call # 3 times (84µs+140µs) by Mouse::Meta::Role::Composite::apply at line 105 of Mouse/Meta/Role/Composite.pm, avg 75µs/call
sub new {
5912µs my $class = shift;
6959µs914µs my $args = $class->Mouse::Object::BUILDARGS(@_);
# spent 14µs making 9 calls to Mouse::Object::BUILDARGS, avg 2µs/call
7
8919µs if(exists $args->{exclude} or exists $args->{alias}) {
9 warnings::warnif(deprecated =>
10 'The alias and excludes options for role application have been'
11 . ' renamed -alias and -exclude');
12
13 if($args->{alias} && !exists $args->{-alias}){
14 $args->{-alias} = $args->{alias};
15 }
16 if($args->{excludes} && !exists $args->{-excludes}){
17 $args->{-excludes} = $args->{excludes};
18 }
19 }
20
21916µs $args->{aliased_methods} = {};
22915µs if(my $alias = $args->{-alias}){
23 @{$args->{aliased_methods}}{ values %{$alias} } = ();
24 }
25
26912µs if(my $excludes = $args->{-excludes}){
27 $args->{-excludes} = {}; # replace with a hash ref
28 if(ref $excludes){
29 %{$args->{-excludes}} = (map{ $_ => undef } @{$excludes});
30 }
31 else{
32 $args->{-excludes}{$excludes} = undef;
33 }
34 }
35934µs my $self = bless $args, $class;
36965µs10182µs if($class ne __PACKAGE__){
# spent 77µs making 3 calls to Mouse::Meta::Class::_initialize_object, avg 26µs/call # spent 59µs making 3 calls to Mouse::Util::meta, avg 20µs/call # spent 40µs making 1 call to Mouse::Meta::Class::_calculate_all_attributes # spent 3µs making 1 call to Mouse::Meta::Class::strict_constructor # spent 2µs making 1 call to Mouse::Meta::Class::is_immutable # spent 2µs making 1 call to Mouse::Meta::Class::is_anon_class
37 $self->meta->_initialize_object($self, $args);
38 }
39936µs return $self;
40}
41
42
# spent 9.91ms (342µs+9.57) within Mouse::Meta::Role::Application::apply which was called 9 times, avg 1.10ms/call: # 6 times (226µs+4.37ms) by Mouse::Meta::Role::apply at line 71 of Mouse/Meta/Role.pm, avg 766µs/call # 3 times (117µs+5.20ms) by Mouse::Meta::Role::Composite::apply at line 105 of Mouse/Meta/Role/Composite.pm, avg 1.77ms/call
sub apply {
43914µs my($self, $role, $consumer, @extra) = @_;
4499µs my $instance;
45
46995µs1539µs if(Mouse::Util::is_a_metaclass($consumer)) { # Application::ToClass
# spent 30µs making 9 calls to Mouse::Util::is_a_metaclass, avg 3µs/call # spent 9µs making 6 calls to Mouse::Util::is_a_metarole, avg 2µs/call
47 $self->{_to} = 'class';
48 }
49 elsif(Mouse::Util::is_a_metarole($consumer)) { # Application::ToRole
50 $self->{_to} = 'role';
51 }
52 else { # Appplication::ToInstance
53 $self->{_to} = 'instance';
54 $instance = $consumer;
55
56 $consumer = (Mouse::Util::class_of($instance) || 'Mouse::Meta::Class')
57 ->create_anon_class(
58 superclasses => [ref $instance],
59 cache => 1,
60 );
61 }
62
63 #$self->check_role_exclusions($role, $consumer, @extra);
64935µs9436µs $self->check_required_methods($role, $consumer, @extra);
# spent 436µs making 9 calls to Mouse::Meta::Role::Application::check_required_methods, avg 48µs/call
65 #$self->check_required_attributes($role, $consumer, @extra);
66
67940µs94.57ms $self->apply_attributes($role, $consumer, @extra);
# spent 4.57ms making 9 calls to Mouse::Meta::Role::Application::apply_attributes, avg 508µs/call
68936µs93.35ms $self->apply_methods($role, $consumer, @extra);
# spent 3.12ms making 6 calls to Mouse::Meta::Role::Application::apply_methods, avg 521µs/call # spent 226µs making 3 calls to Mouse::Meta::Role::Application::RoleSummation::apply_methods, avg 75µs/call
69 #$self->apply_override_method_modifiers($role, $consumer, @extra);
70 #$self->apply_before_method_modifiers($role, $consumer, @extra);
71 #$self->apply_around_method_modifiers($role, $consumer, @extra);
72 #$self->apply_after_method_modifiers($role, $consumer, @extra);
73939µs9141µs $self->apply_modifiers($role, $consumer, @extra);
# spent 141µs making 9 calls to Mouse::Meta::Role::Application::apply_modifiers, avg 16µs/call
74
75935µs91.03ms $self->_append_roles($role, $consumer);
# spent 1.03ms making 9 calls to Mouse::Meta::Role::Application::_append_roles, avg 114µs/call
76
7799µs if(defined $instance){ # Application::ToInstance
78 # rebless instance
79 bless $instance, $consumer->name;
80 $consumer->_initialize_object($instance, $instance, 1);
81 }
82
83932µs return;
84}
85
86
# spent 436µs (235+201) within Mouse::Meta::Role::Application::check_required_methods which was called 9 times, avg 48µs/call: # 9 times (235µs+201µs) by Mouse::Meta::Role::Application::apply at line 64, avg 48µs/call
sub check_required_methods {
87912µs my($self, $role, $consumer) = @_;
88
89951µs12161µs if($self->{_to} eq 'role'){
# spent 139µs making 6 calls to Mouse::Meta::Role::add_required_methods, avg 23µs/call # spent 22µs making 6 calls to Mouse::Meta::Role::get_required_method_list, avg 4µs/call
90 $consumer->add_required_methods($role->get_required_method_list);
91 }
92 else{ # to class or instance
93325µs35µs my $consumer_class_name = $consumer->name;
# spent 5µs making 3 calls to Mouse::Meta::Module::name, avg 2µs/call
94
9533µs my @missing;
96321µs foreach my $method_name(@{$role->{required_methods}}){
971013µs next if exists $self->{aliased_methods}{$method_name};
981013µs next if exists $role->{methods}{$method_name};
991096µs1036µs next if $consumer_class_name->can($method_name);
# spent 36µs making 10 calls to UNIVERSAL::can, avg 4µs/call
100
101 push @missing, $method_name;
102 }
10334µs if(@missing){
104 $role->throw_error(sprintf "'%s' requires the method%s %s to be implemented by '%s'",
105 $role->name,
106 (@missing == 1 ? '' : 's'), # method or methods
107 Mouse::Util::quoted_english_list(@missing),
108 $consumer_class_name);
109 }
110 }
111
112930µs return;
113}
114
115
# spent 3.29ms (254µs+3.04) within Mouse::Meta::Role::Application::apply_methods which was called 9 times, avg 366µs/call: # 6 times (166µs+2.96ms) by Mouse::Meta::Role::Application::apply at line 68, avg 521µs/call # 3 times (88µs+82µs) by Mouse::Meta::Role::Application::RoleSummation::apply_methods at line 145 of Mouse/Meta/Role/Composite.pm, avg 57µs/call
sub apply_methods {
116914µs my($self, $role, $consumer) = @_;
117
118914µs my $alias = $self->{-alias};
119911µs my $excludes = $self->{-excludes};
120
121974µs92.89ms foreach my $method_name($role->get_method_list){
# spent 2.87ms making 6 calls to Mouse::Meta::Module::get_method_list, avg 479µs/call # spent 16µs making 3 calls to Mouse::Meta::Role::Composite::get_method_list, avg 5µs/call
1221316µs next if $method_name eq 'meta';
123
124429µs461µs my $code = $role->get_method_body($method_name);
# spent 51µs making 2 calls to Mouse::Meta::Module::get_method_body, avg 25µs/call # spent 10µs making 2 calls to Mouse::Meta::Role::Composite::get_method_body, avg 5µs/call
125
126436µs789µs if(!exists $excludes->{$method_name}){
# spent 50µs making 2 calls to Mouse::Meta::Module::has_method, avg 25µs/call # spent 29µs making 2 calls to Mouse::Meta::Role::Composite::add_method, avg 15µs/call # spent 5µs making 2 calls to Mouse::Meta::Role::Composite::has_method, avg 3µs/call # spent 5µs making 1 call to Mouse::Meta::Module::add_method
127 if(!$consumer->has_method($method_name)){
128 # The third argument $role is used in Role::Composite
129 $consumer->add_method($method_name => $code, $role);
130 }
131 }
132
133410µs if(exists $alias->{$method_name}){
134 my $dstname = $alias->{$method_name};
135
136 my $dstcode = $consumer->get_method_body($dstname);
137
138 if(defined($dstcode) && $dstcode != $code){
139 $role->throw_error("Cannot create a method alias if a local method of the same name exists");
140 }
141 else{
142 $consumer->add_method($dstname => $code, $role);
143 }
144 }
145 }
146
147937µs return;
148}
149
150
# spent 4.57ms (396µs+4.18) within Mouse::Meta::Role::Application::apply_attributes which was called 9 times, avg 508µs/call: # 9 times (396µs+4.18ms) by Mouse::Meta::Role::Application::apply at line 67, avg 508µs/call
sub apply_attributes {
151913µs my($self, $role, $consumer) = @_;
152
153951µs934µs for my $attr_name ($role->get_attribute_list) {
# spent 34µs making 9 calls to Mouse::Meta::Module::get_attribute_list, avg 4µs/call
1542078µs2063µs next if $consumer->has_attribute($attr_name);
# spent 35µs making 10 calls to Mouse::Meta::Module::has_attribute, avg 3µs/call # spent 28µs making 10 calls to Mouse::Meta::Role::Composite::has_attribute, avg 3µs/call
155
15620159µs404.08ms $consumer->add_attribute($attr_name
# spent 3.79ms making 10 calls to Mouse::Meta::Class::add_attribute, avg 379µs/call # spent 226µs making 10 calls to Mouse::Meta::Role::Composite::add_attribute, avg 23µs/call # spent 61µs making 20 calls to Mouse::Meta::Module::get_attribute, avg 3µs/call
157 => $role->get_attribute($attr_name));
158 }
159931µs return;
160}
161
162
# spent 141µs within Mouse::Meta::Role::Application::apply_modifiers which was called 9 times, avg 16µs/call: # 9 times (141µs+0s) by Mouse::Meta::Role::Application::apply at line 73, avg 16µs/call
sub apply_modifiers {
163914µs my($self, $role, $consumer) = @_;
164
165912µs if(my $modifiers = $role->{override_method_modifiers}){
166 foreach my $method_name (keys %{$modifiers}){
167 $consumer->add_override_method_modifier(
168 $method_name => $modifiers->{$method_name});
169 }
170 }
171
172950µs for my $modifier_type (qw/before around after/) {
1732738µs my $table = $role->{"${modifier_type}_method_modifiers"}
174 or next;
175
176 my $add_modifier = "add_${modifier_type}_method_modifier";
177
178 while(my($method_name, $modifiers) = each %{$table}){
179 foreach my $code(@{ $modifiers }) {
180 # skip if the modifier is already applied
181 next if $consumer->{"_applied_$modifier_type"}{$method_name, $code}++;
182 $consumer->$add_modifier($method_name => $code);
183 }
184 }
185 }
186934µs return;
187}
188
189
# spent 1.03ms (192µs+834µs) within Mouse::Meta::Role::Application::_append_roles which was called 9 times, avg 114µs/call: # 9 times (192µs+834µs) by Mouse::Meta::Role::Application::apply at line 75, avg 114µs/call
sub _append_roles {
190912µs my($self, $role, $metaclass_or_role) = @_;
191
192912µs my $roles = $metaclass_or_role->{roles};
193961µs913µs foreach my $r($role, @{$role->get_roles}){
# spent 13µs making 9 calls to Mouse::Meta::Role::get_roles, avg 1µs/call
1941586µs15820µs if(!$metaclass_or_role->does_role($r)){
# spent 587µs making 9 calls to Mouse::Meta::Class::does_role, avg 65µs/call # spent 233µs making 6 calls to Mouse::Meta::Role::does_role, avg 39µs/call
195 push @{$roles}, $r;
196 }
197 }
198932µs return;
199}
20013µs1;
201__END__