| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint/Parameterizable.pm |
| Statements | Executed 94 statements in 506µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 7 | 1 | 1 | 56µs | 597µs | Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for |
| 9 | 1 | 1 | 51µs | 230µs | Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for (recurses: max depth 1, inclusive time 86µs) |
| 2 | 1 | 1 | 46µs | 1.44ms | Moose::Meta::TypeConstraint::Parameterizable::parameterize (recurses: max depth 1, inclusive time 758µs) |
| 1 | 1 | 1 | 10µs | 11µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 |
| 1 | 1 | 1 | 7µs | 25µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 |
| 2 | 1 | 1 | 7µs | 841µs | Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter (recurses: max depth 1, inclusive time 27µs) |
| 1 | 1 | 1 | 7µs | 158µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 |
| 1 | 1 | 1 | 6µs | 24µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 |
| 1 | 1 | 1 | 4µs | 4µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 |
| 1 | 1 | 1 | 4µs | 8µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 |
| 1 | 1 | 1 | 4µs | 260µs | Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 |
| 1 | 1 | 1 | 2µs | 2µ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 | 300ns | our $VERSION = '2.1605'; | ||
| 3 | |||||
| 4 | 2 | 14µs | 2 | 13µs | # spent 11µs (10+2) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4 which was called:
# once (10µs+2µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 4 # spent 11µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@4
# spent 2µs making 1 call to strict::import |
| 5 | 2 | 12µs | 2 | 12µs | # spent 8µs (4+4) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5 which was called:
# once (4µs+4µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 5 # spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@5
# spent 4µs making 1 call to warnings::import |
| 6 | 2 | 21µs | 2 | 516µs | # spent 260µs (4+256) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6 which was called:
# once (4µs+256µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 6 # spent 260µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@6
# spent 256µs making 1 call to metaclass::import |
| 7 | |||||
| 8 | 2 | 16µs | 2 | 42µs | # spent 24µs (6+18) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8 which was called:
# once (6µs+18µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 8 # spent 24µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@8
# spent 18µs making 1 call to parent::import |
| 9 | 2 | 14µs | 1 | 4µs | # spent 4µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 which was called:
# once (4µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 9 # spent 4µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 |
| 10 | 2 | 12µs | 1 | 2µs | # spent 2µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 which was called:
# once (2µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 10 # spent 2µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 |
| 11 | |||||
| 12 | 2 | 23µs | 2 | 309µs | # spent 158µs (7+151) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12 which was called:
# once (7µs+151µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 12 # spent 158µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@12
# spent 151µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
| 13 | |||||
| 14 | 2 | 259µs | 2 | 42µs | # spent 25µs (7+18) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 which was called:
# once (7µs+18µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 at line 14 # spent 25µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14
# spent 18µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 1 | 4µs | 3 | 454µs | __PACKAGE__->meta->add_attribute('constraint_generator' => ( # spent 435µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 14µ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 | 305µs | __PACKAGE__->meta->add_attribute('inline_generator' => ( # spent 295µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 6µ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 597µs (56+541) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 7 times, avg 85µs/call:
# 7 times (56µs+541µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 55 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 85µs/call | ||||
| 29 | 7 | 1µs | my ($self, $type) = @_; | ||
| 30 | |||||
| 31 | 7 | 7µs | 7 | 7µs | return unless $self->has_constraint_generator; # spent 7µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 1µs/call |
| 32 | |||||
| 33 | 7 | 18µs | 20 | 531µs | return $self->constraint_generator->($type->type_parameter) # spent 508µs making 7 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 73µs/call
# spent 8µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:251]
# spent 7µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:284]
# spent 5µs making 7 calls to Moose::Meta::TypeConstraint::name, avg 686ns/call
# spent 2µs making 2 calls to Moose::Meta::TypeConstraint::Parameterizable::constraint_generator, avg 1µs/call
# spent 1µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 600ns/call |
| 34 | if $type->is_subtype_of($self->name); | ||||
| 35 | |||||
| 36 | 5 | 4µs | 5 | 3µs | return $self->_can_coerce_constraint_from($type) # spent 3µs making 5 calls to Moose::Meta::TypeConstraint::has_coercion, avg 580ns/call |
| 37 | if $self->has_coercion | ||||
| 38 | && $self->coercion->has_coercion_for_type($type->parent->name); | ||||
| 39 | |||||
| 40 | 5 | 7µ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 230µs (51+178) within Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for which was called 9 times, avg 26µs/call:
# 9 times (51µs+178µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 95 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 26µs/call | ||||
| 54 | 9 | 2µs | my ($self, $type, $val) = @_; | ||
| 55 | |||||
| 56 | 9 | 5µs | 9 | 3µs | throw_exception( CannotGenerateInlineConstraint => parameterizable_type_object_name => $self->name, # spent 3µs making 9 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 344ns/call |
| 57 | type_name => $type->name, | ||||
| 58 | value => $val, | ||||
| 59 | ) | ||||
| 60 | unless $self->has_inline_generator; | ||||
| 61 | |||||
| 62 | 9 | 28µs | 18 | 261µs | return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )'; # spent 168µs making 4 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:292], avg 42µs/call
# spent 88µs making 5 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:266], avg 18µs/call
# spent 5µs making 9 calls to Moose::Meta::TypeConstraint::Parameterizable::inline_generator, avg 578ns/call |
| 63 | } | ||||
| 64 | |||||
| 65 | # spent 841µs (7+834) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 2 times, avg 421µs/call:
# 2 times (7µs+834µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 73, avg 421µs/call | ||||
| 66 | 2 | 500ns | my ($self, $type_parameter) = @_; | ||
| 67 | 2 | 7µs | 2 | 0s | return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter); # spent 861µs making 2 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 431µs/call, recursion: max depth 2, sum of overlapping time 861µs |
| 68 | } | ||||
| 69 | |||||
| 70 | # spent 1.44ms (46µs+1.40) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 2 times, avg 721µs/call:
# 2 times (46µs+1.40ms) by Moose::Util::TypeConstraints::_create_parameterized_type_constraint at line 133 of Moose/Util/TypeConstraints.pm, avg 721µs/call | ||||
| 71 | 2 | 2µs | my ($self, $type_parameter) = @_; | ||
| 72 | |||||
| 73 | 2 | 3µs | 2 | 841µs | my $contained_tc = $self->_parse_type_parameter($type_parameter); # spent 868µs making 2 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 434µs/call, recursion: max depth 1, sum of overlapping time 27µs |
| 74 | |||||
| 75 | ## The type parameter should be a subtype of the parent's type parameter | ||||
| 76 | ## if there is one. | ||||
| 77 | |||||
| 78 | 2 | 18µs | 6 | 6µs | if(my $parent = $self->parent) { # spent 3µs making 2 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call
# spent 3µs making 2 calls to UNIVERSAL::can, avg 1µs/call
# spent 600ns making 2 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 300ns/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 | 4µs | 2 | 900ns | if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) { # spent 900ns making 2 calls to UNIVERSAL::isa, avg 450ns/call |
| 89 | 2 | 5µs | 4 | 4µs | my $tc_name = $self->name . '[' . $contained_tc->name . ']'; # spent 4µs making 4 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call |
| 90 | 2 | 8µs | 2 | 1.27ms | return Moose::Meta::TypeConstraint::Parameterized->new( # spent 1.27ms making 2 calls to Moose::Meta::TypeConstraint::new, avg 637µ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 | 8µs | 1; | ||
| 104 | |||||
| 105 | # ABSTRACT: Type constraints which can take a parameter (ArrayRef) | ||||
| 106 | |||||
| 107 | __END__ |