| Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Role/Application.pm |
| Statements | Executed 494 statements in 2.78ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 9 | 1 | 1 | 396µs | 4.57ms | Mouse::Meta::Role::Application::apply_attributes |
| 9 | 2 | 2 | 342µs | 9.91ms | Mouse::Meta::Role::Application::apply |
| 9 | 2 | 2 | 254µs | 3.29ms | Mouse::Meta::Role::Application::apply_methods |
| 9 | 1 | 1 | 235µs | 436µs | Mouse::Meta::Role::Application::check_required_methods |
| 9 | 2 | 2 | 211µs | 360µs | Mouse::Meta::Role::Application::new |
| 9 | 1 | 1 | 192µs | 1.03ms | Mouse::Meta::Role::Application::_append_roles |
| 9 | 1 | 1 | 141µs | 141µs | Mouse::Meta::Role::Application::apply_modifiers |
| 1 | 1 | 1 | 26µs | 112µs | Mouse::Meta::Role::Application::BEGIN@2 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Mouse::Meta::Role::Application; | ||||
| 2 | 2 | 973µs | 2 | 198µ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 # 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 | ||||
| 5 | 81 | 239µs | my $class = shift; | ||
| 6 | 9 | 14µs | my $args = $class->Mouse::Object::BUILDARGS(@_); # spent 14µs making 9 calls to Mouse::Object::BUILDARGS, avg 2µs/call | ||
| 7 | |||||
| 8 | 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 | |||||
| 21 | $args->{aliased_methods} = {}; | ||||
| 22 | if(my $alias = $args->{-alias}){ | ||||
| 23 | @{$args->{aliased_methods}}{ values %{$alias} } = (); | ||||
| 24 | } | ||||
| 25 | |||||
| 26 | 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 | } | ||||
| 35 | my $self = bless $args, $class; | ||||
| 36 | 1 | 28µs | 10 | 182µ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 | } | ||||
| 39 | 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 | ||||
| 43 | 90 | 345µs | my($self, $role, $consumer, @extra) = @_; | ||
| 44 | my $instance; | ||||
| 45 | |||||
| 46 | 15 | 39µ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); | ||||
| 64 | 9 | 436µ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 | |||||
| 67 | 9 | 4.57ms | $self->apply_attributes($role, $consumer, @extra); # spent 4.57ms making 9 calls to Mouse::Meta::Role::Application::apply_attributes, avg 508µs/call | ||
| 68 | 9 | 3.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); | ||||
| 73 | 9 | 141µ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 | |||||
| 75 | 9 | 1.03ms | $self->_append_roles($role, $consumer); # spent 1.03ms making 9 calls to Mouse::Meta::Role::Application::_append_roles, avg 114µs/call | ||
| 76 | |||||
| 77 | if(defined $instance){ # Application::ToInstance | ||||
| 78 | # rebless instance | ||||
| 79 | bless $instance, $consumer->name; | ||||
| 80 | $consumer->_initialize_object($instance, $instance, 1); | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | 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 | ||||
| 87 | 27 | 94µs | my($self, $role, $consumer) = @_; | ||
| 88 | |||||
| 89 | 12 | 41µs | 12 | 161µ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 | ||||
| 93 | 3 | 5µs | my $consumer_class_name = $consumer->name; # spent 5µs making 3 calls to Mouse::Meta::Module::name, avg 2µs/call | ||
| 94 | |||||
| 95 | my @missing; | ||||
| 96 | foreach my $method_name(@{$role->{required_methods}}){ | ||||
| 97 | 30 | 134µs | next if exists $self->{aliased_methods}{$method_name}; | ||
| 98 | next if exists $role->{methods}{$method_name}; | ||||
| 99 | 10 | 36µ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 | } | ||||
| 103 | 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 | |||||
| 112 | 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 | ||||
| 116 | 45 | 137µs | my($self, $role, $consumer) = @_; | ||
| 117 | |||||
| 118 | my $alias = $self->{-alias}; | ||||
| 119 | my $excludes = $self->{-excludes}; | ||||
| 120 | |||||
| 121 | 9 | 2.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 | ||
| 122 | 25 | 104µs | next if $method_name eq 'meta'; | ||
| 123 | |||||
| 124 | 4 | 61µ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 | |||||
| 126 | 7 | 89µ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 | |||||
| 133 | 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 | |||||
| 147 | 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 | ||||
| 151 | 27 | 95µs | my($self, $role, $consumer) = @_; | ||
| 152 | |||||
| 153 | 9 | 34µ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 | ||
| 154 | 40 | 237µs | 20 | 63µ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 | |||||
| 156 | 40 | 4.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 | } | ||||
| 159 | 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 | ||||
| 163 | 36 | 83µs | my($self, $role, $consumer) = @_; | ||
| 164 | |||||
| 165 | 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 | |||||
| 172 | for my $modifier_type (qw/before around after/) { | ||||
| 173 | 27 | 67µ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 | } | ||||
| 186 | 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 | ||||
| 190 | 36 | 116µs | my($self, $role, $metaclass_or_role) = @_; | ||
| 191 | |||||
| 192 | my $roles = $metaclass_or_role->{roles}; | ||||
| 193 | 9 | 13µs | foreach my $r($role, @{$role->get_roles}){ # spent 13µs making 9 calls to Mouse::Meta::Role::get_roles, avg 1µs/call | ||
| 194 | 15 | 86µs | 15 | 820µ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 | } | ||||
| 198 | return; | ||||
| 199 | } | ||||
| 200 | 1 | 3µs | 1; | ||
| 201 | __END__ |