Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint/Parameterized.pm |
Statements | Executed 224 statements in 1.10ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 644µs | 1.96ms | BEGIN@15 | Moose::Meta::TypeConstraint::Parameterized::
45 | 4 | 3 | 384µs | 953µs | can_be_inlined | Moose::Meta::TypeConstraint::Parameterized::
16 | 3 | 3 | 178µs | 493µs | inline_environment | Moose::Meta::TypeConstraint::Parameterized::
17 | 2 | 2 | 133µs | 1.37ms | _inline_check | Moose::Meta::TypeConstraint::Parameterized::
3 | 1 | 1 | 78µs | 2.13ms | compile_type_constraint | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 8µs | 14µs | equals | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 7µs | 7µs | BEGIN@14 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 9µs | BEGIN@10 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 27µs | BEGIN@13 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 52µs | BEGIN@17 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 6µs | 16µs | BEGIN@9 | Moose::Meta::TypeConstraint::Parameterized::
1 | 1 | 1 | 5µs | 331µ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 | # spent 8µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@2 which was called:
# once (8µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 4 | ||||
3 | 1 | 4µs | $Moose::Meta::TypeConstraint::Parameterized::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 31µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@2 |
5 | { | ||||
6 | 2 | 800ns | $Moose::Meta::TypeConstraint::Parameterized::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 21µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@9 which was called:
# once (6µs+10µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 9 # spent 16µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@9
# spent 10µs making 1 call to strict::import |
10 | 2 | 19µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 10 # spent 9µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@10
# spent 3µs making 1 call to warnings::import |
11 | 2 | 29µs | 2 | 657µs | # spent 331µs (5+326) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@11 which was called:
# once (5µs+326µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 11 # spent 331µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@11
# spent 326µs making 1 call to metaclass::import |
12 | |||||
13 | 2 | 21µs | 2 | 48µs | # spent 27µs (6+21) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@13 which was called:
# once (6µs+21µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 13 # spent 27µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@13
# spent 21µs making 1 call to Exporter::import |
14 | 2 | 23µs | 1 | 7µs | # spent 7µs within Moose::Meta::TypeConstraint::Parameterized::BEGIN@14 which was called:
# once (7µs+0s) by Moose::Util::TypeConstraints::BEGIN@34 at line 14 # spent 7µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@14 |
15 | 2 | 105µs | 1 | 1.96ms | # spent 1.96ms (644µs+1.32) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 which was called:
# once (644µs+1.32ms) by Moose::Util::TypeConstraints::BEGIN@34 at line 15 # spent 1.96ms making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 |
16 | |||||
17 | 2 | 395µs | 2 | 99µs | # spent 52µs (6+46) within Moose::Meta::TypeConstraint::Parameterized::BEGIN@17 which was called:
# once (6µs+46µs) by Moose::Util::TypeConstraints::BEGIN@34 at line 17 # spent 52µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::BEGIN@17
# spent 46µs making 1 call to base::import |
18 | |||||
19 | 1 | 3µs | 3 | 430µs | __PACKAGE__->meta->add_attribute('type_parameter' => ( # spent 412µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 13µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
20 | accessor => 'type_parameter', | ||||
21 | predicate => 'has_type_parameter', | ||||
22 | Class::MOP::_definition_context(), | ||||
23 | )); | ||||
24 | |||||
25 | 1 | 3µs | 3 | 402µs | __PACKAGE__->meta->add_attribute('parameterized_from' => ( # spent 390µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
26 | accessor => 'parameterized_from', | ||||
27 | predicate => 'has_parameterized_from', | ||||
28 | Class::MOP::_definition_context(), | ||||
29 | )); | ||||
30 | |||||
31 | # spent 14µs (8+6) within Moose::Meta::TypeConstraint::Parameterized::equals which was called:
# once (8µs+6µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 278 of Moose/Meta/TypeConstraint.pm | ||||
32 | 1 | 400ns | my ( $self, $type_or_name ) = @_; | ||
33 | |||||
34 | 1 | 1µs | 1 | 4µs | my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name); # spent 4µs making 1 call to Moose::Util::TypeConstraints::find_type_constraint |
35 | |||||
36 | 1 | 7µs | 1 | 1µs | return unless $other->isa(__PACKAGE__); # spent 1µs making 1 call to UNIVERSAL::isa |
37 | |||||
38 | return ( | ||||
39 | $self->type_parameter->equals( $other->type_parameter ) | ||||
40 | and | ||||
41 | $self->parent->equals( $other->parent ) | ||||
42 | ); | ||||
43 | } | ||||
44 | |||||
45 | # spent 2.13ms (78µs+2.05) within Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint which was called 3 times, avg 709µs/call:
# 3 times (78µs+2.05ms) by Moose::Meta::TypeConstraint::new at line 144 of Moose/Meta/TypeConstraint.pm, avg 709µs/call | ||||
46 | 3 | 700ns | my $self = shift; | ||
47 | |||||
48 | 3 | 5µs | 3 | 5µs | unless ( $self->has_type_parameter ) { # spent 5µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 2µs/call |
49 | require Moose; | ||||
50 | Moose->throw_error("You cannot create a Higher Order type without a type parameter"); | ||||
51 | } | ||||
52 | |||||
53 | 3 | 5µs | 3 | 6µs | my $type_parameter = $self->type_parameter; # spent 6µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 2µs/call |
54 | |||||
55 | 3 | 15µs | 6 | 4µs | unless ( blessed $type_parameter && $type_parameter->isa('Moose::Meta::TypeConstraint') ) { # spent 3µs making 3 calls to Scalar::Util::blessed, avg 967ns/call
# spent 2µs making 3 calls to UNIVERSAL::isa, avg 533ns/call |
56 | require Moose; | ||||
57 | Moose->throw_error("The type parameter must be a Moose meta type"); | ||||
58 | } | ||||
59 | |||||
60 | 3 | 6µs | 3 | 6µs | foreach my $type (Moose::Util::TypeConstraints::get_all_parameterizable_types()) { # spent 6µs making 3 calls to Moose::Util::TypeConstraints::get_all_parameterizable_types, avg 2µs/call |
61 | 7 | 9µs | 7 | 999µs | if (my $constraint = $type->generate_constraint_for($self)) { # spent 999µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for, avg 143µs/call |
62 | 3 | 7µs | 3 | 6µs | $self->_set_constraint($constraint); # spent 6µs making 3 calls to Moose::Meta::TypeConstraint::_set_constraint, avg 2µs/call |
63 | 3 | 12µs | 3 | 1.02ms | return $self->SUPER::compile_type_constraint; # spent 1.02ms making 3 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 342µs/call |
64 | } | ||||
65 | } | ||||
66 | |||||
67 | # if we get here, then we couldn't | ||||
68 | # find a way to parameterize this type | ||||
69 | require Moose; | ||||
70 | Moose->throw_error("The " . $self->name . " constraint cannot be used, because " | ||||
71 | . $self->parent->name . " doesn't subtype or coerce from a parameterizable type."); | ||||
72 | } | ||||
73 | |||||
74 | # spent 953µs (384+569) within Moose::Meta::TypeConstraint::Parameterized::can_be_inlined which was called 45 times, avg 21µs/call:
# 17 times (130µs+188µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 99, avg 19µs/call
# 14 times (121µs+185µs) by Moose::Meta::Attribute::_inline_check_constraint at line 711 of Moose/Meta/Attribute.pm, avg 22µs/call
# 11 times (93µs+151µs) by Moose::Meta::Attribute::_eval_environment at line 789 of Moose/Meta/Attribute.pm, avg 22µs/call
# 3 times (39µs+45µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 311 of Moose/Meta/TypeConstraint.pm, avg 28µs/call | ||||
75 | 45 | 4µs | my $self = shift; | ||
76 | |||||
77 | return | ||||
78 | 45 | 201µs | 225 | 569µs | $self->has_parameterized_from # spent 390µs making 45 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 9µs/call
# spent 46µs making 45 calls to Moose::Meta::TypeConstraint::Parameterized::has_parameterized_from, avg 1µs/call
# spent 45µs making 45 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 1µs/call
# spent 44µs making 45 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 969ns/call
# spent 43µs making 45 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 964ns/call |
79 | && $self->parameterized_from->has_inline_generator | ||||
80 | && $self->type_parameter->can_be_inlined; | ||||
81 | } | ||||
82 | |||||
83 | # spent 493µs (178+315) within Moose::Meta::TypeConstraint::Parameterized::inline_environment which was called 16 times, avg 31µs/call:
# 11 times (118µs+218µs) by Moose::Meta::Attribute::_eval_environment at line 800 of Moose/Meta/Attribute.pm, avg 31µs/call
# 3 times (40µs+59µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 311 of Moose/Meta/TypeConstraint.pm, avg 33µs/call
# 2 times (20µs+38µs) by Moose::Meta::Class::_eval_environment at line 543 of Moose/Meta/Class.pm, avg 29µs/call | ||||
84 | 16 | 2µs | my $self = shift; | ||
85 | |||||
86 | return { | ||||
87 | ($self->has_parameterized_from | ||||
88 | ? (%{ $self->parameterized_from->inline_environment }) | ||||
89 | : ()), | ||||
90 | ($self->has_type_parameter | ||||
91 | 16 | 95µs | 96 | 315µs | ? (%{ $self->type_parameter->inline_environment }) # spent 253µs making 32 calls to Moose::Meta::TypeConstraint::inline_environment, avg 8µs/call
# spent 16µs making 16 calls to Moose::Meta::TypeConstraint::Parameterized::has_type_parameter, avg 1µs/call
# spent 16µs making 16 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 988ns/call
# spent 16µs making 16 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 988ns/call
# spent 14µs making 16 calls to Moose::Meta::TypeConstraint::Parameterized::has_parameterized_from, avg 900ns/call |
92 | : ()), | ||||
93 | }; | ||||
94 | } | ||||
95 | |||||
96 | # spent 1.37ms (133µs+1.24) within Moose::Meta::TypeConstraint::Parameterized::_inline_check which was called 17 times, avg 81µs/call:
# 14 times (101µs+948µs) by Moose::Meta::Attribute::_inline_check_constraint at line 711 of Moose/Meta/Attribute.pm, avg 75µs/call
# 3 times (32µs+291µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 311 of Moose/Meta/TypeConstraint.pm, avg 108µs/call | ||||
97 | 17 | 2µs | my $self = shift; | ||
98 | |||||
99 | 17 | 13µs | 17 | 318µs | return unless $self->can_be_inlined; # spent 318µs making 17 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 19µs/call |
100 | |||||
101 | 17 | 58µs | 51 | 921µs | return $self->parameterized_from->generate_inline_for( $self->type_parameter, @_ ); # spent 889µs making 17 calls to Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for, avg 52µs/call
# spent 17µs making 17 calls to Moose::Meta::TypeConstraint::Parameterized::parameterized_from, avg 982ns/call
# spent 16µs making 17 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 918ns/call |
102 | } | ||||
103 | |||||
104 | sub create_child_type { | ||||
105 | my ($self, %opts) = @_; | ||||
106 | return Moose::Meta::TypeConstraint::Parameterizable->new(%opts, parent=>$self); | ||||
107 | } | ||||
108 | |||||
109 | 1 | 5µs | 1; | ||
110 | |||||
111 | # ABSTRACT: Type constraints with a bound parameter (ArrayRef[Int]) | ||||
112 | |||||
113 | __END__ |