| Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint/Parameterizable.pm |
| Statements | Executed 272 statements in 5.28ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 7 | 1 | 1 | 4.29ms | 10.8ms | Moose::Meta::TypeConstraint::Parameterizable::parameterize |
| 40 | 1 | 1 | 376µs | 2.54ms | Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for |
| 18 | 1 | 1 | 200µs | 2.18ms | Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for |
| 7 | 1 | 1 | 27µs | 950µs | Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter |
| 1 | 1 | 1 | 10µs | 22µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 |
| 1 | 1 | 1 | 8µs | 12µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 |
| 1 | 1 | 1 | 7µs | 31µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 |
| 1 | 1 | 1 | 7µs | 31µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 |
| 1 | 1 | 1 | 6µs | 6µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 |
| 1 | 1 | 1 | 6µs | 377µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 |
| 1 | 1 | 1 | 6µs | 159µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 |
| 1 | 1 | 1 | 3µs | 3µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 |
| 0 | 0 | 0 | 0s | 0s | Moose::Meta::TypeConstraint::Parameterizable::__ANON__[:50] |
| 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 | 1 | 500ns | our $VERSION = '2.1604'; | ||
| 3 | |||||
| 4 | 2 | 27µs | 2 | 34µs | # spent 22µs (10+12) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 which was called:
# once (10µs+12µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 4 # spent 22µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4
# spent 12µs making 1 call to strict::import |
| 5 | 2 | 19µs | 2 | 16µs | # spent 12µs (8+4) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 which was called:
# once (8µs+4µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 5 # spent 12µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5
# spent 4µs making 1 call to warnings::import |
| 6 | 2 | 27µs | 2 | 748µs | # spent 377µs (6+371) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 which was called:
# once (6µs+371µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 6 # spent 377µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6
# spent 371µs making 1 call to metaclass::import |
| 7 | |||||
| 8 | 2 | 22µs | 2 | 55µs | # spent 31µs (7+24) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 which was called:
# once (7µs+24µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 8 # spent 31µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8
# spent 24µs making 1 call to parent::import |
| 9 | 2 | 21µs | 1 | 6µs | # spent 6µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 which was called:
# once (6µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 9 # spent 6µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 |
| 10 | 2 | 18µs | 1 | 3µs | # spent 3µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 which was called:
# once (3µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 10 # spent 3µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 |
| 11 | |||||
| 12 | 2 | 25µs | 2 | 313µs | # spent 159µs (6+153) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 which was called:
# once (6µs+153µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 12 # spent 159µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12
# spent 153µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 13 | |||||
| 14 | 2 | 374µs | 2 | 55µs | # spent 31µs (7+24) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 which was called:
# once (7µs+24µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 14 # spent 31µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14
# spent 24µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 1 | 6µs | 3 | 499µs | __PACKAGE__->meta->add_attribute('constraint_generator' => ( # spent 478µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 16µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta
# spent 6µs making 1 call to Class::MOP::_definition_context |
| 17 | accessor => 'constraint_generator', | ||||
| 18 | predicate => 'has_constraint_generator', | ||||
| 19 | Class::MOP::_definition_context(), | ||||
| 20 | )); | ||||
| 21 | |||||
| 22 | 1 | 2µs | 3 | 375µs | __PACKAGE__->meta->add_attribute('inline_generator' => ( # spent 363µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
| 23 | accessor => 'inline_generator', | ||||
| 24 | predicate => 'has_inline_generator', | ||||
| 25 | Class::MOP::_definition_context(), | ||||
| 26 | )); | ||||
| 27 | |||||
| 28 | # spent 2.18ms (200µs+1.98) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 18 times, avg 121µs/call:
# 18 times (200µs+1.98ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 55 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 121µs/call | ||||
| 29 | 18 | 5µs | my ($self, $type) = @_; | ||
| 30 | |||||
| 31 | 18 | 22µs | 18 | 26µs | return unless $self->has_constraint_generator; # spent 26µs making 18 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 1µs/call |
| 32 | |||||
| 33 | 18 | 71µs | 57 | 1.94ms | return $self->constraint_generator->($type->type_parameter) # spent 1.83ms making 18 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 102µs/call
# spent 39µs making 4 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:216], avg 10µs/call
# spent 20µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:251], avg 10µs/call
# spent 20µs making 18 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
# spent 15µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::constraint_generator, avg 2µs/call
# spent 9µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:284]
# spent 7µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call |
| 34 | if $type->is_subtype_of($self->name); | ||||
| 35 | |||||
| 36 | 11 | 14µs | 11 | 14µs | return $self->_can_coerce_constraint_from($type) # spent 14µs making 11 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call |
| 37 | if $self->has_coercion | ||||
| 38 | && $self->coercion->has_coercion_for_type($type->parent->name); | ||||
| 39 | |||||
| 40 | 11 | 20µs | return; | ||
| 41 | } | ||||
| 42 | |||||
| 43 | sub _can_coerce_constraint_from { | ||||
| 44 | my ($self, $type) = @_; | ||||
| 45 | my $coercion = $self->coercion; | ||||
| 46 | my $constraint = $self->constraint_generator->($type->type_parameter); | ||||
| 47 | return sub { | ||||
| 48 | local $_ = $coercion->coerce($_); | ||||
| 49 | $constraint->(@_); | ||||
| 50 | }; | ||||
| 51 | } | ||||
| 52 | |||||
| 53 | # spent 2.54ms (376µs+2.16) within Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for which was called 40 times, avg 63µs/call:
# 40 times (376µs+2.16ms) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 95 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 63µs/call | ||||
| 54 | 40 | 22µs | my ($self, $type, $val) = @_; | ||
| 55 | |||||
| 56 | 40 | 39µs | 40 | 30µs | throw_exception( CannotGenerateInlineConstraint => parameterizable_type_object_name => $self->name, # spent 30µs making 40 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 742ns/call |
| 57 | type_name => $type->name, | ||||
| 58 | value => $val, | ||||
| 59 | ) | ||||
| 60 | unless $self->has_inline_generator; | ||||
| 61 | |||||
| 62 | 40 | 238µs | 80 | 2.13ms | return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )'; # spent 1.10ms making 20 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:231], avg 55µs/call
# spent 822µs making 18 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:266], avg 46µs/call
# spent 119µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:292], avg 60µs/call
# spent 95µs making 40 calls to Moose::Meta::TypeConstraint::Parameterizable::inline_generator, avg 2µs/call |
| 63 | } | ||||
| 64 | |||||
| 65 | # spent 950µs (27+922) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 7 times, avg 136µs/call:
# 7 times (27µs+922µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 73, avg 136µs/call | ||||
| 66 | 7 | 2µs | my ($self, $type_parameter) = @_; | ||
| 67 | 7 | 4.15ms | 7 | 604µs | return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter); # spent 922µs making 7 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 132µs/call, recursion: max depth 1, sum of overlapping time 318µs |
| 68 | } | ||||
| 69 | |||||
| 70 | # spent 10.8ms (4.29+6.51) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 7 times, avg 1.54ms/call:
# 7 times (4.29ms+6.51ms) by Moose::Util::TypeConstraints::_create_parameterized_type_constraint at line 133 of Moose/Util/TypeConstraints.pm, avg 1.54ms/call | ||||
| 71 | 7 | 3µs | my ($self, $type_parameter) = @_; | ||
| 72 | |||||
| 73 | 7 | 14µs | 7 | 950µs | my $contained_tc = $self->_parse_type_parameter($type_parameter); # spent 950µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 136µs/call |
| 74 | |||||
| 75 | ## The type parameter should be a subtype of the parent's type parameter | ||||
| 76 | ## if there is one. | ||||
| 77 | |||||
| 78 | 7 | 45µs | 21 | 30µs | if(my $parent = $self->parent) { # spent 20µs making 7 calls to Moose::Meta::TypeConstraint::parent, avg 3µs/call
# spent 6µs making 7 calls to UNIVERSAL::can, avg 900ns/call
# spent 4µs making 7 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 514ns/call |
| 79 | if($parent->can('type_parameter')) { | ||||
| 80 | unless ( $contained_tc->is_a_type_of($parent->type_parameter) ) { | ||||
| 81 | throw_exception( ParameterIsNotSubtypeOfParent => type_parameter => $type_parameter, | ||||
| 82 | type_name => $self->name, | ||||
| 83 | ); | ||||
| 84 | } | ||||
| 85 | } | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | 7 | 25µs | 7 | 7µs | if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) { # spent 7µs making 7 calls to UNIVERSAL::isa, avg 1µs/call |
| 89 | 7 | 25µs | 14 | 24µs | my $tc_name = $self->name . '[' . $contained_tc->name . ']'; # spent 24µs making 14 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call |
| 90 | 7 | 39µs | 7 | 5.50ms | return Moose::Meta::TypeConstraint::Parameterized->new( # spent 5.50ms making 7 calls to Moose::Meta::TypeConstraint::new, avg 786µs/call |
| 91 | name => $tc_name, | ||||
| 92 | parent => $self, | ||||
| 93 | type_parameter => $contained_tc, | ||||
| 94 | parameterized_from => $self, | ||||
| 95 | ); | ||||
| 96 | } | ||||
| 97 | else { | ||||
| 98 | confess("The type parameter must be a Moose meta type"); | ||||
| 99 | } | ||||
| 100 | } | ||||
| 101 | |||||
| 102 | |||||
| 103 | 1 | 6µs | 1; | ||
| 104 | |||||
| 105 | # ABSTRACT: Type constraints which can take a parameter (ArrayRef) | ||||
| 106 | |||||
| 107 | __END__ |