Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint/Parameterizable.pm |
Statements | Executed 127 statements in 783µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
17 | 1 | 1 | 122µs | 889µs | generate_inline_for | Moose::Meta::TypeConstraint::Parameterizable::
7 | 1 | 1 | 83µs | 999µs | generate_constraint_for | Moose::Meta::TypeConstraint::Parameterizable::
3 | 1 | 1 | 76µs | 3.03ms | parameterize | Moose::Meta::TypeConstraint::Parameterizable::
3 | 1 | 1 | 10µs | 582µs | _parse_type_parameter | Moose::Meta::TypeConstraint::Parameterizable::
1 | 1 | 1 | 8µs | 8µs | BEGIN@2 | Moose::Meta::TypeConstraint::Parameterizable::
1 | 1 | 1 | 6µs | 53µs | BEGIN@13 | Moose::Meta::TypeConstraint::Parameterizable::
1 | 1 | 1 | 6µs | 6µs | BEGIN@14 | Moose::Meta::TypeConstraint::Parameterizable::
1 | 1 | 1 | 6µs | 26µs | BEGIN@17 | Moose::Meta::TypeConstraint::Parameterizable::
1 | 1 | 1 | 6µs | 9µs | BEGIN@10 | Moose::Meta::TypeConstraint::Parameterizable::
1 | 1 | 1 | 6µs | 16µs | BEGIN@9 | Moose::Meta::TypeConstraint::Parameterizable::
1 | 1 | 1 | 5µs | 333µs | BEGIN@11 | Moose::Meta::TypeConstraint::Parameterizable::
1 | 1 | 1 | 3µs | 3µs | BEGIN@15 | Moose::Meta::TypeConstraint::Parameterizable::
0 | 0 | 0 | 0s | 0s | __ANON__[:53] | Moose::Meta::TypeConstraint::Parameterizable::
0 | 0 | 0 | 0s | 0s | _can_coerce_constraint_from | Moose::Meta::TypeConstraint::Parameterizable::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Meta::TypeConstraint::Parameterizable; | ||||
2 | # spent 8µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@2 which was called:
# once (8µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 4 | ||||
3 | 1 | 4µs | $Moose::Meta::TypeConstraint::Parameterizable::AUTHORITY = 'cpan:STEVAN'; | ||
4 | 1 | 30µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@2 |
5 | { | ||||
6 | 2 | 800ns | $Moose::Meta::TypeConstraint::Parameterizable::VERSION = '2.1005'; | ||
7 | } | ||||
8 | |||||
9 | 2 | 20µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9 which was called:
# once (6µs+10µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 9 # spent 16µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@9
# spent 10µs making 1 call to strict::import |
10 | 2 | 18µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10 which was called:
# once (6µs+3µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 10 # spent 9µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@10
# spent 3µs making 1 call to warnings::import |
11 | 2 | 28µs | 2 | 660µs | # spent 333µs (5+327) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11 which was called:
# once (5µs+327µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 11 # spent 333µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@11
# spent 327µs making 1 call to metaclass::import |
12 | |||||
13 | 2 | 25µs | 2 | 99µs | # spent 53µs (6+47) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13 which was called:
# once (6µs+47µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 13 # spent 53µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@13
# spent 46µs making 1 call to base::import |
14 | 2 | 21µs | 1 | 6µs | # spent 6µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 which was called:
# once (6µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 14 # spent 6µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@14 |
15 | 2 | 21µs | 1 | 3µs | # spent 3µs within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@15 which was called:
# once (3µs+0s) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 15 # spent 3µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@15 |
16 | |||||
17 | 2 | 408µs | 2 | 46µs | # spent 26µs (6+20) within Moose::Meta::TypeConstraint::Parameterizable::BEGIN@17 which was called:
# once (6µs+20µs) by Moose::Meta::TypeConstraint::Parameterized::BEGIN@15 at line 17 # spent 26µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::BEGIN@17
# spent 20µs making 1 call to Exporter::import |
18 | |||||
19 | 1 | 3µs | 3 | 457µs | __PACKAGE__->meta->add_attribute('constraint_generator' => ( # spent 439µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 14µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
20 | accessor => 'constraint_generator', | ||||
21 | predicate => 'has_constraint_generator', | ||||
22 | Class::MOP::_definition_context(), | ||||
23 | )); | ||||
24 | |||||
25 | 1 | 3µs | 3 | 409µs | __PACKAGE__->meta->add_attribute('inline_generator' => ( # spent 396µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Moose::Meta::TypeConstraint::Parameterizable::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
26 | accessor => 'inline_generator', | ||||
27 | predicate => 'has_inline_generator', | ||||
28 | Class::MOP::_definition_context(), | ||||
29 | )); | ||||
30 | |||||
31 | # spent 999µs (83+916) within Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for which was called 7 times, avg 143µs/call:
# 7 times (83µs+916µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 61 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 143µs/call | ||||
32 | 7 | 2µs | my ($self, $type) = @_; | ||
33 | |||||
34 | 7 | 8µs | 7 | 10µs | return unless $self->has_constraint_generator; # spent 10µs making 7 calls to Moose::Meta::TypeConstraint::Parameterizable::has_constraint_generator, avg 1µs/call |
35 | |||||
36 | 7 | 27µs | 23 | 902µs | return $self->constraint_generator->($type->type_parameter) # spent 858µs making 7 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 122µs/call
# spent 17µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:222], avg 8µs/call
# spent 9µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:257]
# spent 8µs making 7 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
# spent 6µs making 3 calls to Moose::Meta::TypeConstraint::Parameterizable::constraint_generator, avg 2µs/call
# spent 4µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::type_parameter, avg 1µs/call |
37 | if $type->is_subtype_of($self->name); | ||||
38 | |||||
39 | 4 | 4µs | 4 | 5µs | return $self->_can_coerce_constraint_from($type) # spent 5µs making 4 calls to Moose::Meta::TypeConstraint::has_coercion, avg 1µs/call |
40 | if $self->has_coercion | ||||
41 | && $self->coercion->has_coercion_for_type($type->parent->name); | ||||
42 | |||||
43 | 4 | 7µs | return; | ||
44 | } | ||||
45 | |||||
46 | sub _can_coerce_constraint_from { | ||||
47 | my ($self, $type) = @_; | ||||
48 | my $coercion = $self->coercion; | ||||
49 | my $constraint = $self->constraint_generator->($type->type_parameter); | ||||
50 | return sub { | ||||
51 | local $_ = $coercion->coerce($_); | ||||
52 | $constraint->(@_); | ||||
53 | }; | ||||
54 | } | ||||
55 | |||||
56 | # spent 889µs (122+767) within Moose::Meta::TypeConstraint::Parameterizable::generate_inline_for which was called 17 times, avg 52µs/call:
# 17 times (122µs+767µs) by Moose::Meta::TypeConstraint::Parameterized::_inline_check at line 101 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 52µs/call | ||||
57 | 17 | 5µs | my ($self, $type, $val) = @_; | ||
58 | |||||
59 | 17 | 11µs | 17 | 14µs | confess "Can't generate an inline constraint for $type, since none " # spent 14µs making 17 calls to Moose::Meta::TypeConstraint::Parameterizable::has_inline_generator, avg 824ns/call |
60 | . "was defined" | ||||
61 | unless $self->has_inline_generator; | ||||
62 | |||||
63 | 17 | 60µs | 34 | 753µs | return '( do { ' . $self->inline_generator->( $self, $type, $val ) . ' } )'; # spent 652µs making 16 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:237], avg 41µs/call
# spent 80µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:272]
# spent 21µs making 17 calls to Moose::Meta::TypeConstraint::Parameterizable::inline_generator, avg 1µs/call |
64 | } | ||||
65 | |||||
66 | # spent 582µs (10+571) within Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter which was called 3 times, avg 194µs/call:
# 3 times (10µs+571µs) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 74, avg 194µs/call | ||||
67 | 3 | 700ns | my ($self, $type_parameter) = @_; | ||
68 | 3 | 9µs | 3 | 512µs | return Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($type_parameter); # spent 571µs making 3 calls to Moose::Util::TypeConstraints::find_or_create_isa_type_constraint, avg 190µs/call, recursion: max depth 1, sum of overlapping time 60µs |
69 | } | ||||
70 | |||||
71 | # spent 3.03ms (76µs+2.96) within Moose::Meta::TypeConstraint::Parameterizable::parameterize which was called 3 times, avg 1.01ms/call:
# 3 times (76µs+2.96ms) by Moose::Util::TypeConstraints::_create_parameterized_type_constraint at line 143 of Moose/Util/TypeConstraints.pm, avg 1.01ms/call | ||||
72 | 3 | 1µs | my ($self, $type_parameter) = @_; | ||
73 | |||||
74 | 3 | 5µs | 3 | 582µs | my $contained_tc = $self->_parse_type_parameter($type_parameter); # spent 582µs making 3 calls to Moose::Meta::TypeConstraint::Parameterizable::_parse_type_parameter, avg 194µs/call |
75 | |||||
76 | ## The type parameter should be a subtype of the parent's type parameter | ||||
77 | ## if there is one. | ||||
78 | |||||
79 | 3 | 9µs | 6 | 7µs | if(my $parent = $self->parent) { # spent 5µs making 3 calls to Moose::Meta::TypeConstraint::parent, avg 2µs/call
# spent 2µs making 3 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 667ns/call |
80 | 3 | 11µs | 3 | 3µs | if($parent->can('type_parameter')) { # spent 3µs making 3 calls to UNIVERSAL::can, avg 1µs/call |
81 | unless ( $contained_tc->is_a_type_of($parent->type_parameter) ) { | ||||
82 | require Moose; | ||||
83 | Moose->throw_error("$type_parameter is not a subtype of ".$parent->type_parameter); | ||||
84 | } | ||||
85 | } | ||||
86 | } | ||||
87 | |||||
88 | 3 | 8µs | 3 | 2µs | if ( $contained_tc->isa('Moose::Meta::TypeConstraint') ) { # spent 2µs making 3 calls to UNIVERSAL::isa, avg 733ns/call |
89 | 3 | 8µs | 6 | 7µs | my $tc_name = $self->name . '[' . $contained_tc->name . ']'; # spent 7µs making 6 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call |
90 | 3 | 18µs | 3 | 2.36ms | return Moose::Meta::TypeConstraint::Parameterized->new( # spent 2.36ms making 3 calls to Moose::Meta::TypeConstraint::new, avg 785µs/call |
91 | name => $tc_name, | ||||
92 | parent => $self, | ||||
93 | type_parameter => $contained_tc, | ||||
94 | parameterized_from => $self, | ||||
95 | ); | ||||
96 | } | ||||
97 | else { | ||||
98 | require Moose; | ||||
99 | Moose->throw_error("The type parameter must be a Moose meta type"); | ||||
100 | } | ||||
101 | } | ||||
102 | |||||
103 | |||||
104 | 1 | 6µs | 1; | ||
105 | |||||
106 | # ABSTRACT: Type constraints which can take a parameter (ArrayRef) | ||||
107 | |||||
108 | __END__ |