| Filename | /home/hinrik/perl5/perlbrew/perls/perl-5.13.5/lib/site_perl/5.13.5/x86_64-linux/Mouse/Meta/Role.pm |
| Statements | Executed 464 statements in 2.28ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 3 | 1 | 1 | 836µs | 7.76ms | Mouse::Meta::Role::combine |
| 33 | 3 | 3 | 534µs | 617µs | Mouse::Meta::Role::does_role (recurses: max depth 1, inclusive time 251µs) |
| 17 | 2 | 2 | 306µs | 565µs | Mouse::Meta::Role::add_required_methods |
| 7 | 1 | 1 | 181µs | 372µs | Mouse::Meta::Role::_construct_meta |
| 18 | 2 | 2 | 144µs | 144µs | Mouse::Meta::Role::add_attribute |
| 6 | 1 | 1 | 90µs | 4.82ms | Mouse::Meta::Role::apply |
| 33 | 2 | 2 | 45µs | 45µs | Mouse::Meta::Role::get_roles (xsub) |
| 3 | 1 | 1 | 30µs | 658µs | Mouse::Meta::Role::create_anon_role |
| 1 | 1 | 1 | 25µs | 105µs | Mouse::Meta::Role::BEGIN@2 |
| 6 | 1 | 1 | 22µs | 22µs | Mouse::Meta::Role::get_required_method_list |
| 1 | 1 | 1 | 6µs | 6µs | Mouse::Meta::Role::BEGIN@4 |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Role::add_override_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Role::calculate_all_roles |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Role::get_override_method_modifier |
| 0 | 0 | 0 | 0s | 0s | Mouse::Meta::Role::requires_method |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Mouse::Meta::Role; | ||||
| 2 | 2 | 28µs | 2 | 185µs | # spent 105µs (25+80) within Mouse::Meta::Role::BEGIN@2 which was called:
# once (25µs+80µs) by Mouse::BEGIN@15 at line 2 # spent 105µs making 1 call to Mouse::Meta::Role::BEGIN@2
# spent 80µs making 1 call to Mouse::Exporter::do_import |
| 3 | |||||
| 4 | 2 | 567µs | 1 | 6µs | # spent 6µs within Mouse::Meta::Role::BEGIN@4 which was called:
# once (6µs+0s) by Mouse::BEGIN@15 at line 4 # spent 6µs making 1 call to Mouse::Meta::Role::BEGIN@4 |
| 5 | 1 | 6µs | our @ISA = qw(Mouse::Meta::Module); | ||
| 6 | |||||
| 7 | sub method_metaclass; | ||||
| 8 | |||||
| 9 | # spent 372µs (181+191) within Mouse::Meta::Role::_construct_meta which was called 7 times, avg 53µs/call:
# 7 times (181µs+191µs) by Mouse::Meta::Module::initialize at line 29 of Mouse/Meta/Module.pm, avg 53µs/call | ||||
| 10 | 63 | 206µs | my $class = shift; | ||
| 11 | |||||
| 12 | my %args = @_; | ||||
| 13 | |||||
| 14 | $args{methods} = {}; | ||||
| 15 | $args{attributes} = {}; | ||||
| 16 | $args{required_methods} = []; | ||||
| 17 | $args{roles} = []; | ||||
| 18 | |||||
| 19 | my $self = bless \%args, ref($class) || $class; | ||||
| 20 | 1 | 38µs | 10 | 257µs | if($class ne __PACKAGE__){ # spent 108µs making 3 calls to Mouse::Meta::Class::_initialize_object, avg 36µs/call
# spent 83µs making 3 calls to Mouse::Util::meta, avg 28µs/call
# spent 58µs making 1 call to Mouse::Meta::Class::_calculate_all_attributes
# spent 3µs making 1 call to Mouse::Meta::Class::strict_constructor
# spent 3µs making 1 call to Mouse::Meta::Class::is_anon_class
# spent 2µs making 1 call to Mouse::Meta::Class::is_immutable |
| 21 | $self->meta->_initialize_object($self, \%args); | ||||
| 22 | } | ||||
| 23 | return $self; | ||||
| 24 | } | ||||
| 25 | |||||
| 26 | # spent 658µs (30+627) within Mouse::Meta::Role::create_anon_role which was called 3 times, avg 219µs/call:
# 3 times (30µs+627µs) by Mouse::Meta::Role::Composite::new at line 16 of Mouse/Meta/Role/Composite.pm, avg 219µs/call | ||||
| 27 | 6 | 29µs | my $self = shift; | ||
| 28 | 3 | 627µs | return $self->create(undef, @_); # spent 627µs making 3 calls to Mouse::Meta::Module::create, avg 209µs/call | ||
| 29 | } | ||||
| 30 | |||||
| 31 | sub is_anon_role; | ||||
| 32 | |||||
| 33 | sub get_roles; | ||||
| 34 | |||||
| 35 | sub calculate_all_roles { | ||||
| 36 | my $self = shift; | ||||
| 37 | my %seen; | ||||
| 38 | return grep { !$seen{ $_->name }++ } | ||||
| 39 | ($self, map { $_->calculate_all_roles } @{ $self->get_roles }); | ||||
| 40 | } | ||||
| 41 | |||||
| 42 | # spent 22µs within Mouse::Meta::Role::get_required_method_list which was called 6 times, avg 4µs/call:
# 6 times (22µs+0s) by Mouse::Meta::Role::Application::check_required_methods at line 89 of Mouse/Meta/Role/Application.pm, avg 4µs/call | ||||
| 43 | 6 | 28µs | return @{ $_[0]->{required_methods} }; | ||
| 44 | } | ||||
| 45 | |||||
| 46 | # spent 565µs (306+259) within Mouse::Meta::Role::add_required_methods which was called 17 times, avg 33µs/call:
# 11 times (192µs+234µs) by Mouse::Role::requires at line 100 of Mouse/Role.pm, avg 39µs/call
# 6 times (114µs+25µs) by Mouse::Meta::Role::Application::check_required_methods at line 89 of Mouse/Meta/Role/Application.pm, avg 23µs/call | ||||
| 47 | 89 | 299µs | my($self, @methods) = @_; | ||
| 48 | my %required = map{ $_ => 1 } @{$self->{required_methods}}; | ||||
| 49 | 21 | 259µs | push @{$self->{required_methods}}, grep{ !$required{$_}++ && !$self->has_method($_) } @methods; # spent 234µs making 11 calls to Mouse::Meta::Module::has_method, avg 21µs/call
# spent 25µs making 10 calls to Mouse::Meta::Role::Composite::has_method, avg 3µs/call | ||
| 50 | return; | ||||
| 51 | } | ||||
| 52 | |||||
| 53 | sub requires_method { | ||||
| 54 | my($self, $name) = @_; | ||||
| 55 | return scalar( grep{ $_ eq $name } @{ $self->{required_methods} } ) != 0; | ||||
| 56 | } | ||||
| 57 | |||||
| 58 | # spent 144µs within Mouse::Meta::Role::add_attribute which was called 18 times, avg 8µs/call:
# 10 times (63µs+0s) by Mouse::Meta::Role::Composite::add_attribute at line 84 of Mouse/Meta/Role/Composite.pm, avg 6µs/call
# 8 times (81µs+0s) by Mouse::Role::has at line 44 of Mouse/Role.pm, avg 10µs/call | ||||
| 59 | 72 | 162µs | my $self = shift; | ||
| 60 | my $name = shift; | ||||
| 61 | |||||
| 62 | $self->{attributes}->{$name} = (@_ == 1) ? $_[0] : { @_ }; | ||||
| 63 | return; | ||||
| 64 | } | ||||
| 65 | |||||
| 66 | # spent 4.82ms (90µs+4.73) within Mouse::Meta::Role::apply which was called 6 times, avg 803µs/call:
# 6 times (90µs+4.73ms) by Mouse::Meta::Role::Composite::new at line 21 of Mouse/Meta/Role/Composite.pm, avg 803µs/call | ||||
| 67 | 24 | 87µs | my $self = shift; | ||
| 68 | my $consumer = shift; | ||||
| 69 | |||||
| 70 | require 'Mouse/Meta/Role/Application.pm'; | ||||
| 71 | 12 | 4.73ms | return Mouse::Meta::Role::Application->new(@_)->apply($self, $consumer); # spent 4.59ms making 6 calls to Mouse::Meta::Role::Application::apply, avg 766µs/call
# spent 136µs making 6 calls to Mouse::Meta::Role::Application::new, avg 23µs/call | ||
| 72 | } | ||||
| 73 | |||||
| 74 | # spent 7.76ms (836µs+6.92) within Mouse::Meta::Role::combine which was called 3 times, avg 2.59ms/call:
# 3 times (836µs+6.92ms) by Mouse::Util::apply_all_roles at line 310 of Mouse/Util.pm, avg 2.59ms/call | ||||
| 75 | 9 | 200µs | my($self, @role_specs) = @_; | ||
| 76 | |||||
| 77 | require 'Mouse/Meta/Role/Composite.pm'; | ||||
| 78 | 3 | 5.63ms | return Mouse::Meta::Role::Composite->new(roles => \@role_specs); # spent 5.63ms making 3 calls to Mouse::Meta::Role::Composite::new, avg 1.88ms/call | ||
| 79 | } | ||||
| 80 | |||||
| 81 | sub add_before_method_modifier; | ||||
| 82 | sub add_around_method_modifier; | ||||
| 83 | sub add_after_method_modifier; | ||||
| 84 | |||||
| 85 | sub get_before_method_modifiers; | ||||
| 86 | sub get_around_method_modifiers; | ||||
| 87 | sub get_after_method_modifiers; | ||||
| 88 | |||||
| 89 | sub add_override_method_modifier{ | ||||
| 90 | my($self, $method_name, $method) = @_; | ||||
| 91 | |||||
| 92 | if($self->has_method($method_name)){ | ||||
| 93 | # This error happens in the override keyword or during role composition, | ||||
| 94 | # so I added a message, "A local method of ...", only for compatibility (gfx) | ||||
| 95 | $self->throw_error("Cannot add an override of method '$method_name' " | ||||
| 96 | . "because there is a local version of '$method_name'" | ||||
| 97 | . "(A local method of the same name as been found)"); | ||||
| 98 | } | ||||
| 99 | |||||
| 100 | $self->{override_method_modifiers}->{$method_name} = $method; | ||||
| 101 | } | ||||
| 102 | |||||
| 103 | sub get_override_method_modifier { | ||||
| 104 | my ($self, $method_name) = @_; | ||||
| 105 | return $self->{override_method_modifiers}->{$method_name}; | ||||
| 106 | } | ||||
| 107 | |||||
| 108 | # spent 617µs (534+83) within Mouse::Meta::Role::does_role which was called 33 times, avg 19µs/call:
# 18 times (216µs+-216µs) by Mouse::Meta::Role::does_role at line 120, avg 0s/call
# 9 times (178µs+206µs) by Mouse::Meta::Class::does_role at line 455 of Mouse/Meta/Class.pm, avg 43µs/call
# 6 times (140µs+93µs) by Mouse::Meta::Role::Application::_append_roles at line 194 of Mouse/Meta/Role/Application.pm, avg 39µs/call | ||||
| 109 | 189 | 626µs | my ($self, $role_name) = @_; | ||
| 110 | |||||
| 111 | (defined $role_name) | ||||
| 112 | || $self->throw_error("You must supply a role name to look for"); | ||||
| 113 | |||||
| 114 | 6 | 9µs | $role_name = $role_name->name if ref $role_name; # spent 9µs making 6 calls to Mouse::Meta::Module::name, avg 1µs/call | ||
| 115 | |||||
| 116 | # if we are it,.. then return true | ||||
| 117 | 33 | 42µs | return 1 if $role_name eq $self->name; # spent 42µs making 33 calls to Mouse::Meta::Module::name, avg 1µs/call | ||
| 118 | # otherwise.. check our children | ||||
| 119 | 24 | 31µs | for my $role (@{ $self->get_roles }) { # spent 31µs making 24 calls to Mouse::Meta::Role::get_roles, avg 1µs/call | ||
| 120 | 18 | 0s | return 1 if $role->does_role($role_name); # spent 251µs making 18 calls to Mouse::Meta::Role::does_role, avg 14µs/call, recursion: max depth 1, sum of overlapping time 251µs | ||
| 121 | } | ||||
| 122 | return 0; | ||||
| 123 | } | ||||
| 124 | |||||
| 125 | 1 | 3µs | 1; | ||
| 126 | __END__ | ||||
# spent 45µs within Mouse::Meta::Role::get_roles which was called 33 times, avg 1µs/call:
# 24 times (31µs+0s) by Mouse::Meta::Role::does_role at line 119, avg 1µs/call
# 9 times (13µs+0s) by Mouse::Meta::Role::Application::_append_roles at line 193 of Mouse/Meta/Role/Application.pm, avg 1µs/call |