| Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Composite.pm |
| Statements | Executed 519 statements in 4.56ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 59 | 1 | 1 | 3.77ms | 4.69ms | Moose::Meta::Role::Composite::add_method |
| 3 | 1 | 1 | 80µs | 322µs | Moose::Meta::Role::Composite::new |
| 3 | 1 | 1 | 55µs | 12.4ms | Moose::Meta::Role::Composite::apply_params |
| 12 | 2 | 2 | 31µs | 40µs | Moose::Meta::Role::Composite::has_method |
| 3 | 2 | 2 | 18µs | 22µs | Moose::Meta::Role::Composite::_get_local_methods |
| 1 | 1 | 1 | 8µs | 8µs | Moose::Meta::Role::Composite::BEGIN@2 |
| 1 | 1 | 1 | 6µs | 27µs | Moose::Meta::Role::Composite::BEGIN@13 |
| 1 | 1 | 1 | 6µs | 24µs | Moose::Meta::Role::Composite::BEGIN@14 |
| 1 | 1 | 1 | 6µs | 9µs | Moose::Meta::Role::Composite::BEGIN@10 |
| 1 | 1 | 1 | 6µs | 57µs | Moose::Meta::Role::Composite::BEGIN@16 |
| 1 | 1 | 1 | 5µs | 327µs | Moose::Meta::Role::Composite::BEGIN@11 |
| 1 | 1 | 1 | 5µs | 16µs | Moose::Meta::Role::Composite::BEGIN@9 |
| 3 | 1 | 1 | 5µs | 5µs | Moose::Meta::Role::Composite::__ANON__[:36] |
| 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 | # spent 8µs within Moose::Meta::Role::Composite::BEGIN@2 which was called:
# once (8µs+0s) by Moose::BEGIN@36 at line 4 | ||||
| 3 | 1 | 4µs | $Moose::Meta::Role::Composite::AUTHORITY = 'cpan:STEVAN'; | ||
| 4 | 1 | 28µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::Role::Composite::BEGIN@2 |
| 5 | { | ||||
| 6 | 2 | 800ns | $Moose::Meta::Role::Composite::VERSION = '2.1005'; | ||
| 7 | } | ||||
| 8 | |||||
| 9 | 2 | 20µs | 2 | 26µs | # spent 16µs (5+10) within Moose::Meta::Role::Composite::BEGIN@9 which was called:
# once (5µs+10µs) by Moose::BEGIN@36 at line 9 # spent 16µs making 1 call to Moose::Meta::Role::Composite::BEGIN@9
# spent 10µs making 1 call to strict::import |
| 10 | 2 | 18µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::Role::Composite::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::BEGIN@36 at line 10 # spent 9µs making 1 call to Moose::Meta::Role::Composite::BEGIN@10
# spent 3µs making 1 call to warnings::import |
| 11 | 2 | 26µs | 2 | 649µs | # spent 327µs (5+322) within Moose::Meta::Role::Composite::BEGIN@11 which was called:
# once (5µs+322µs) by Moose::BEGIN@36 at line 11 # spent 327µs making 1 call to Moose::Meta::Role::Composite::BEGIN@11
# spent 322µs making 1 call to metaclass::import |
| 12 | |||||
| 13 | 2 | 22µs | 2 | 47µs | # spent 27µs (6+21) within Moose::Meta::Role::Composite::BEGIN@13 which was called:
# once (6µs+21µs) by Moose::BEGIN@36 at line 13 # spent 27µs making 1 call to Moose::Meta::Role::Composite::BEGIN@13
# spent 21µs making 1 call to Exporter::import |
| 14 | 2 | 22µs | 2 | 41µs | # spent 24µs (6+18) within Moose::Meta::Role::Composite::BEGIN@14 which was called:
# once (6µs+18µs) by Moose::BEGIN@36 at line 14 # spent 24µs making 1 call to Moose::Meta::Role::Composite::BEGIN@14
# spent 18µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 2 | 537µs | 2 | 109µs | # spent 57µs (6+52) within Moose::Meta::Role::Composite::BEGIN@16 which was called:
# once (6µs+52µs) by Moose::BEGIN@36 at line 16 # spent 57µs making 1 call to Moose::Meta::Role::Composite::BEGIN@16
# spent 52µs making 1 call to base::import |
| 17 | |||||
| 18 | # NOTE: | ||||
| 19 | # we need to override the ->name | ||||
| 20 | # method from Class::MOP::Package | ||||
| 21 | # since we don't have an actual | ||||
| 22 | # package for this. | ||||
| 23 | # - SL | ||||
| 24 | 1 | 3µs | 3 | 286µs | __PACKAGE__->meta->add_attribute('name' => ( # spent 266µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 16µs making 1 call to Moose::Meta::Role::Composite::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
| 25 | reader => 'name', | ||||
| 26 | Class::MOP::_definition_context(), | ||||
| 27 | )); | ||||
| 28 | |||||
| 29 | # NOTE: | ||||
| 30 | # Again, since we don't have a real | ||||
| 31 | # package to store our methods in, | ||||
| 32 | # we use a HASH ref instead. | ||||
| 33 | # - SL | ||||
| 34 | __PACKAGE__->meta->add_attribute('_methods' => ( | ||||
| 35 | reader => '_method_map', | ||||
| 36 | 3 | 8µs | # spent 5µs within Moose::Meta::Role::Composite::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/Role/Composite.pm:36] which was called 3 times, avg 2µs/call:
# 3 times (5µs+0s) by Moose::Meta::Role::Composite::_new at line 15 of (eval 74)[Eval/Closure.pm:135], avg 2µs/call | ||
| 37 | 1 | 4µs | 3 | 271µs | Class::MOP::_definition_context(), # spent 258µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 9µs making 1 call to Moose::Meta::Role::Composite::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
| 38 | )); | ||||
| 39 | |||||
| 40 | 1 | 3µs | 3 | 268µs | __PACKAGE__->meta->add_attribute( # spent 255µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Moose::Meta::Role::Composite::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 41 | 'application_role_summation_class', | ||||
| 42 | reader => 'application_role_summation_class', | ||||
| 43 | default => 'Moose::Meta::Role::Application::RoleSummation', | ||||
| 44 | Class::MOP::_definition_context(), | ||||
| 45 | ); | ||||
| 46 | |||||
| 47 | # spent 322µs (80+242) within Moose::Meta::Role::Composite::new which was called 3 times, avg 107µs/call:
# 3 times (80µs+242µs) by Moose::Meta::Role::combine at line 495 of Moose/Meta/Role.pm, avg 107µs/call | ||||
| 48 | 3 | 3µs | my ($class, %params) = @_; | ||
| 49 | |||||
| 50 | # the roles param is required ... | ||||
| 51 | 3 | 3µs | foreach ( @{$params{roles}} ) { | ||
| 52 | 8 | 18µs | 8 | 4µs | unless ( $_->isa('Moose::Meta::Role') ) { # spent 4µs making 8 calls to UNIVERSAL::isa, avg 488ns/call |
| 53 | require Moose; | ||||
| 54 | Moose->throw_error("The list of roles must be instances of Moose::Meta::Role, not $_"); | ||||
| 55 | } | ||||
| 56 | } | ||||
| 57 | |||||
| 58 | 8 | 7µs | 8 | 5µs | my @composition_roles = map { # spent 5µs making 8 calls to Moose::Meta::Role::composition_class_roles, avg 662ns/call |
| 59 | $_->composition_class_roles | ||||
| 60 | 3 | 5µs | } @{ $params{roles} }; | ||
| 61 | |||||
| 62 | 3 | 700ns | if (@composition_roles) { | ||
| 63 | my $meta = Moose::Meta::Class->create_anon_class( | ||||
| 64 | superclasses => [ $class ], | ||||
| 65 | roles => [ @composition_roles ], | ||||
| 66 | cache => 1, | ||||
| 67 | ); | ||||
| 68 | $class = $meta->name; | ||||
| 69 | } | ||||
| 70 | |||||
| 71 | # and the name is created from the | ||||
| 72 | # roles if one has not been provided | ||||
| 73 | 11 | 25µs | 8 | 4µs | $params{name} ||= (join "|" => map { $_->name } @{$params{roles}}); # spent 4µs making 8 calls to Class::MOP::Package::name, avg 538ns/call |
| 74 | 3 | 11µs | 3 | 229µs | $class->_new(\%params); # spent 229µs making 3 calls to Moose::Meta::Role::Composite::_new, avg 76µs/call |
| 75 | } | ||||
| 76 | |||||
| 77 | # This is largely a copy of what's in Moose::Meta::Role (itself | ||||
| 78 | # largely a copy of Class::MOP::Class). However, we can't actually | ||||
| 79 | # call add_package_symbol, because there's no package into which to | ||||
| 80 | # add the symbol. | ||||
| 81 | # spent 4.69ms (3.77+917µs) within Moose::Meta::Role::Composite::add_method which was called 59 times, avg 80µs/call:
# 59 times (3.77ms+917µs) by Moose::Meta::Role::Application::RoleSummation::apply_methods at line 205 of Moose/Meta/Role/Application/RoleSummation.pm, avg 80µs/call | ||||
| 82 | 59 | 13µs | my ($self, $method_name, $method) = @_; | ||
| 83 | |||||
| 84 | 59 | 6µs | unless ( defined $method_name && $method_name ) { | ||
| 85 | Moose->throw_error("You must define a method name"); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | 59 | 300ns | my $body; | ||
| 89 | 59 | 3.14ms | 59 | 25µs | if (blessed($method)) { # spent 25µs making 59 calls to Scalar::Util::blessed, avg 427ns/call |
| 90 | 59 | 102µs | 59 | 25µs | $body = $method->body; # spent 25µs making 59 calls to Class::MOP::Method::body, avg 422ns/call |
| 91 | 59 | 302µs | 295 | 805µs | if ($method->package_name ne $self->name) { # spent 627µs making 59 calls to Class::MOP::Method::clone, avg 11µs/call
# spent 125µs making 118 calls to Moose::Meta::Role::Composite::name, avg 1µs/call
# spent 32µs making 59 calls to UNIVERSAL::can, avg 537ns/call
# spent 22µs making 59 calls to Class::MOP::Method::package_name, avg 376ns/call |
| 92 | $method = $method->clone( | ||||
| 93 | package_name => $self->name, | ||||
| 94 | name => $method_name | ||||
| 95 | ) if $method->can('clone'); | ||||
| 96 | } | ||||
| 97 | } | ||||
| 98 | else { | ||||
| 99 | $body = $method; | ||||
| 100 | $method = $self->wrap_method_body( body => $body, name => $method_name ); | ||||
| 101 | } | ||||
| 102 | |||||
| 103 | 59 | 133µs | 59 | 61µs | $self->_method_map->{$method_name} = $method; # spent 61µs making 59 calls to Moose::Meta::Role::Composite::_method_map, avg 1µs/call |
| 104 | } | ||||
| 105 | |||||
| 106 | sub get_method_list { | ||||
| 107 | my $self = shift; | ||||
| 108 | return keys %{ $self->_method_map }; | ||||
| 109 | } | ||||
| 110 | |||||
| 111 | # spent 22µs (18+4) within Moose::Meta::Role::Composite::_get_local_methods which was called 3 times, avg 7µs/call:
# 2 times (11µs+2µs) by Moose::Meta::Role::Application::ToRole::apply_methods at line 82 of Moose/Meta/Role/Application/ToRole.pm, avg 6µs/call
# once (7µs+2µs) by Moose::Meta::Role::Application::ToClass::apply_methods at line 162 of Moose/Meta/Role/Application/ToClass.pm | ||||
| 112 | 3 | 800ns | my $self = shift; | ||
| 113 | 3 | 16µs | 3 | 4µs | return values %{ $self->_method_map }; # spent 4µs making 3 calls to Moose::Meta::Role::Composite::_method_map, avg 1µs/call |
| 114 | } | ||||
| 115 | |||||
| 116 | # spent 40µs (31+9) within Moose::Meta::Role::Composite::has_method which was called 12 times, avg 3µs/call:
# 6 times (18µs+5µs) by Moose::Meta::Role::Application::RoleSummation::apply_override_method_modifiers at line 223 of Moose/Meta/Role/Application/RoleSummation.pm, avg 4µs/call
# 6 times (13µs+4µs) by Moose::Meta::Role::add_override_method_modifier at line 366 of Moose/Meta/Role.pm, avg 3µs/call | ||||
| 117 | 12 | 2µs | my ($self, $method_name) = @_; | ||
| 118 | |||||
| 119 | 12 | 25µs | 12 | 9µs | return exists $self->_method_map->{$method_name}; # spent 9µs making 12 calls to Moose::Meta::Role::Composite::_method_map, avg 758ns/call |
| 120 | } | ||||
| 121 | |||||
| 122 | sub get_method { | ||||
| 123 | my ($self, $method_name) = @_; | ||||
| 124 | |||||
| 125 | return $self->_method_map->{$method_name}; | ||||
| 126 | } | ||||
| 127 | |||||
| 128 | # spent 12.4ms (55µs+12.3) within Moose::Meta::Role::Composite::apply_params which was called 3 times, avg 4.13ms/call:
# 3 times (55µs+12.3ms) by Moose::Meta::Role::combine at line 496 of Moose/Meta/Role.pm, avg 4.13ms/call | ||||
| 129 | 3 | 1µs | my ($self, $role_params) = @_; | ||
| 130 | 3 | 7µs | 6 | 29µs | load_class($self->application_role_summation_class); # spent 64µs making 3 calls to Class::Load::load_class, avg 21µs/call, recursion: max depth 2, sum of overlapping time 42µs
# spent 7µs making 3 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 2µs/call |
| 131 | |||||
| 132 | 3 | 21µs | 9 | 4.19ms | $self->application_role_summation_class->new( # spent 12.2ms making 3 calls to Moose::Meta::Role::Application::apply, avg 4.05ms/call, recursion: max depth 1, sum of overlapping time 8.06ms
# spent 81µs making 3 calls to Moose::Meta::Role::Application::new, avg 27µs/call
# spent 4µs making 3 calls to Moose::Meta::Role::Composite::application_role_summation_class, avg 1µs/call |
| 133 | role_params => $role_params, | ||||
| 134 | )->apply($self); | ||||
| 135 | |||||
| 136 | 3 | 6µs | return $self; | ||
| 137 | } | ||||
| 138 | |||||
| 139 | sub reinitialize { | ||||
| 140 | my ( $class, $old_meta, @args ) = @_; | ||||
| 141 | |||||
| 142 | Moose->throw_error( | ||||
| 143 | 'Moose::Meta::Role::Composite instances can only be reinitialized from an existing metaclass instance' | ||||
| 144 | ) | ||||
| 145 | if !blessed $old_meta | ||||
| 146 | || !$old_meta->isa('Moose::Meta::Role::Composite'); | ||||
| 147 | |||||
| 148 | my %existing_classes = map { $_ => $old_meta->$_() } qw( | ||||
| 149 | application_role_summation_class | ||||
| 150 | ); | ||||
| 151 | |||||
| 152 | return $old_meta->meta->clone_object( $old_meta, %existing_classes, @args ); | ||||
| 153 | } | ||||
| 154 | |||||
| 155 | 1 | 6µs | 1; | ||
| 156 | |||||
| 157 | # ABSTRACT: An object to represent the set of roles | ||||
| 158 | |||||
| 159 | __END__ |