| Filename | /home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role/Composite.pm |
| Statements | Executed 625 statements in 12.8ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 72 | 1 | 1 | 7.70ms | 16.8ms | Moose::Meta::Role::Composite::add_method |
| 3 | 1 | 1 | 551µs | 2.38ms | Moose::Meta::Role::Composite::new |
| 18 | 2 | 2 | 438µs | 615µs | Moose::Meta::Role::Composite::has_method |
| 3 | 1 | 1 | 316µs | 70.3ms | Moose::Meta::Role::Composite::apply_params |
| 3 | 1 | 1 | 112µs | 152µs | Moose::Meta::Role::Composite::_get_local_methods |
| 1 | 1 | 1 | 77µs | 96µs | Moose::Meta::Role::Composite::BEGIN@3 |
| 1 | 1 | 1 | 51µs | 340µs | Moose::Meta::Role::Composite::BEGIN@13 |
| 1 | 1 | 1 | 42µs | 203µs | Moose::Meta::Role::Composite::BEGIN@7 |
| 3 | 1 | 1 | 39µs | 39µs | Moose::Meta::Role::Composite::__ANON__[:30] |
| 1 | 1 | 1 | 38µs | 3.05ms | Moose::Meta::Role::Composite::BEGIN@5 |
| 1 | 1 | 1 | 38µs | 106µs | Moose::Meta::Role::Composite::BEGIN@4 |
| 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 | 101µs | 2 | 115µs | # spent 96µs (77+19) within Moose::Meta::Role::Composite::BEGIN@3 which was called:
# once (77µs+19µs) by Moose::BEGIN@28 at line 3 # spent 96µs making 1 call to Moose::Meta::Role::Composite::BEGIN@3
# spent 19µs making 1 call to strict::import |
| 4 | 3 | 95µs | 2 | 174µs | # spent 106µs (38+68) within Moose::Meta::Role::Composite::BEGIN@4 which was called:
# once (38µs+68µs) by Moose::BEGIN@28 at line 4 # spent 106µs making 1 call to Moose::Meta::Role::Composite::BEGIN@4
# spent 68µs making 1 call to warnings::import |
| 5 | 3 | 148µs | 2 | 6.06ms | # spent 3.05ms (38µs+3.01) within Moose::Meta::Role::Composite::BEGIN@5 which was called:
# once (38µs+3.01ms) by Moose::BEGIN@28 at line 5 # spent 3.05ms making 1 call to Moose::Meta::Role::Composite::BEGIN@5
# spent 3.01ms making 1 call to metaclass::import |
| 6 | |||||
| 7 | 3 | 222µs | 2 | 364µs | # spent 203µs (42+161) within Moose::Meta::Role::Composite::BEGIN@7 which was called:
# once (42µs+161µs) by Moose::BEGIN@28 at line 7 # spent 203µs making 1 call to Moose::Meta::Role::Composite::BEGIN@7
# spent 161µs making 1 call to Exporter::import |
| 8 | |||||
| 9 | 1 | 5µs | our $VERSION = '1.19'; | ||
| 10 | 1 | 60µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 11 | 1 | 4µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 12 | |||||
| 13 | 3 | 2.05ms | 2 | 629µs | # spent 340µs (51+289) within Moose::Meta::Role::Composite::BEGIN@13 which was called:
# once (51µs+289µs) by Moose::BEGIN@28 at line 13 # spent 340µs making 1 call to Moose::Meta::Role::Composite::BEGIN@13
# spent 289µ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 | 27µs | 2 | 2.10ms | __PACKAGE__->meta->add_attribute('name' => (reader => 'name')); # spent 1.95ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 150µ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 | 3 | 56µs | # spent 39µs within Moose::Meta::Role::Composite::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/Role/Composite.pm:30] which was called 3 times, avg 13µs/call:
# 3 times (39µs+0s) by Moose::Meta::Role::Composite::_new at line 12 of generated method (unknown origin), avg 13µs/call | ||
| 31 | 1 | 31µs | 2 | 2.10ms | )); # spent 2.01ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 88µs making 1 call to Moose::Meta::Role::Composite::meta |
| 32 | |||||
| 33 | 1 | 24µs | 2 | 2.02ms | __PACKAGE__->meta->add_attribute( # spent 1.94ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 88µ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 2.38ms (551µs+1.83) within Moose::Meta::Role::Composite::new which was called 3 times, avg 793µs/call:
# 3 times (551µs+1.83ms) by Moose::Meta::Role::combine at line 508 of Moose/Meta/Role.pm, avg 793µs/call | ||||
| 40 | 3 | 25µs | my ($class, %params) = @_; | ||
| 41 | |||||
| 42 | # the roles param is required ... | ||||
| 43 | 3 | 23µs | foreach ( @{$params{roles}} ) { | ||
| 44 | 8 | 156µs | 8 | 41µs | unless ( $_->isa('Moose::Meta::Role') ) { # spent 41µs making 8 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 | 8 | 76µs | 8 | 50µs | my @composition_roles = map { # spent 50µs making 8 calls to Moose::Meta::Role::composition_class_roles, avg 6µs/call |
| 51 | $_->composition_class_roles | ||||
| 52 | 3 | 38µs | } @{ $params{roles} }; | ||
| 53 | |||||
| 54 | 3 | 8µs | 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 | 11 | 198µs | 8 | 40µs | $params{name} ||= (join "|" => map { $_->name } @{$params{roles}}); # spent 40µs making 8 calls to Class::MOP::Package::name, avg 5µs/call |
| 66 | 3 | 75µs | 3 | 1.70ms | $class->_new(\%params); # spent 1.70ms making 3 calls to Moose::Meta::Role::Composite::_new, avg 566µ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 16.8ms (7.70+9.07) within Moose::Meta::Role::Composite::add_method which was called 72 times, avg 233µs/call:
# 72 times (7.70ms+9.07ms) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 200 of Moose/Meta/Role/Application/RoleSummation.pm, avg 233µs/call | ||||
| 74 | 72 | 299µs | my ($self, $method_name, $method) = @_; | ||
| 75 | |||||
| 76 | 72 | 156µs | unless ( defined $method_name && $method_name ) { | ||
| 77 | Moose->throw_error("You must define a method name"); | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | 72 | 119µs | my $body; | ||
| 81 | 72 | 1.35ms | 72 | 369µs | if (blessed($method)) { # spent 369µs making 72 calls to Scalar::Util::blessed, avg 5µs/call |
| 82 | 72 | 1.14ms | 72 | 367µs | $body = $method->body; # spent 367µs making 72 calls to Class::MOP::Method::body, avg 5µs/call |
| 83 | 72 | 3.89ms | 360 | 7.49ms | if ($method->package_name ne $self->name) { # spent 5.04ms making 72 calls to Class::MOP::Method::clone, avg 70µs/call
# spent 1.68ms making 144 calls to Moose::Meta::Role::Composite::name, avg 12µs/call
# spent 421µs making 72 calls to UNIVERSAL::can, avg 6µs/call
# spent 347µs making 72 calls to Class::MOP::Method::package_name, avg 5µ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 | 72 | 1.55ms | 72 | 849µs | $self->_method_map->{$method_name} = $method; # spent 849µs making 72 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 152µs (112+40) within Moose::Meta::Role::Composite::_get_local_methods which was called 3 times, avg 51µs/call:
# 3 times (112µs+40µs) by Moose::Meta::Role::Application::ToRole::apply_methods at line 80 of Moose/Meta/Role/Application/ToRole.pm, avg 51µs/call | ||||
| 104 | 3 | 8µs | my $self = shift; | ||
| 105 | 3 | 100µs | 3 | 40µs | return values %{ $self->_method_map }; # spent 40µs making 3 calls to Moose::Meta::Role::Composite::_method_map, avg 13µs/call |
| 106 | } | ||||
| 107 | |||||
| 108 | # spent 615µs (438+177) within Moose::Meta::Role::Composite::has_method which was called 18 times, avg 34µs/call:
# 9 times (235µs+90µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 218 of Moose/Meta/Role/Application/RoleSummation.pm, avg 36µs/call
# 9 times (203µs+87µs) by Moose::Meta::Role::add_override_method_modifier at line 358 of Moose/Meta/Role.pm, avg 32µs/call | ||||
| 109 | 18 | 58µs | my ($self, $method_name) = @_; | ||
| 110 | |||||
| 111 | 18 | 364µs | 18 | 177µs | return exists $self->_method_map->{$method_name}; # spent 177µs making 18 calls to Moose::Meta::Role::Composite::_method_map, avg 10µ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 70.3ms (316µs+70.0) within Moose::Meta::Role::Composite::apply_params which was called 3 times, avg 23.4ms/call:
# 3 times (316µs+70.0ms) by Moose::Meta::Role::combine at line 509 of Moose/Meta/Role.pm, avg 23.4ms/call | ||||
| 121 | 3 | 13µs | my ($self, $role_params) = @_; | ||
| 122 | 3 | 64µs | 6 | 48µs | Class::MOP::load_class($self->application_role_summation_class); # spent 48µs making 3 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 16µs/call
# spent 728µs making 3 calls to Class::MOP::load_class, avg 243µs/call, recursion: max depth 2, sum of overlapping time 728µs |
| 123 | |||||
| 124 | 3 | 145µs | 9 | 69.2ms | $self->application_role_summation_class->new( # spent 68.7ms making 3 calls to Moose::Meta::Role::Application::apply, avg 22.9ms/call
# spent 489µs making 3 calls to Moose::Meta::Role::Application::new, avg 163µs/call
# spent 42µs making 3 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 14µs/call |
| 125 | role_params => $role_params, | ||||
| 126 | )->apply($self); | ||||
| 127 | |||||
| 128 | 3 | 45µs | 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 | 41µs | 1; | ||
| 148 | |||||
| 149 | __END__ |