Filename | /Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint/Parameterized.pm |
Statements | Executed 112 statements in 1.15ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 674µs | 2.55ms | BEGIN@10 | Moose::Meta::TypeConstraint::Parameterized::
16 | 4 | 3 | 221µs | 577µs | can_be_inlined | Moose::Meta::TypeConstraint::Parameterized::
10 | 3 | 3 | 192µs | 518µs | inline_environment | Moose::Meta::TypeConstraint::Parameterized::
2 | 1 | 1 | 109µs | 2.14ms | compile_type_constraint | Moose::Meta::TypeConstraint::Parameterized::
6 | 2 | 2 | 73µs | 704µs | _inline_check | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 15µs | 30µs | BEGIN@4 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 10µs | 40µs | BEGIN@13 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 10µs | 185µs | BEGIN@11 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 10µs | 41µs | BEGIN@8 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 9µs | 9µs | BEGIN@9 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 9µs | 14µs | BEGIN@5 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 8µs | 495µs | BEGIN@6 | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | create_child_type | Moose::Meta::TypeConstraint::Parameterized::
0 | 0 | 0 | 0s | 0s | equals | 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.1403'; | ||
3 | |||||
4 | 2 | 26µs | 2 | 45µs | # spent 30µs (15+15) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@4 which was called:
# once (15µs+15µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 4 # spent 30µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@4
# spent 15µs making 1 call to strict::import |
5 | 2 | 22µ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 | 28µs | 2 | 982µs | # spent 495µs (8+487) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@6 which was called:
# once (8µs+487µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 6 # spent 495µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@6
# spent 487µs making 1 call to metaclass::import |
7 | |||||
8 | 2 | 26µs | 2 | 72µs | # spent 41µs (10+31) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@8 which was called:
# once (10µs+31µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 8 # spent 41µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@8
# spent 31µs making 1 call to Exporter::import |
9 | 2 | 26µs | 1 | 9µs | # spent 9µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 which was called:
# once (9µs+0s) by Moose::Util::TypeConstraints::BEGIN@26 at line 9 # spent 9µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 |
10 | 2 | 138µs | 1 | 2.55ms | # spent 2.55ms (674µs+1.87) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 which was called:
# once (674µs+1.87ms) by Moose::Util::TypeConstraints::BEGIN@26 at line 10 # spent 2.55ms making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 |
11 | 2 | 33µs | 2 | 359µs | # spent 185µs (10+175) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 which was called:
# once (10µs+175µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 11 # spent 185µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@11
# spent 175µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
12 | |||||
13 | 2 | 407µs | 2 | 70µs | # spent 40µs (10+30) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@13 which was called:
# once (10µs+30µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 13 # spent 40µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@13
# spent 30µs making 1 call to parent::import |
14 | |||||
15 | 1 | 6µs | 3 | 576µs | __PACKAGE__->meta->add_attribute('type_parameter' => ( # spent 551µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 19µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 6µ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 | 4µs | 3 | 472µs | __PACKAGE__->meta->add_attribute('parameterized_from' => ( # spent 456µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 10µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 5µ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 | sub equals { | ||||
28 | my ( $self, $type_or_name ) = @_; | ||||
29 | |||||
30 | my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name); | ||||
31 | |||||
32 | return unless $other->isa(__PACKAGE__); | ||||
33 | |||||
34 | return ( | ||||
35 | $self->type_parameter->equals( $other->type_parameter ) | ||||
36 | and | ||||
37 | $self->parent->equals( $other->parent ) | ||||
38 | ); | ||||
39 | } | ||||
40 | |||||
41 | # spent 2.14ms (109µs+2.03) within Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint which was called 2 times, avg 1.07ms/call:
# 2 times (109µs+2.03ms) by Moose::Meta::TypeConstraint::new at line 125 of Moose/Meta/TypeConstraint.pm, avg 1.07ms/call | ||||
42 | 10 | 34µs | my $self = shift; | ||
43 | |||||
44 | 2 | 5µs | unless ( $self->has_type_parameter ) { # spent 5µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 3µs/call | ||
45 | throw_exception( CannotCreateHigherOrderTypeWithoutATypeParameter => type_name => $self->name ); | ||||
46 | } | ||||
47 | |||||
48 | 2 | 5µs | my $type_parameter = $self->type_parameter; # spent 5µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 3µs/call | ||
49 | |||||
50 | 4 | 5µs | unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { # spent 3µs making 2 calls to Scalar::Util::blessed, avg 2µs/call
# spent 2µs making 2 calls to UNIVERSAL::isa, avg 750ns/call | ||
51 | throw_exception( TypeParameterMustBeMooseMetaType => type_name => $self->name ); | ||||
52 | } | ||||
53 | |||||
54 | 2 | 4µs | foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { # spent 4µs making 2 calls to Moose::Util::TypeConstraints::get_all_parameterizable_types, avg 2µs/call | ||
55 | 12 | 52µs | 8 | 1.23ms | if (my $constraint = $type->generate_constraint_for($self)) { # spent 1.23ms making 8 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for, avg 154µs/call |
56 | 2 | 5µs | $self->_set_constraint($constraint); # spent 5µs making 2 calls to Moose::Meta::TypeConstraint::_set_constraint, avg 3µs/call | ||
57 | 2 | 779µs | return $self->SUPER::compile_type_constraint; # spent 779µs making 2 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 390µ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 577µs (221+356) within Moose::Meta::TypeConstraint::Parameterized::can_be_inlined which was called 16 times, avg 36µs/call:
# 6 times (59µs+95µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 93, avg 26µs/call
# 4 times (65µs+125µs) by Moose::Meta::Attribute::_eval_environment at line 766 of Moose/Meta/Attribute.pm, avg 48µs/call
# 4 times (63µs+94µs) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 39µs/call
# 2 times (34µs+43µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 285 of Moose/Meta/TypeConstraint.pm, avg 38µs/call | ||||
69 | 32 | 166µs | my $self = shift; | ||
70 | |||||
71 | return | ||||
72 | 80 | 356µs | $self->has_parameterized_from # spent 221µs making 16 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 14µs/call
# spent 38µs making 16 calls to Moose::Meta::TypeConstraint::Parameterized::has_parameterized_from, avg 2µs/call
# spent 34µs making 16 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 2µs/call
# spent 32µs making 16 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 2µs/call
# spent 32µs making 16 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 2µs/call | ||
73 | && $self->parameterized_from->has_inline_generator | ||||
74 | && $self->type_parameter->can_be_inlined; | ||||
75 | } | ||||
76 | |||||
77 | # spent 518µs (192+326) within Moose::Meta::TypeConstraint::Parameterized::inline_environment which was called 10 times, avg 52µs/call:
# 4 times (84µs+139µs) by Moose::Meta::Class::_eval_environment at line 535 of Moose/Meta/Class.pm, avg 56µs/call
# 4 times (71µs+132µs) by Moose::Meta::Attribute::_eval_environment at line 777 of Moose/Meta/Attribute.pm, avg 51µs/call
# 2 times (36µs+55µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 285 of Moose/Meta/TypeConstraint.pm, avg 46µs/call | ||||
78 | 20 | 125µ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 | 60 | 326µs | ? (%{ $self->type_parameter->inline_environment }) # spent 255µs making 20 calls to Moose::Meta::TypeConstraint::inline_environment, avg 13µs/call
# spent 23µs making 10 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 2µs/call
# spent 18µs making 10 calls to Moose::Meta::TypeConstraint::Parameterized::has_parameterized_from, avg 2µs/call
# spent 16µs making 10 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 2µs/call
# spent 15µs making 10 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 2µs/call | ||
86 | : ()), | ||||
87 | }; | ||||
88 | } | ||||
89 | |||||
90 | # spent 704µs (73+631) within Moose::Meta::TypeConstraint::Parameterized::_inline_check which was called 6 times, avg 117µs/call:
# 4 times (46µs+390µs) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 109µs/call
# 2 times (27µs+241µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 285 of Moose/Meta/TypeConstraint.pm, avg 134µs/call | ||||
91 | 18 | 47µs | my $self = shift; | ||
92 | |||||
93 | 6 | 153µs | return unless $self->can_be_inlined; # spent 153µs making 6 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 26µs/call | ||
94 | |||||
95 | 18 | 478µs | return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ ); # spent 462µs making 6 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for, avg 77µs/call
# spent 8µs making 6 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 1µs/call
# spent 8µs making 6 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/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 | 9µs | 1; | ||
104 | |||||
105 | # ABSTRACT: Type constraints with a bound parameter (ArrayRef[Int]) | ||||
106 | |||||
107 | __END__ |