Filename | /usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint/Parameterized.pm |
Statements | Executed 538 statements in 2.45ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
109 | 4 | 3 | 1.24ms | 3.39ms | can_be_inlined | Moose::Meta::TypeConstraint::Parameterized::
49 | 3 | 3 | 776µs | 2.13ms | inline_environment | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 616µs | 2.13ms | BEGIN@10 | Moose::Meta::TypeConstraint::Parameterized::
40 | 2 | 2 | 409µs | 3.92ms | _inline_check | Moose::Meta::TypeConstraint::Parameterized::
7 | 1 | 1 | 187µs | 4.96ms | compile_type_constraint | Moose::Meta::TypeConstraint::Parameterized::
5 | 1 | 1 | 64µs | 102µs | equals | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 10µs | 24µs | BEGIN@4 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 10µs | 56µs | BEGIN@8 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 9µs | 14µs | BEGIN@5 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 8µs | 8µs | BEGIN@9 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 7µs | 28µs | BEGIN@13 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 7µs | 442µs | BEGIN@6 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 160µs | BEGIN@11 | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | create_child_type | Moose::Meta::TypeConstraint::Parameterized::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::TypeConstraint::Parameterized; | ||||
2 | 1 | 600ns | our $VERSION = '2.1604'; | ||
3 | |||||
4 | 2 | 23µs | 2 | 38µs | # spent 24µs (10+14) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@4 which was called:
# once (10µs+14µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 4 # spent 24µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@4
# spent 14µs making 1 call to strict::import |
5 | 2 | 20µs | 2 | 19µs | # spent 14µs (9+5) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@5 which was called:
# once (9µs+5µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 5 # spent 14µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@5
# spent 5µs making 1 call to warnings::import |
6 | 2 | 41µs | 2 | 876µs | # spent 442µs (7+435) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@6 which was called:
# once (7µs+435µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 6 # spent 442µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@6
# spent 435µs making 1 call to metaclass::import |
7 | |||||
8 | 2 | 24µs | 2 | 102µs | # spent 56µs (10+46) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@8 which was called:
# once (10µs+46µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 8 # spent 56µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@8
# spent 46µs making 1 call to Exporter::import |
9 | 2 | 26µs | 1 | 8µs | # spent 8µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 which was called:
# once (8µs+0s) by Moose::Util::TypeConstraints::BEGIN@26 at line 9 # spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 |
10 | 2 | 125µs | 1 | 2.13ms | # spent 2.13ms (616µs+1.52) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 which was called:
# once (616µs+1.52ms) by Moose::Util::TypeConstraints::BEGIN@26 at line 10 # spent 2.13ms making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 |
11 | 2 | 27µs | 2 | 314µs | # spent 160µs (6+154) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 which was called:
# once (6µs+154µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 11 # spent 160µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@11
# spent 154µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
12 | |||||
13 | 2 | 349µs | 2 | 48µs | # spent 28µs (7+20) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@13 which was called:
# once (7µs+20µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 13 # spent 28µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@13
# spent 20µs making 1 call to parent::import |
14 | |||||
15 | 1 | 3µs | 3 | 419µs | __PACKAGE__->meta->add_attribute('type_parameter' => ( # spent 400µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 14µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
16 | accessor => 'type_parameter', | ||||
17 | predicate => 'has_type_parameter', | ||||
18 | Class::MOP::_definition_context(), | ||||
19 | )); | ||||
20 | |||||
21 | 1 | 3µs | 3 | 386µs | __PACKAGE__->meta->add_attribute('parameterized_from' => ( # spent 374µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 4µs making 1 call to Class::MOP::_definition_context |
22 | accessor => 'parameterized_from', | ||||
23 | predicate => 'has_parameterized_from', | ||||
24 | Class::MOP::_definition_context(), | ||||
25 | )); | ||||
26 | |||||
27 | # spent 102µs (64+38) within Moose::Meta::TypeConstraint::Parameterized::equals which was called 5 times, avg 20µs/call:
# 5 times (64µs+38µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 257 of Moose/Meta/TypeConstraint.pm, avg 20µs/call | ||||
28 | 5 | 2µs | my ( $self, $type_or_name ) = @_; | ||
29 | |||||
30 | 5 | 28µs | 5 | 22µs | my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name); # spent 22µs making 5 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 4µs/call |
31 | |||||
32 | 5 | 40µs | 5 | 17µs | return unless $other->isa(__PACKAGE__); # spent 17µs making 5 calls to UNIVERSAL::isa, avg 3µs/call |
33 | |||||
34 | return ( | ||||
35 | $self->type_parameter->equals( $other->type_parameter ) | ||||
36 | and | ||||
37 | $self->parent->equals( $other->parent ) | ||||
38 | ); | ||||
39 | } | ||||
40 | |||||
41 | # spent 4.96ms (187µs+4.77) within Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint which was called 7 times, avg 708µs/call:
# 7 times (187µs+4.77ms) by Moose::Meta::TypeConstraint::new at line 125 of Moose/Meta/TypeConstraint.pm, avg 708µs/call | ||||
42 | 7 | 2µs | my $self = shift; | ||
43 | |||||
44 | 7 | 14µs | 7 | 14µs | unless ( $self->has_type_parameter ) { # spent 14µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 2µs/call |
45 | throw_exception( CannotCreateHigherOrderTypeWithoutATypeParameter => type_name => $self->name ); | ||||
46 | } | ||||
47 | |||||
48 | 7 | 16µs | 7 | 17µs | my $type_parameter = $self->type_parameter; # spent 17µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 2µs/call |
49 | |||||
50 | 7 | 40µs | 14 | 10µs | unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { # spent 6µs making 7 calls to Scalar::Util::blessed, avg 929ns/call
# spent 4µs making 7 calls to UNIVERSAL::isa, avg 571ns/call |
51 | throw_exception( TypeParameterMustBeMooseMetaType => type_name => $self->name ); | ||||
52 | } | ||||
53 | |||||
54 | 7 | 15µs | 7 | 13µs | foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { # spent 13µs making 7 calls to Moose::Util::TypeConstraints::get_all_parameterizable_types, avg 2µs/call |
55 | 18 | 26µs | 18 | 2.18ms | if (my $constraint = $type->generate_constraint_for($self)) { # spent 2.18ms making 18 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for, avg 121µs/call |
56 | 7 | 12µs | 7 | 12µs | $self->_set_constraint($constraint); # spent 12µs making 7 calls to Moose::Meta::TypeConstraint::_set_constraint, avg 2µs/call |
57 | 7 | 30µs | 7 | 2.52ms | return $self->SUPER::compile_type_constraint; # spent 2.52ms making 7 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 361µs/call |
58 | } | ||||
59 | } | ||||
60 | |||||
61 | # if we get here, then we couldn't | ||||
62 | # find a way to parameterize this type | ||||
63 | throw_exception( TypeConstraintCannotBeUsedForAParameterizableType => type_name => $self->name, | ||||
64 | parent_type_name => $self->parent->name, | ||||
65 | ); | ||||
66 | } | ||||
67 | |||||
68 | # spent 3.39ms (1.24+2.15) within Moose::Meta::TypeConstraint::Parameterized::can_be_inlined which was called 109 times, avg 31µs/call:
# 40 times (336µs+561µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 93, avg 22µs/call
# 33 times (448µs+781µs) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 37µs/call
# 29 times (354µs+648µs) by Moose::Meta::Attribute::_eval_environment at line 766 of Moose/Meta/Attribute.pm, avg 35µs/call
# 7 times (98µs+162µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288 of Moose/Meta/TypeConstraint.pm, avg 37µs/call | ||||
69 | 109 | 23µs | my $self = shift; | ||
70 | |||||
71 | return | ||||
72 | 109 | 810µs | 545 | 2.15ms | $self->has_parameterized_from # spent 1.04ms making 88 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 12µs/call
# spent 504µs making 21 calls to Moose::Meta::TypeConstraint::Union::can_be_inlined, avg 24µs/call
# spent 169µs making 109 calls to Moose::Meta::TypeConstraint::Parameterized::has_parameterized_from, avg 2µs/call
# spent 155µs making 109 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 1µs/call
# spent 144µs making 109 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 1µs/call
# spent 138µs making 109 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call |
73 | && $self->parameterized_from->has_inline_generator | ||||
74 | && $self->type_parameter->can_be_inlined; | ||||
75 | } | ||||
76 | |||||
77 | # spent 2.13ms (776µs+1.35) within Moose::Meta::TypeConstraint::Parameterized::inline_environment which was called 49 times, avg 43µs/call:
# 29 times (472µs+851µs) by Moose::Meta::Attribute::_eval_environment at line 777 of Moose/Meta/Attribute.pm, avg 46µs/call
# 13 times (202µs+330µs) by Moose::Meta::Class::_eval_environment at line 535 of Moose/Meta/Class.pm, avg 41µs/call
# 7 times (102µs+171µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288 of Moose/Meta/TypeConstraint.pm, avg 39µs/call | ||||
78 | 49 | 16µs | my $self = shift; | ||
79 | |||||
80 | return { | ||||
81 | ($self->has_parameterized_from | ||||
82 | ? (%{ $self->parameterized_from->inline_environment }) | ||||
83 | : ()), | ||||
84 | ($self->has_type_parameter | ||||
85 | 49 | 479µs | 294 | 1.35ms | ? (%{ $self->type_parameter->inline_environment }) # spent 859µs making 87 calls to Moose::Meta::TypeConstraint::inline_environment, avg 10µs/call
# spent 251µs making 11 calls to Moose::Meta::TypeConstraint::Union::inline_environment, avg 23µs/call
# spent 84µs making 49 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 2µs/call
# spent 54µs making 49 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 1µs/call
# spent 53µs making 49 calls to Moose::Meta::TypeConstraint::Parameterized::has_parameterized_from, avg 1µs/call
# spent 49µs making 49 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call |
86 | : ()), | ||||
87 | }; | ||||
88 | } | ||||
89 | |||||
90 | # spent 3.92ms (409µs+3.51) within Moose::Meta::TypeConstraint::Parameterized::_inline_check which was called 40 times, avg 98µs/call:
# 33 times (339µs+2.92ms) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 99µs/call
# 7 times (70µs+592µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288 of Moose/Meta/TypeConstraint.pm, avg 94µs/call | ||||
91 | 40 | 12µs | my $self = shift; | ||
92 | |||||
93 | 40 | 43µs | 40 | 897µs | return unless $self->can_be_inlined; # spent 897µs making 40 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 22µs/call |
94 | |||||
95 | 40 | 200µs | 120 | 2.61ms | return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ ); # spent 2.54ms making 40 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for, avg 63µs/call
# spent 38µs making 40 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 960ns/call
# spent 34µs making 40 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 850ns/call |
96 | } | ||||
97 | |||||
98 | sub create_child_type { | ||||
99 | my ($self, %opts) = @_; | ||||
100 | return Moose::Meta::TypeConstraint::Parameterizable->new(%opts, parent=>$self); | ||||
101 | } | ||||
102 | |||||
103 | 1 | 5µs | 1; | ||
104 | |||||
105 | # ABSTRACT: Type constraints with a bound parameter (ArrayRef[Int]) | ||||
106 | |||||
107 | __END__ |