| Filename | /home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint/Parameterizable.pm |
| Statements | Executed 135 statements in 3.91ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 14 | 1 | 1 | 1.13ms | 19.5ms | Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for |
| 6 | 1 | 1 | 918µs | 31.4ms | Moose::Meta::TypeConstraint::Parameterizable::parameterize |
| 6 | 1 | 1 | 202µs | 2.45ms | Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter |
| 1 | 1 | 1 | 76µs | 94µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@3 |
| 1 | 1 | 1 | 42µs | 317µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 |
| 1 | 1 | 1 | 39µs | 39µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 |
| 1 | 1 | 1 | 37µs | 105µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 |
| 1 | 1 | 1 | 37µs | 3.06ms | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 |
| 1 | 1 | 1 | 19µs | 19µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Parameterizable::__ANON__[:42] |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Parameterizable::_can_coerce_constraint_from |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Moose::Meta::TypeConstraint::Parameterizable; | ||||
| 2 | |||||
| 3 | 3 | 113µs | 2 | 112µs | # spent 94µs (76+18) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@3 which was called:
# once (76µs+18µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 3 # spent 94µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@3
# spent 18µs making 1 call to strict::import |
| 4 | 3 | 103µs | 2 | 172µs | # spent 105µs (37+67) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 which was called:
# once (37µs+67µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 4 # spent 105µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4
# spent 68µs making 1 call to warnings::import |
| 5 | 3 | 254µs | 2 | 6.08ms | # spent 3.06ms (37µs+3.02) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 which was called:
# once (37µs+3.02ms) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 5 # spent 3.06ms making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5
# spent 3.02ms making 1 call to metaclass::import |
| 6 | |||||
| 7 | 1 | 7µs | our $VERSION = '1.19'; | ||
| 8 | 1 | 82µs | $VERSION = eval $VERSION; # spent 11µs executing statements in string eval | ||
| 9 | 1 | 3µs | our $AUTHORITY = 'cpan:STEVAN'; | ||
| 10 | |||||
| 11 | 3 | 120µs | 2 | 591µs | # spent 317µs (42+275) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 which was called:
# once (42µs+275µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 11 # spent 317µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11
# spent 275µs making 1 call to base::import |
| 12 | 3 | 100µs | 1 | 39µs | # spent 39µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 which was called:
# once (39µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 12 # spent 39µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 |
| 13 | 3 | 1.22ms | 1 | 19µs | # spent 19µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 which was called:
# once (19µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 at line 13 # spent 19µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 |
| 14 | |||||
| 15 | 1 | 27µs | 2 | 3.34ms | __PACKAGE__->meta->add_attribute('constraint_generator' => ( # spent 3.22ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 124µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta |
| 16 | accessor => 'constraint_generator', | ||||
| 17 | predicate => 'has_constraint_generator', | ||||
| 18 | )); | ||||
| 19 | |||||
| 20 | # spent 19.5ms (1.13+18.3) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 14 times, avg 1.39ms/call:
# 14 times (1.13ms+18.3ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 52 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 1.39ms/call | ||||
| 21 | 14 | 49µs | my ($self, $type) = @_; | ||
| 22 | |||||
| 23 | 14 | 144µs | 14 | 176µs | return unless $self->has_constraint_generator; # spent 176µs making 14 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 13µs/call |
| 24 | |||||
| 25 | 14 | 503µs | 46 | 18.0ms | return $self->constraint_generator->($type->type_parameter) # spent 16.5ms making 14 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 1.18ms/call
# spent 779µs making 4 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:807], avg 195µs/call
# spent 410µs making 2 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:828], avg 205µs/call
# spent 179µs making 14 calls to Moose::Meta::TypeConstraint::name, avg 13µs/call
# spent 76µs making 6 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 13µs/call
# spent 76µs making 6 calls to Moose::Meta::TypeConstraint::Parameterizable::constraint_generator, avg 13µs/call |
| 26 | if $type->is_subtype_of($self->name); | ||||
| 27 | |||||
| 28 | 8 | 104µs | 8 | 101µs | return $self->_can_coerce_constraint_from($type) # spent 101µs making 8 calls to Moose::Meta::TypeConstraint::has_coercion, avg 13µs/call |
| 29 | if $self->has_coercion | ||||
| 30 | && $self->coercion->has_coercion_for_type($type->parent->name); | ||||
| 31 | |||||
| 32 | 8 | 104µs | return; | ||
| 33 | } | ||||
| 34 | |||||
| 35 | sub _can_coerce_constraint_from { | ||||
| 36 | my ($self, $type) = @_; | ||||
| 37 | my $coercion = $self->coercion; | ||||
| 38 | my $constraint = $self->constraint_generator->($type->type_parameter); | ||||
| 39 | return sub { | ||||
| 40 | local $_ = $coercion->coerce($_); | ||||
| 41 | $constraint->(@_); | ||||
| 42 | }; | ||||
| 43 | } | ||||
| 44 | |||||
| 45 | # spent 2.45ms (202µs+2.25) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 6 times, avg 409µs/call:
# 6 times (202µs+2.25ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 53, avg 409µs/call | ||||
| 46 | 6 | 17µs | my ($self, $type_parameter) = @_; | ||
| 47 | 6 | 112µs | 6 | 2.25ms | return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter); # spent 2.25ms making 6 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 375µs/call |
| 48 | } | ||||
| 49 | |||||
| 50 | # spent 31.4ms (918µs+30.5) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 6 times, avg 5.23ms/call:
# 6 times (918µs+30.5ms) by MooseX::Types::create_arged_type_constraint at line 430 of MooseX/Types.pm, avg 5.23ms/call | ||||
| 51 | 6 | 24µs | my ($self, $type_parameter) = @_; | ||
| 52 | |||||
| 53 | 6 | 77µs | 6 | 2.45ms | my $contained_tc = $self->_parse_type_parameter($type_parameter); # spent 2.45ms making 6 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 409µs/call |
| 54 | |||||
| 55 | ## The type parameter should be a subtype of the parent's type parameter | ||||
| 56 | ## if there is one. | ||||
| 57 | |||||
| 58 | 6 | 145µs | 12 | 128µs | if(my $parent = $self->parent) { # spent 81µs making 6 calls to Moose::Meta::TypeConstraint::parent, avg 14µs/call
# spent 47µs making 6 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call |
| 59 | 6 | 146µs | 6 | 49µs | if($parent->can('type_parameter')) { # spent 49µs making 6 calls to UNIVERSAL::can, avg 8µs/call |
| 60 | unless ( $contained_tc->is_a_type_of($parent->type_parameter) ) { | ||||
| 61 | require Moose; | ||||
| 62 | Moose->throw_error("$type_parameter is not a subtype of ".$parent->type_parameter); | ||||
| 63 | } | ||||
| 64 | } | ||||
| 65 | } | ||||
| 66 | |||||
| 67 | 6 | 62µs | 6 | 484µs | if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) { # spent 484µs making 6 calls to MooseX::Types::TypeDecorator::isa, avg 81µs/call |
| 68 | 6 | 183µs | 12 | 914µs | my $tc_name = $self->name . '[' . $contained_tc->name . ']'; # spent 840µs making 6 calls to MooseX::Types::TypeDecorator::AUTOLOAD, avg 140µs/call
# spent 74µs making 6 calls to Moose::Meta::TypeConstraint::name, avg 12µs/call |
| 69 | 6 | 186µs | 6 | 26.4ms | return Moose::Meta::TypeConstraint::Parameterized->new( # spent 26.4ms making 6 calls to Moose::Meta::TypeConstraint::new, avg 4.40ms/call |
| 70 | name => $tc_name, | ||||
| 71 | parent => $self, | ||||
| 72 | type_parameter => $contained_tc, | ||||
| 73 | ); | ||||
| 74 | } | ||||
| 75 | else { | ||||
| 76 | require Moose; | ||||
| 77 | Moose->throw_error("The type parameter must be a Moose meta type"); | ||||
| 78 | } | ||||
| 79 | } | ||||
| 80 | |||||
| 81 | |||||
| 82 | 1 | 24µs | 1; | ||
| 83 | |||||
| 84 | __END__ |