| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role/Composite.pm |
| Statements | Executed 1609 statements in 30.9ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 178 | 1 | 1 | 20.6ms | 45.2ms | Moose::Meta::Role::Composite::add_method |
| 82 | 2 | 2 | 2.12ms | 3.00ms | Moose::Meta::Role::Composite::has_method |
| 9 | 1 | 1 | 1.51ms | 6.15ms | Moose::Meta::Role::Composite::new |
| 9 | 1 | 1 | 847µs | 252ms | Moose::Meta::Role::Composite::apply_params |
| 9 | 1 | 1 | 344µs | 467µs | Moose::Meta::Role::Composite::_get_local_methods |
| 9 | 1 | 1 | 87µs | 87µs | Moose::Meta::Role::Composite::__ANON__[:30] |
| 1 | 1 | 1 | 76µs | 94µs | Moose::Meta::Role::Composite::BEGIN@3 |
| 1 | 1 | 1 | 44µs | 119µs | Moose::Meta::Role::Composite::BEGIN@4 |
| 1 | 1 | 1 | 43µs | 204µs | Moose::Meta::Role::Composite::BEGIN@7 |
| 1 | 1 | 1 | 40µs | 297µs | Moose::Meta::Role::Composite::BEGIN@13 |
| 1 | 1 | 1 | 38µs | 3.33ms | Moose::Meta::Role::Composite::BEGIN@5 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::get_method |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::get_method_list |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::Role::Composite::reinitialize |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::Role::Composite; | ||||
| 2 | |||||
| 3 | 3 | 102µs | 2 | 113µs | # spent 94µs (76+18) within Moose::Meta::Role::Composite::BEGIN@3 which was called:
# once (76µs+18µs) by Moose::BEGIN@28 at line 3 # spent 94µs making 1 call to Moose::Meta::Role::Composite::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 107µs | 2 | 194µs | # spent 119µs (44+75) within Moose::Meta::Role::Composite::BEGIN@4 which was called:
# once (44µs+75µs) by Moose::BEGIN@28 at line 4 # spent 119µs making 1 call to Moose::Meta::Role::Composite::BEGIN@4
# spent 75µs making 1 call to warnings::import |
| 5 | 3 | 160µs | 2 | 6.63ms | # spent 3.33ms (38µs+3.30) within Moose::Meta::Role::Composite::BEGIN@5 which was called:
# once (38µs+3.30ms) by Moose::BEGIN@28 at line 5 # spent 3.33ms making 1 call to Moose::Meta::Role::Composite::BEGIN@5
# spent 3.30ms making 1 call to metaclass::import |
| 6 | |||||
| 7 | 3 | 224µs | 2 | 366µs | # spent 204µs (43+162) within Moose::Meta::Role::Composite::BEGIN@7 which was called:
# once (43µs+162µs) by Moose::BEGIN@28 at line 7 # spent 204µs making 1 call to Moose::Meta::Role::Composite::BEGIN@7
# spent 162µs making 1 call to Exporter::import |
| 8 | |||||
| 9 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 10 | 1 | 66µs | $VERSION = eval $VERSION; # spent 13µs executing statements in string eval | ||
| 11 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 12 | |||||
| 13 | 3 | 2.04ms | 2 | 554µs | # spent 297µs (40+257) within Moose::Meta::Role::Composite::BEGIN@13 which was called:
# once (40µs+257µs) by Moose::BEGIN@28 at line 13 # spent 297µs making 1 call to Moose::Meta::Role::Composite::BEGIN@13
# spent 257µs making 1 call to base::import |
| 14 | |||||
| 15 | # NOTE: | ||||
| 16 | # we need to override the ->name | ||||
| 17 | # method from Class::MOP::Package | ||||
| 18 | # since we don't have an actual | ||||
| 19 | # package for this. | ||||
| 20 | # - SL | ||||
| 21 | 1 | 28µs | 2 | 2.22ms | __PACKAGE__->meta->add_attribute('name' => (reader => 'name')); # spent 2.10ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 119µs making 1 call to Moose::Meta::Role::Composite::meta |
| 22 | |||||
| 23 | # NOTE: | ||||
| 24 | # Again, since we don't have a real | ||||
| 25 | # package to store our methods in, | ||||
| 26 | # we use a HASH ref instead. | ||||
| 27 | # - SL | ||||
| 28 | __PACKAGE__->meta->add_attribute('_methods' => ( | ||||
| 29 | reader => '_method_map', | ||||
| 30 | 9 | 125µs | # spent 87µs within Moose::Meta::Role::Composite::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/Role/Composite.pm:30] which was called 9 times, avg 10µs/call:
# 9 times (87µs+0s) by Moose::Meta::Role::Composite::_new at line 46 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 10µs/call | ||
| 31 | 1 | 32µs | 2 | 2.12ms | )); # spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 87µs making 1 call to Moose::Meta::Role::Composite::meta |
| 32 | |||||
| 33 | 1 | 26µs | 2 | 2.18ms | __PACKAGE__->meta->add_attribute( # spent 2.08ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 108µs making 1 call to Moose::Meta::Role::Composite::meta |
| 34 | 'application_role_summation_class', | ||||
| 35 | reader => 'application_role_summation_class', | ||||
| 36 | default => 'Moose::Meta::Role::Application::RoleSummation', | ||||
| 37 | ); | ||||
| 38 | |||||
| 39 | # spent 6.15ms (1.51+4.63) within Moose::Meta::Role::Composite::new which was called 9 times, avg 683µs/call:
# 9 times (1.51ms+4.63ms) by Moose::Meta::Role::combine at line 508 of Moose/Meta/Role.pm, avg 683µs/call | ||||
| 40 | 54 | 661µs | my ($class, %params) = @_; | ||
| 41 | |||||
| 42 | # the roles param is required ... | ||||
| 43 | foreach ( @{$params{roles}} ) { | ||||
| 44 | 20 | 400µs | 20 | 104µs | unless ( $_->isa('Moose::Meta::Role') ) { # spent 104µs making 20 calls to UNIVERSAL::isa, avg 5µs/call |
| 45 | require Moose; | ||||
| 46 | Moose->throw_error("The list of roles must be instances of Moose::Meta::Role, not $_"); | ||||
| 47 | } | ||||
| 48 | } | ||||
| 49 | |||||
| 50 | 20 | 133µs | my @composition_roles = map { # spent 133µs making 20 calls to Moose::Meta::Role::composition_class_roles, avg 7µs/call | ||
| 51 | $_->composition_class_roles | ||||
| 52 | 20 | 199µs | } @{ $params{roles} }; | ||
| 53 | |||||
| 54 | if (@composition_roles) { | ||||
| 55 | my $meta = Moose::Meta::Class->create_anon_class( | ||||
| 56 | superclasses => [ $class ], | ||||
| 57 | roles => [ @composition_roles ], | ||||
| 58 | cache => 1, | ||||
| 59 | ); | ||||
| 60 | $class = $meta->name; | ||||
| 61 | } | ||||
| 62 | |||||
| 63 | # and the name is created from the | ||||
| 64 | # roles if one has not been provided | ||||
| 65 | 20 | 388µs | 20 | 106µs | $params{name} ||= (join "|" => map { $_->name } @{$params{roles}}); # spent 106µs making 20 calls to Class::MOP::Package::name, avg 5µs/call |
| 66 | 9 | 4.29ms | $class->_new(\%params); # spent 4.29ms making 9 calls to Moose::Meta::Role::Composite::_new, avg 477µs/call | ||
| 67 | } | ||||
| 68 | |||||
| 69 | # This is largely a cope of what's in Moose::Meta::Role (itself | ||||
| 70 | # largely a copy of Class::MOP::Class). However, we can't actually | ||||
| 71 | # call add_package_symbol, because there's no package to which which | ||||
| 72 | # add the symbol. | ||||
| 73 | # spent 45.2ms (20.6+24.7) within Moose::Meta::Role::Composite::add_method which was called 178 times, avg 254µs/call:
# 178 times (20.6ms+24.7ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 200 of Moose/Meta/Role/Application/RoleSummation.pm, avg 254µs/call | ||||
| 74 | 890 | 9.24ms | my ($self, $method_name, $method) = @_; | ||
| 75 | |||||
| 76 | unless ( defined $method_name && $method_name ) { | ||||
| 77 | Moose->throw_error("You must define a method name"); | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | my $body; | ||||
| 81 | 356 | 13.9ms | 178 | 1.06ms | if (blessed($method)) { # spent 1.06ms making 178 calls to Scalar::Util::blessed, avg 6µs/call |
| 82 | 178 | 1.03ms | $body = $method->body; # spent 1.03ms making 178 calls to Class::MOP::Method::body, avg 6µs/call | ||
| 83 | 890 | 20.4ms | if ($method->package_name ne $self->name) { # spent 13.7ms making 178 calls to Class::MOP::Method::clone, avg 77µs/call
# spent 4.50ms making 356 calls to Moose::Meta::Role::Composite::name, avg 13µs/call
# spent 1.19ms making 178 calls to UNIVERSAL::can, avg 7µs/call
# spent 997µs making 178 calls to Class::MOP::Method::package_name, avg 6µs/call | ||
| 84 | $method = $method->clone( | ||||
| 85 | package_name => $self->name, | ||||
| 86 | name => $method_name | ||||
| 87 | ) if $method->can('clone'); | ||||
| 88 | } | ||||
| 89 | } | ||||
| 90 | else { | ||||
| 91 | $body = $method; | ||||
| 92 | $method = $self->wrap_method_body( body => $body, name => $method_name ); | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | 178 | 2.17ms | $self->_method_map->{$method_name} = $method; # spent 2.17ms making 178 calls to Moose::Meta::Role::Composite::_method_map, avg 12µs/call | ||
| 96 | } | ||||
| 97 | |||||
| 98 | sub get_method_list { | ||||
| 99 | my $self = shift; | ||||
| 100 | return keys %{ $self->_method_map }; | ||||
| 101 | } | ||||
| 102 | |||||
| 103 | # spent 467µs (344+122) within Moose::Meta::Role::Composite::_get_local_methods which was called 9 times, avg 52µs/call:
# 9 times (344µs+122µs) by Moose::Meta::Role::Application::ToRole::apply_methods at line 80 of Moose/Meta/Role/Application/ToRole.pm, avg 52µs/call | ||||
| 104 | 18 | 335µs | my $self = shift; | ||
| 105 | 9 | 122µs | return values %{ $self->_method_map }; # spent 122µs making 9 calls to Moose::Meta::Role::Composite::_method_map, avg 14µs/call | ||
| 106 | } | ||||
| 107 | |||||
| 108 | # spent 3.00ms (2.12+873µs) within Moose::Meta::Role::Composite::has_method which was called 82 times, avg 37µs/call:
# 41 times (1.11ms+441µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 218 of Moose/Meta/Role/Application/RoleSummation.pm, avg 38µs/call
# 41 times (1.01ms+432µs) by Moose::Meta::Role::add_override_method_modifier at line 351 of Moose/Meta/Role.pm, avg 35µs/call | ||||
| 109 | 164 | 2.04ms | my ($self, $method_name) = @_; | ||
| 110 | |||||
| 111 | 82 | 873µs | return exists $self->_method_map->{$method_name}; # spent 873µs making 82 calls to Moose::Meta::Role::Composite::_method_map, avg 11µs/call | ||
| 112 | } | ||||
| 113 | |||||
| 114 | sub get_method { | ||||
| 115 | my ($self, $method_name) = @_; | ||||
| 116 | |||||
| 117 | return $self->_method_map->{$method_name}; | ||||
| 118 | } | ||||
| 119 | |||||
| 120 | # spent 252ms (847µs+252) within Moose::Meta::Role::Composite::apply_params which was called 9 times, avg 28.0ms/call:
# 9 times (847µs+252ms) by Moose::Meta::Role::combine at line 509 of Moose/Meta/Role.pm, avg 28.0ms/call | ||||
| 121 | 36 | 748µs | my ($self, $role_params) = @_; | ||
| 122 | 18 | 131µs | Class::MOP::load_class($self->application_role_summation_class); # spent 131µs making 9 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 15µs/call
# spent 2.21ms making 9 calls to Class::MOP::load_class, avg 246µs/call, recursion: max depth 3, sum of overlapping time 2.21ms | ||
| 123 | |||||
| 124 | 27 | 249ms | $self->application_role_summation_class->new( # spent 248ms making 9 calls to Moose::Meta::Role::Application::apply, avg 27.5ms/call
# spent 1.29ms making 9 calls to Moose::Meta::Role::Application::new, avg 144µs/call
# spent 122µs making 9 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 14µs/call | ||
| 125 | role_params => $role_params, | ||||
| 126 | )->apply($self); | ||||
| 127 | |||||
| 128 | return $self; | ||||
| 129 | } | ||||
| 130 | |||||
| 131 | sub reinitialize { | ||||
| 132 | my ( $class, $old_meta, @args ) = @_; | ||||
| 133 | |||||
| 134 | Moose->throw_error( | ||||
| 135 | 'Moose::Meta::Role::Composite instances can only be reinitialized from an existing metaclass instance' | ||||
| 136 | ) | ||||
| 137 | if !blessed $old_meta | ||||
| 138 | || !$old_meta->isa('Moose::Meta::Role::Composite'); | ||||
| 139 | |||||
| 140 | my %existing_classes = map { $_ => $old_meta->$_() } qw( | ||||
| 141 | application_role_summation_class | ||||
| 142 | ); | ||||
| 143 | |||||
| 144 | return $old_meta->meta->clone_object( $old_meta, %existing_classes, @args ); | ||||
| 145 | } | ||||
| 146 | |||||
| 147 | 1 | 39µs | 1; | ||
| 148 | |||||
| 149 | __END__ |