Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint/Parameterized.pm |
Statements | Executed 130 statements in 665µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 424µs | 1.68ms | BEGIN@10 | Moose::Meta::TypeConstraint::Parameterized::
24 | 5 | 3 | 143µs | 263µs | can_be_inlined (recurses: max depth 1, inclusive time 111µs) | Moose::Meta::TypeConstraint::Parameterized::
7 | 4 | 4 | 59µs | 128µs | inline_environment (recurses: max depth 1, inclusive time 53µs) | Moose::Meta::TypeConstraint::Parameterized::
9 | 3 | 3 | 54µs | 352µs | _inline_check (recurses: max depth 1, inclusive time 153µs) | Moose::Meta::TypeConstraint::Parameterized::
2 | 1 | 1 | 45µs | 1.15ms | compile_type_constraint | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 11µs | 14µs | BEGIN@4 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 7µs | 28µs | BEGIN@13 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 7µs | 34µs | BEGIN@8 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 139µs | BEGIN@11 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 12µs | BEGIN@5 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 408µs | BEGIN@6 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 6µs | BEGIN@9 | 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 | 300ns | our $VERSION = '2.1605'; | ||
3 | |||||
4 | 2 | 18µs | 2 | 17µs | # spent 14µs (11+3) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@4 which was called:
# once (11µs+3µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 4 # spent 14µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@4
# spent 3µs making 1 call to strict::import |
5 | 2 | 14µs | 2 | 19µs | # spent 12µs (6+7) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@5 which was called:
# once (6µs+7µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 5 # spent 12µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@5
# spent 6µs making 1 call to warnings::import |
6 | 2 | 22µs | 2 | 811µs | # spent 408µs (6+403) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@6 which was called:
# once (6µs+403µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 6 # spent 408µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@6
# spent 403µs making 1 call to metaclass::import |
7 | |||||
8 | 2 | 22µs | 2 | 60µs | # spent 34µs (7+26) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@8 which was called:
# once (7µs+26µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 8 # spent 34µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@8
# spent 26µs making 1 call to Exporter::import |
9 | 2 | 16µs | 1 | 6µs | # spent 6µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 which was called:
# once (6µs+0s) by Moose::Util::TypeConstraints::BEGIN@26 at line 9 # spent 6µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 |
10 | 2 | 92µs | 1 | 1.68ms | # spent 1.68ms (424µs+1.25) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 which was called:
# once (424µs+1.25ms) by Moose::Util::TypeConstraints::BEGIN@26 at line 10 # spent 1.68ms making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 |
11 | 2 | 23µs | 2 | 272µs | # spent 139µs (6+133) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 which was called:
# once (6µs+133µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 11 # spent 139µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@11
# spent 133µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337] |
12 | |||||
13 | 2 | 257µs | 2 | 49µs | # spent 28µs (7+21) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@13 which was called:
# once (7µs+21µs) by Moose::Util::TypeConstraints::BEGIN@26 at line 13 # spent 28µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@13
# spent 21µs making 1 call to parent::import |
14 | |||||
15 | 1 | 3µs | 3 | 329µs | __PACKAGE__->meta->add_attribute('type_parameter' => ( # spent 312µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 13µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 4µ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 | 2µs | 3 | 414µs | __PACKAGE__->meta->add_attribute('parameterized_from' => ( # spent 404µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 6µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 3µ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 1.15ms (45µs+1.10) within Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint which was called 2 times, avg 575µs/call:
# 2 times (45µs+1.10ms) by Moose::Meta::TypeConstraint::new at line 125 of Moose/Meta/TypeConstraint.pm, avg 575µs/call | ||||
42 | 2 | 400ns | my $self = shift; | ||
43 | |||||
44 | 2 | 3µs | 2 | 2µs | unless ( $self->has_type_parameter ) { # spent 2µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 850ns/call |
45 | throw_exception( CannotCreateHigherOrderTypeWithoutATypeParameter => type_name => $self->name ); | ||||
46 | } | ||||
47 | |||||
48 | 2 | 2µs | 2 | 2µs | my $type_parameter = $self->type_parameter; # spent 2µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call |
49 | |||||
50 | 2 | 8µs | 4 | 2µs | unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { # spent 1µs making 2 calls to Scalar::Util::blessed, avg 600ns/call
# spent 800ns making 2 calls to UNIVERSAL::isa, avg 400ns/call |
51 | throw_exception( TypeParameterMustBeMooseMetaType => type_name => $self->name ); | ||||
52 | } | ||||
53 | |||||
54 | 2 | 3µs | 2 | 2µs | foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { # spent 2µs making 2 calls to Moose::Util::TypeConstraints::get_all_parameterizable_types, avg 1µs/call |
55 | 7 | 6µs | 7 | 597µs | if (my $constraint = $type->generate_constraint_for($self)) { # spent 597µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for, avg 85µs/call |
56 | 2 | 4µs | 2 | 2µs | $self->_set_constraint($constraint); # spent 2µs making 2 calls to Moose::Meta::TypeConstraint::_set_constraint, avg 1µs/call |
57 | 2 | 8µs | 2 | 497µs | return $self->SUPER::compile_type_constraint; # spent 497µs making 2 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 249µ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 263µs (143+120) within Moose::Meta::TypeConstraint::Parameterized::can_be_inlined which was called 24 times, avg 11µs/call:
# 9 times (47µs+81µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 93, avg 14µs/call
# 9 times (51µs+-51µs) by Moose::Meta::TypeConstraint::Parameterized::can_be_inlined at line 72, avg 0s/call
# 3 times (21µs+45µs) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 22µs/call
# 2 times (19µs+30µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288 of Moose/Meta/TypeConstraint.pm, avg 25µs/call
# once (6µs+14µs) by Moose::Meta::Attribute::_eval_environment at line 766 of Moose/Meta/Attribute.pm | ||||
69 | 24 | 2µs | my $self = shift; | ||
70 | |||||
71 | return | ||||
72 | 24 | 83µs | 120 | 120µs | $self->has_parameterized_from # spent 74µs making 15 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 5µs/call
# spent 12µs making 24 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 521ns/call
# spent 12µs making 24 calls to Moose::Meta::TypeConstraint::Parameterized::has_parameterized_from, avg 496ns/call
# spent 11µs making 24 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 454ns/call
# spent 10µs making 24 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 425ns/call
# spent 111µs making 9 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 12µs/call, recursion: max depth 1, sum of overlapping time 111µs |
73 | && $self->parameterized_from->has_inline_generator | ||||
74 | && $self->type_parameter->can_be_inlined; | ||||
75 | } | ||||
76 | |||||
77 | # spent 128µs (59+69) within Moose::Meta::TypeConstraint::Parameterized::inline_environment which was called 7 times, avg 18µs/call:
# 3 times (21µs+-21µs) by Moose::Meta::TypeConstraint::Parameterized::inline_environment at line 85, avg 0s/call
# 2 times (22µs+42µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288 of Moose/Meta/TypeConstraint.pm, avg 32µs/call
# once (9µs+24µs) by Moose::Meta::Class::_eval_environment at line 542 of Moose/Meta/Class.pm
# once (7µs+23µs) by Moose::Meta::Attribute::_eval_environment at line 777 of Moose/Meta/Attribute.pm | ||||
78 | 7 | 1µ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 | 7 | 36µs | 42 | 69µs | ? (%{ $self->type_parameter->inline_environment }) # spent 55µs making 11 calls to Moose::Meta::TypeConstraint::inline_environment, avg 5µs/call
# spent 4µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 571ns/call
# spent 4µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 543ns/call
# spent 3µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::has_parameterized_from, avg 443ns/call
# spent 3µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 414ns/call
# spent 53µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 18µs/call, recursion: max depth 1, sum of overlapping time 53µs |
86 | : ()), | ||||
87 | }; | ||||
88 | } | ||||
89 | |||||
90 | # spent 352µs (54+298) within Moose::Meta::TypeConstraint::Parameterized::_inline_check which was called 9 times, avg 39µs/call:
# 4 times (21µs+-21µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Util/TypeConstraints/Builtins.pm:292] at line 290 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call
# 3 times (18µs+188µs) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 69µs/call
# 2 times (15µs+130µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288 of Moose/Meta/TypeConstraint.pm, avg 73µs/call | ||||
91 | 9 | 1µs | my $self = shift; | ||
92 | |||||
93 | 9 | 6µs | 9 | 128µs | return unless $self->can_be_inlined; # spent 128µs making 9 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 14µs/call |
94 | |||||
95 | 9 | 28µs | 27 | 237µs | return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ ); # spent 316µs making 9 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for, avg 35µs/call, recursion: max depth 1, sum of overlapping time 86µs
# spent 4µs making 9 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 444ns/call
# spent 3µs making 9 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 378ns/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__ |