| Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint/Parameterizable.pm |
| Statements | Executed 90 statements in 820µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 8 | 1 | 1 | 125µs | 1.23ms | Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for |
| 2 | 1 | 1 | 74µs | 2.66ms | Moose::Meta::TypeConstraint::Parameterizable::parameterize |
| 6 | 1 | 1 | 71µs | 462µs | Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for |
| 1 | 1 | 1 | 14µs | 28µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 |
| 1 | 1 | 1 | 13µs | 37µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 |
| 2 | 1 | 1 | 10µs | 92µs | Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter |
| 1 | 1 | 1 | 8µs | 34µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 |
| 1 | 1 | 1 | 8µs | 12µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 |
| 1 | 1 | 1 | 8µs | 186µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 |
| 1 | 1 | 1 | 8µs | 8µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 |
| 1 | 1 | 1 | 7µs | 435µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 |
| 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 | 600ns | our $VERSION = '2.1403'; | ||
| 3 | |||||
| 4 | 2 | 24µs | 2 | 42µs | # spent 28µs (14+14) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 which was called:
# once (14µs+14µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 4 # spent 28µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4
# spent 14µs making 1 call to strict::import |
| 5 | 2 | 26µ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 | 26µs | 2 | 862µs | # spent 435µs (7+428) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 which was called:
# once (7µs+428µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 6 # spent 435µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6
# spent 428µs making 1 call to metaclass::import |
| 7 | |||||
| 8 | 2 | 28µs | 2 | 60µs | # spent 34µs (8+26) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 which was called:
# once (8µs+26µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 8 # spent 34µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8
# spent 26µs making 1 call to parent::import |
| 9 | 2 | 26µs | 1 | 8µs | # spent 8µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 which was called:
# once (8µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 9 # spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 |
| 10 | 2 | 20µ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 | 28µs | 2 | 364µs | # spent 186µs (8+178) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 which was called:
# once (8µs+178µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 12 # spent 186µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12
# spent 178µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 13 | |||||
| 14 | 2 | 404µs | 2 | 61µs | # spent 37µs (13+24) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 which was called:
# once (13µs+24µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 14 # spent 37µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14
# spent 24µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 1 | 7µs | 3 | 607µs | __PACKAGE__->meta->add_attribute('constraint_generator' => ( # spent 583µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 18µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta
# spent 7µ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 | 5µs | 3 | 523µs | __PACKAGE__->meta->add_attribute('inline_generator' => ( # spent 506µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta
# spent 6µ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 1.23ms (125µs+1.11) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 8 times, avg 154µs/call:
# 8 times (125µs+1.11ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 55 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 154µs/call | ||||
| 29 | 36 | 80µs | my ($self, $type) = @_; | ||
| 30 | |||||
| 31 | 8 | 16µs | return unless $self->has_constraint_generator; # spent 16µs making 8 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 2µs/call | ||
| 32 | |||||
| 33 | 22 | 1.08ms | return $self->constraint_generator->($type->type_parameter) # spent 1.03ms making 8 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 128µs/call
# spent 27µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:284], avg 13µs/call
# spent 15µs making 8 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call
# spent 6µs making 2 calls to Moose::Meta::TypeConstraint::Parameterizable::constraint_generator, avg 3µs/call
# spent 3µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 2µs/call | ||
| 34 | if $type->is_subtype_of($self->name); | ||||
| 35 | |||||
| 36 | 6 | 12µs | return $self->_can_coerce_constraint_from($type) # spent 12µs making 6 calls to Moose::Meta::TypeConstraint::has_coercion, avg 2µs/call | ||
| 37 | if $self->has_coercion | ||||
| 38 | && $self->coercion->has_coercion_for_type($type->parent->name); | ||||
| 39 | |||||
| 40 | 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 462µs (71+391) within Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for which was called 6 times, avg 77µs/call:
# 6 times (71µs+391µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 95 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 77µs/call | ||||
| 54 | 18 | 56µs | my ($self, $type, $val) = @_; | ||
| 55 | |||||
| 56 | 6 | 8µs | throw_exception( CannotGenerateInlineConstraint => parameterizable_type_object_name => $self->name, # spent 8µs making 6 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 1µs/call | ||
| 57 | type_name => $type->name, | ||||
| 58 | value => $val, | ||||
| 59 | ) | ||||
| 60 | unless $self->has_inline_generator; | ||||
| 61 | |||||
| 62 | 12 | 383µs | return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )'; # spent 368µs making 6 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:292], avg 61µs/call
# spent 16µs making 6 calls to Moose::Meta::TypeConstraint::Parameterizable::inline_generator, avg 3µs/call | ||
| 63 | } | ||||
| 64 | |||||
| 65 | # spent 92µs (10+81) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 2 times, avg 46µs/call:
# 2 times (10µs+81µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 73, avg 46µs/call | ||||
| 66 | 4 | 13µs | my ($self, $type_parameter) = @_; | ||
| 67 | 2 | 0s | return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter); # spent 81µs making 2 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 41µs/call, recursion: max depth 1, sum of overlapping time 81µs | ||
| 68 | } | ||||
| 69 | |||||
| 70 | # spent 2.66ms (74µs+2.59) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 2 times, avg 1.33ms/call:
# 2 times (74µs+2.59ms) by Moose::Util::TypeConstraints::_create_parameterized_type_constraint at line 133 of Moose/Util/TypeConstraints.pm, avg 1.33ms/call | ||||
| 71 | 12 | 52µs | my ($self, $type_parameter) = @_; | ||
| 72 | |||||
| 73 | 2 | 92µs | my $contained_tc = $self->_parse_type_parameter($type_parameter); # spent 92µs making 2 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 46µs/call | ||
| 74 | |||||
| 75 | ## The type parameter should be a subtype of the parent's type parameter | ||||
| 76 | ## if there is one. | ||||
| 77 | |||||
| 78 | 1 | 13µs | 6 | 13µs | if(my $parent = $self->parent) { # spent 6µs making 2 calls to Moose::Meta::TypeConstraint::parent, avg 3µs/call
# spent 5µs making 2 calls to UNIVERSAL::can, avg 2µs/call
# spent 2µs making 2 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 800ns/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 | 2 | 2µs | if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) { # spent 2µs making 2 calls to UNIVERSAL::isa, avg 1µs/call | ||
| 89 | 4 | 9µs | my $tc_name = $self->name . '[' . $contained_tc->name . ']'; # spent 9µs making 4 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call | ||
| 90 | 2 | 2.47ms | return Moose::Meta::TypeConstraint::Parameterized->new( # spent 2.47ms making 2 calls to Moose::Meta::TypeConstraint::new, avg 1.24ms/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 | 10µs | 1; | ||
| 104 | |||||
| 105 | # ABSTRACT: Type constraints which can take a parameter (ArrayRef) | ||||
| 106 | |||||
| 107 | __END__ |