← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 21:42:38 2010
Reported on Wed Nov 17 22:04:49 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint.pm
StatementsExecuted 3323 statements in 50.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
87218.90ms20.1msMoose::Meta::TypeConstraint::::equalsMoose::Meta::TypeConstraint::equals
7801566.85ms6.85msMoose::Meta::TypeConstraint::::__ANON__[:10]Moose::Meta::TypeConstraint::__ANON__[:10]
25114.92ms29.7msMoose::Meta::TypeConstraint::::is_subtype_ofMoose::Meta::TypeConstraint::is_subtype_of
102114.38ms15.2msMoose::Meta::TypeConstraint::::_actually_compile_type_constraintMoose::Meta::TypeConstraint::_actually_compile_type_constraint
108443.85ms21.1msMoose::Meta::TypeConstraint::::compile_type_constraintMoose::Meta::TypeConstraint::compile_type_constraint
38843.41ms55.9msMoose::Meta::TypeConstraint::::newMoose::Meta::TypeConstraint::new
174112.89ms3.62msMoose::Meta::TypeConstraint::::__ANON__[:8]Moose::Meta::TypeConstraint::__ANON__[:8]
86112.66ms3.63msMoose::Meta::TypeConstraint::::_compile_hand_optimized_type_constraintMoose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint
15112.00ms5.40msMoose::Meta::TypeConstraint::::_compile_subtypeMoose::Meta::TypeConstraint::_compile_subtype
15111.63ms2.46msMoose::Meta::TypeConstraint::::_collect_all_parentsMoose::Meta::TypeConstraint::_collect_all_parents
1111.51ms5.52msMoose::Meta::TypeConstraint::::BEGIN@6Moose::Meta::TypeConstraint::BEGIN@6
8721954µs954µsMoose::Meta::TypeConstraint::::__ANON__[:32]Moose::Meta::TypeConstraint::__ANON__[:32]
1711632µs7.43msMoose::Meta::TypeConstraint::::create_child_typeMoose::Meta::TypeConstraint::create_child_type
911367µs1.00msMoose::Meta::TypeConstraint::::checkMoose::Meta::TypeConstraint::check
211122µs730µsMoose::Meta::TypeConstraint::::is_a_type_ofMoose::Meta::TypeConstraint::is_a_type_of
11177µs338µsMoose::Meta::TypeConstraint::::BEGIN@8Moose::Meta::TypeConstraint::BEGIN@8
11172µs98µsMoose::Meta::TypeConstraint::::_compile_typeMoose::Meta::TypeConstraint::_compile_type
11170µs88µsMoose::Meta::TypeConstraint::::BEGIN@4Moose::Meta::TypeConstraint::BEGIN@4
11141µs236µsMoose::Meta::TypeConstraint::::BEGIN@13Moose::Meta::TypeConstraint::BEGIN@13
11139µs170µsMoose::Meta::TypeConstraint::::BEGIN@14Moose::Meta::TypeConstraint::BEGIN@14
11139µs108µsMoose::Meta::TypeConstraint::::BEGIN@5Moose::Meta::TypeConstraint::BEGIN@5
11137µs267µsMoose::Meta::TypeConstraint::::BEGIN@16Moose::Meta::TypeConstraint::BEGIN@16
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:274]Moose::Meta::TypeConstraint::__ANON__[:274]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:287]Moose::Meta::TypeConstraint::__ANON__[:287]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:28]Moose::Meta::TypeConstraint::__ANON__[:28]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:300]Moose::Meta::TypeConstraint::__ANON__[:300]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:9]Moose::Meta::TypeConstraint::__ANON__[:9]
0000s0sMoose::Meta::TypeConstraint::::assert_coerceMoose::Meta::TypeConstraint::assert_coerce
0000s0sMoose::Meta::TypeConstraint::::assert_validMoose::Meta::TypeConstraint::assert_valid
0000s0sMoose::Meta::TypeConstraint::::coerceMoose::Meta::TypeConstraint::coerce
0000s0sMoose::Meta::TypeConstraint::::get_messageMoose::Meta::TypeConstraint::get_message
0000s0sMoose::Meta::TypeConstraint::::parentsMoose::Meta::TypeConstraint::parents
0000s0sMoose::Meta::TypeConstraint::::validateMoose::Meta::TypeConstraint::validate
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1
2package Moose::Meta::TypeConstraint;
3
4396µs2106µs
# spent 88µs (70+18) within Moose::Meta::TypeConstraint::BEGIN@4 which was called: # once (70µs+18µs) by Moose::BEGIN@20 at line 4
use strict;
# spent 88µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@4 # spent 18µs making 1 call to strict::import
5392µs2176µs
# spent 108µs (39+69) within Moose::Meta::TypeConstraint::BEGIN@5 which was called: # once (39µs+69µs) by Moose::BEGIN@20 at line 5
use warnings;
# spent 108µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@5 # spent 69µs making 1 call to warnings::import
63651µs28.72ms
# spent 5.52ms (1.51+4.02) within Moose::Meta::TypeConstraint::BEGIN@6 which was called: # once (1.51ms+4.02ms) by Moose::BEGIN@20 at line 6
use metaclass;
# spent 5.52ms making 1 call to Moose::Meta::TypeConstraint::BEGIN@6 # spent 3.20ms making 1 call to metaclass::import
7
81743.89ms174727µs
# spent 3.62ms (2.89+728µs) within Moose::Meta::TypeConstraint::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint.pm:8] which was called 174 times, avg 21µs/call: # 174 times (2.89ms+728µs) by Moose::Meta::TypeConstraint::equals at line 157, avg 21µs/call # spent 338µs (77+262) within Moose::Meta::TypeConstraint::BEGIN@8 which was called: # once (77µs+262µs) by Moose::BEGIN@20 at line 11
use overload '0+' => sub { refaddr(shift) }, # id an object
# spent 727µs making 174 calls to Scalar::Util::refaddr, avg 4µs/call
9 '""' => sub { shift->name }, # stringify to tc name
1078010.1ms
# spent 6.85ms within Moose::Meta::TypeConstraint::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint.pm:10] which was called 780 times, avg 9µs/call: # 170 times (1.82ms+0s) by Moose::Meta::Method::Accessor::_eval_environment at line 46 of Moose/Meta/Method/Accessor.pm, avg 11µs/call # 131 times (1.29ms+0s) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218 of Moose/Util/TypeConstraints.pm, avg 10µs/call # 118 times (884µs+0s) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 204 of Moose/Util/TypeConstraints.pm, avg 7µs/call # 98 times (836µs+0s) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 47 of Moose/Meta/TypeConstraint/Registry.pm, avg 9µs/call # 87 times (674µs+0s) by Moose::Meta::TypeConstraint::equals at line 155, avg 8µs/call # 85 times (622µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 190, avg 7µs/call # 25 times (196µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 186, avg 8µs/call # 17 times (119µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 547 of Moose/Util/TypeConstraints.pm, avg 7µs/call # 15 times (118µs+0s) by Moose::Util::TypeConstraints::create_type_constraint_union at line 89 of Moose/Util/TypeConstraints.pm, avg 8µs/call # 10 times (113µs+0s) by Moose::Util::TypeConstraints::find_or_create_does_type_constraint at line 210 of Moose/Util/TypeConstraints.pm, avg 11µs/call # 10 times (73µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 58 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 7µs/call # 8 times (58µs+0s) by Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type at line 42 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 7µs/call # 2 times (15µs+0s) by Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type at line 39 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 8µs/call # 2 times (15µs+0s) by Moose::Meta::TypeConstraint::is_a_type_of at line 178, avg 7µs/call # 2 times (14µs+0s) by Moose::Util::TypeConstraints::find_or_create_type_constraint at line 176 of Moose/Util/TypeConstraints.pm, avg 7µs/call
bool => sub { 1 },
113171µs2600µs fallback => 1;
# spent 338µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@8 # spent 262µs making 1 call to overload::import
12
133115µs2431µs
# spent 236µs (41+195) within Moose::Meta::TypeConstraint::BEGIN@13 which was called: # once (41µs+195µs) by Moose::BEGIN@20 at line 13
use Scalar::Util qw(blessed refaddr);
# spent 236µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@13 # spent 195µs making 1 call to Exporter::import
143116µs2302µs
# spent 170µs (39+131) within Moose::Meta::TypeConstraint::BEGIN@14 which was called: # once (39µs+131µs) by Moose::BEGIN@20 at line 14
use Sub::Name qw(subname);
# spent 170µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14 # spent 131µs making 1 call to Exporter::import
15
1634.92ms2497µs
# spent 267µs (37+230) within Moose::Meta::TypeConstraint::BEGIN@16 which was called: # once (37µs+230µs) by Moose::BEGIN@20 at line 16
use base qw(Class::MOP::Object);
# spent 267µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@16 # spent 230µs making 1 call to base::import
17
1815µsour $VERSION = '1.19';
191145µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
2014µsour $AUTHORITY = 'cpan:STEVAN';
21
22128µs22.51ms__PACKAGE__->meta->add_attribute('name' => (reader => 'name'));
# spent 2.39ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 121µs making 1 call to Moose::Meta::TypeConstraint::meta
23123µs24.74ms__PACKAGE__->meta->add_attribute('parent' => (
# spent 4.62ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 125µs making 1 call to Moose::Meta::TypeConstraint::meta
24 reader => 'parent',
25 predicate => 'has_parent',
26));
27
28114µsmy $null_constraint = sub { 1 };
29__PACKAGE__->meta->add_attribute('constraint' => (
30 reader => 'constraint',
31 writer => '_set_constraint',
32871.21ms
# spent 954µs within Moose::Meta::TypeConstraint::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint.pm:32] which was called 87 times, avg 11µs/call: # 53 times (590µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new or Moose::Meta::TypeConstraint::Role::_new or Moose::Meta::TypeConstraint::Union::_new or Moose::Meta::TypeConstraint::_new at line 18 of generated method (unknown origin), avg 11µs/call # 34 times (364µs+0s) by Moose::Meta::TypeConstraint::Class::_new at line 21 of generated method (unknown origin), avg 11µs/call
default => sub { $null_constraint }
33146µs24.54ms));
# spent 4.41ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 127µs making 1 call to Moose::Meta::TypeConstraint::meta
34132µs24.40ms__PACKAGE__->meta->add_attribute('message' => (
# spent 4.28ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 122µs making 1 call to Moose::Meta::TypeConstraint::meta
35 accessor => 'message',
36 predicate => 'has_message'
37));
38133µs24.37ms__PACKAGE__->meta->add_attribute('coercion' => (
# spent 4.24ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 121µs making 1 call to Moose::Meta::TypeConstraint::meta
39 accessor => 'coercion',
40 predicate => 'has_coercion'
41));
42
43134µs26.66ms__PACKAGE__->meta->add_attribute('hand_optimized_type_constraint' => (
# spent 6.54ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 119µs making 1 call to Moose::Meta::TypeConstraint::meta
44 init_arg => 'optimized',
45 accessor => 'hand_optimized_type_constraint',
46 predicate => 'has_hand_optimized_type_constraint',
47));
48
49sub parents {
50 my $self;
51 $self->parent;
52}
53
54# private accessors
55
56131µs23.25ms__PACKAGE__->meta->add_attribute('compiled_type_constraint' => (
# spent 3.13ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 117µs making 1 call to Moose::Meta::TypeConstraint::meta
57 accessor => '_compiled_type_constraint',
58 predicate => '_has_compiled_type_constraint'
59));
60124µs22.07ms__PACKAGE__->meta->add_attribute('package_defined_in' => (
# spent 1.99ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 86µs making 1 call to Moose::Meta::TypeConstraint::meta
61 accessor => '_package_defined_in'
62));
63
64
# spent 55.9ms (3.41+52.5) within Moose::Meta::TypeConstraint::new which was called 38 times, avg 1.47ms/call: # 17 times (1.44ms+5.35ms) by Moose::Meta::TypeConstraint::create_child_type at line 319, avg 400µs/call # 10 times (944µs+43.1ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 69 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 4.40ms/call # 6 times (543µs+1.80ms) by Moose::Meta::TypeConstraint::Union::new at line 29 of Moose/Meta/TypeConstraint/Union.pm, avg 391µs/call # once (97µs+697µs) by Moose::Meta::Attribute::BEGIN@20 at line 847 of Moose/Util/TypeConstraints.pm # once (116µs+602µs) by Moose::Meta::Attribute::BEGIN@20 at line 788 of Moose/Util/TypeConstraints.pm # once (102µs+556µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 557 of Moose/Util/TypeConstraints.pm # once (81µs+235µs) by Moose::Meta::Attribute::BEGIN@20 at line 830 of Moose/Util/TypeConstraints.pm # once (83µs+217µs) by Moose::Meta::Attribute::BEGIN@20 at line 809 of Moose/Util/TypeConstraints.pm
sub new {
652663.23ms my $class = shift;
66 my ($first, @rest) = @_;
67 my %args = ref $first ? %$first : $first ? ($first, @rest) : ();
68 $args{name} = $args{name} ? "$args{name}" : "__ANON__";
69
70385.44ms my $self = $class->_new(%args);
# spent 1.92ms making 10 calls to Moose::Meta::TypeConstraint::Parameterized::_new, avg 192µs/call # spent 1.80ms making 18 calls to Moose::Meta::TypeConstraint::_new, avg 100µs/call # spent 1.05ms making 6 calls to Moose::Meta::TypeConstraint::Union::_new, avg 176µs/call # spent 656µs making 4 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 164µs/call
717647.1ms $self->compile_type_constraint()
# spent 41.0ms making 10 calls to Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint, avg 4.10ms/call # spent 5.63ms making 28 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 201µs/call # spent 439µs making 38 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 12µs/call
72 unless $self->_has_compiled_type_constraint;
73 return $self;
74}
75
- -
78sub coerce {
79 my $self = shift;
80
81 my $coercion = $self->coercion;
82
83 unless ($coercion) {
84 require Moose;
85 Moose->throw_error("Cannot coerce without a type coercion");
86 }
87
88 return $_[0] if $self->check($_[0]);
89
90 return $coercion->coerce(@_);
91}
92
93sub assert_coerce {
94 my $self = shift;
95
96 my $coercion = $self->coercion;
97
98 unless ($coercion) {
99 require Moose;
100 Moose->throw_error("Cannot coerce without a type coercion");
101 }
102
103 return $_[0] if $self->check($_[0]);
104
105 my $result = $coercion->coerce(@_);
106
107 $self->assert_valid($result);
108
109 return $result;
110}
111
112
# spent 1.00ms (367µs+635µs) within Moose::Meta::TypeConstraint::check which was called 9 times, avg 111µs/call: # 9 times (367µs+635µs) by Moose::Meta::Attribute::verify_against_type_constraint at line 1141 of Moose/Meta/Attribute.pm, avg 111µs/call
sub check {
11327321µs my ($self, @args) = @_;
1149110µs my $constraint_subref = $self->_compiled_type_constraint;
# spent 110µs making 9 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 12µs/call
1159525µs return $constraint_subref->(@args) ? 1 : undef;
# spent 403µs making 5 calls to Moose::Meta::TypeConstraint::Bool, avg 81µs/call # spent 92µs making 2 calls to Moose::Util::TypeConstraints::OptimizedConstraints::Int, avg 46µs/call # spent 30µs making 2 calls to Moose::Util::TypeConstraints::OptimizedConstraints::Str, avg 15µs/call
116}
117
118sub validate {
119 my ($self, $value) = @_;
120 if ($self->_compiled_type_constraint->($value)) {
121 return undef;
122 }
123 else {
124 $self->get_message($value);
125 }
126}
127
128sub assert_valid {
129 my ($self, $value) = @_;
130
131 my $error = $self->validate($value);
132 return 1 if ! defined $error;
133
134 require Moose;
135 Moose->throw_error($error);
136}
137
138sub get_message {
139 my ($self, $value) = @_;
140 if (my $msg = $self->message) {
141 local $_ = $value;
142 return $msg->($value);
143 }
144 else {
145 $value = (defined $value ? overload::StrVal($value) : 'undef');
146 return "Validation failed for '" . $self->name . "' with value $value";
147 }
148}
149
150## type predicates ...
151
152
# spent 20.1ms (8.90+11.2) within Moose::Meta::TypeConstraint::equals which was called 87 times, avg 231µs/call: # 85 times (8.75ms+11.0ms) by Moose::Meta::TypeConstraint::is_subtype_of at line 191, avg 232µs/call # 2 times (149µs+213µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 180, avg 181µs/call
sub equals {
1534115.82ms my ( $self, $type_or_name ) = @_;
154
1551247µs1744.05ms my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 3.37ms making 87 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 39µs/call # spent 674µs making 87 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call
156
15711.19ms1743.62ms return 1 if $self == $other;
# spent 3.62ms making 174 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 21µs/call
158
1591651.81ms if ( $self->has_hand_optimized_type_constraint and $other->has_hand_optimized_type_constraint ) {
# spent 1.13ms making 105 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 11µs/call # spent 679µs making 60 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 11µs/call
160 return 1 if $self->hand_optimized_type_constraint == $other->hand_optimized_type_constraint;
161 }
162
1631501.74ms return unless $self->constraint == $other->constraint;
# spent 1.74ms making 150 calls to Moose::Meta::TypeConstraint::constraint, avg 12µs/call
164
165 if ( $self->has_parent ) {
166 return unless $other->has_parent;
167 return unless $self->parent->equals( $other->parent );
168 } else {
169 return if $other->has_parent;
170 }
171
172 return;
173}
174
175
# spent 730µs (122+608) within Moose::Meta::TypeConstraint::is_a_type_of which was called 2 times, avg 365µs/call: # 2 times (122µs+608µs) by Moose::Meta::Attribute::Native::Trait::_check_helper_type at line 96 of Moose/Meta/Attribute/Native/Trait.pm, avg 365µs/call
sub is_a_type_of {
1766108µs my ($self, $type_or_name) = @_;
177
17816µs4245µs my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 230µs making 2 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 115µs/call # spent 15µs making 2 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call
179
1802362µs ($self->equals($type) || $self->is_subtype_of($type));
# spent 362µs making 2 calls to Moose::Meta::TypeConstraint::equals, avg 181µs/call
181}
182
183
# spent 29.7ms (4.92+24.8) within Moose::Meta::TypeConstraint::is_subtype_of which was called 25 times, avg 1.19ms/call: # 25 times (4.92ms+24.8ms) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 1.19ms/call
sub is_subtype_of {
1842753.61ms my ($self, $type_or_name) = @_;
185
186178µs503.31ms my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 3.12ms making 25 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 125µs/call # spent 196µs making 25 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call
187
188 my $current = $self;
189
1901222µs1851.73ms while (my $parent = $current->parent) {
# spent 1.11ms making 100 calls to Moose::Meta::TypeConstraint::parent, avg 11µs/call # spent 622µs making 85 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call
1918519.7ms return 1 if $parent->equals($type);
# spent 19.7ms making 85 calls to Moose::Meta::TypeConstraint::equals, avg 232µs/call
192 $current = $parent;
193 }
194
195 return 0;
196}
197
198## compiling the type constraint
199
200
# spent 21.1ms (3.85+17.2) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 108 times, avg 195µs/call: # 36 times (1.28ms+3.88ms) by Moose::Meta::TypeConstraint::Role::new at line 27 of Moose/Meta/TypeConstraint/Role.pm, avg 143µs/call # 34 times (1.22ms+3.73ms) by Moose::Meta::TypeConstraint::Class::new at line 27 of Moose/Meta/TypeConstraint/Class.pm, avg 145µs/call # 28 times (998µs+4.63ms) by Moose::Meta::TypeConstraint::new at line 71, avg 201µs/call # 10 times (355µs+4.98ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 54 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 533µs/call
sub compile_type_constraint {
2012163.56ms my $self = shift;
20221617.2ms $self->_compiled_type_constraint($self->_actually_compile_type_constraint);
# spent 15.2ms making 102 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 149µs/call # spent 1.73ms making 108 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 16µs/call # spent 341µs making 6 calls to Moose::Meta::TypeConstraint::Union::_actually_compile_type_constraint, avg 57µs/call
203}
204
205## type compilers ...
206
207
# spent 15.2ms (4.38+10.8) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 102 times, avg 149µs/call: # 102 times (4.38ms+10.8ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 202, avg 149µs/call
sub _actually_compile_type_constraint {
2082533.70ms my $self = shift;
209
2101884.82ms return $self->_compile_hand_optimized_type_constraint
# spent 3.63ms making 86 calls to Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint, avg 42µs/call # spent 1.19ms making 102 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 12µs/call
211 if $self->has_hand_optimized_type_constraint;
212
21316266µs my $check = $self->constraint;
# spent 266µs making 16 calls to Moose::Meta::TypeConstraint::constraint, avg 17µs/call
214 unless ( defined $check ) {
215 require Moose;
216 Moose->throw_error( "Could not compile type constraint '"
217 . $self->name
218 . "' because no constraint check" );
219 }
220
221315.59ms return $self->_compile_subtype($check)
# spent 5.40ms making 15 calls to Moose::Meta::TypeConstraint::_compile_subtype, avg 360µs/call # spent 192µs making 16 calls to Moose::Meta::TypeConstraint::has_parent, avg 12µs/call
222 if $self->has_parent;
223
224198µs return $self->_compile_type($check);
# spent 98µs making 1 call to Moose::Meta::TypeConstraint::_compile_type
225}
226
227
# spent 3.63ms (2.66+961µs) within Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint which was called 86 times, avg 42µs/call: # 86 times (2.66ms+961µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 210, avg 42µs/call
sub _compile_hand_optimized_type_constraint {
2283442.52ms my $self = shift;
229
23086961µs my $type_constraint = $self->hand_optimized_type_constraint;
# spent 961µs making 86 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 11µs/call
231
232 unless ( ref $type_constraint ) {
233 require Moose;
234 Carp::confess ("Hand optimized type constraint for " . $self->name . " is not a code reference");
235 Moose->throw_error("Hand optimized type constraint is not a code reference");
236 }
237
238 return $type_constraint;
239}
240
241
# spent 5.40ms (2.00+3.40) within Moose::Meta::TypeConstraint::_compile_subtype which was called 15 times, avg 360µs/call: # 15 times (2.00ms+3.40ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 221, avg 360µs/call
sub _compile_subtype {
2421732.12ms my ($self, $check) = @_;
243
244 # gather all the parent constraintss in order
245 my @parents;
246 my $optimized_parent;
247152.46ms foreach my $parent ($self->_collect_all_parents) {
# spent 2.46ms making 15 calls to Moose::Meta::TypeConstraint::_collect_all_parents, avg 164µs/call
248 # if a parent is optimized, the optimized constraint already includes
249 # all of its parents tcs, so we can break the loop
25019265µs if ($parent->has_hand_optimized_type_constraint) {
# spent 265µs making 19 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 14µs/call
25110123µs push @parents => $optimized_parent = $parent->hand_optimized_type_constraint;
# spent 123µs making 10 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 12µs/call
252 last;
253 }
254 else {
255999µs push @parents => $parent->constraint;
# spent 99µs making 9 calls to Moose::Meta::TypeConstraint::constraint, avg 11µs/call
256 }
257 }
258
259 @parents = grep { $_ != $null_constraint } reverse @parents;
260
261 unless ( @parents ) {
262 return $self->_compile_type($check);
263 } elsif( $optimized_parent and @parents == 1 ) {
264 # the case of just one optimized parent is optimized to prevent
265 # looping and the unnecessary localization
266 if ( $check == $null_constraint ) {
267 return $optimized_parent;
268 } else {
269 return subname($self->name, sub {
270 return undef unless $optimized_parent->($_[0]);
271 my (@args) = @_;
272 local $_ = $args[0];
273 $check->(@args);
27420325µs });
# spent 187µs making 10 calls to Sub::Name::subname, avg 19µs/call # spent 139µs making 10 calls to Moose::Meta::TypeConstraint::name, avg 14µs/call
275 }
276 } else {
277 # general case, check all the constraints, from the first parent to ourselves
278 my @checks = @parents;
279 push @checks, $check if $check != $null_constraint;
280 return subname($self->name => sub {
28130265µs my (@args) = @_;
282 local $_ = $args[0];
283 foreach my $check (@checks) {
28410115µs return undef unless $check->(@args);
285 }
286 return 1;
28710134µs });
# spent 68µs making 5 calls to Sub::Name::subname, avg 14µs/call # spent 66µs making 5 calls to Moose::Meta::TypeConstraint::name, avg 13µs/call
288 }
289}
290
291
# spent 98µs (72+27) within Moose::Meta::TypeConstraint::_compile_type which was called: # once (72µs+27µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 224
sub _compile_type {
292382µs my ($self, $check) = @_;
293
294 return $check if $check == $null_constraint; # Item, Any
295
296 return subname($self->name => sub {
297 my (@args) = @_;
298 local $_ = $args[0];
299 $check->(@args);
300226µs });
# spent 14µs making 1 call to Moose::Meta::TypeConstraint::name # spent 13µs making 1 call to Sub::Name::subname
301}
302
303## other utils ...
304
305
# spent 2.46ms (1.63+824µs) within Moose::Meta::TypeConstraint::_collect_all_parents which was called 15 times, avg 164µs/call: # 15 times (1.63ms+824µs) by Moose::Meta::TypeConstraint::_compile_subtype at line 247, avg 164µs/call
sub _collect_all_parents {
3061931.40ms my $self = shift;
307 my @parents;
30815172µs my $current = $self->parent;
# spent 172µs making 15 calls to Moose::Meta::TypeConstraint::parent, avg 11µs/call
309 while (defined $current) {
310 push @parents => $current;
31159652µs $current = $current->parent;
# spent 652µs making 59 calls to Moose::Meta::TypeConstraint::parent, avg 11µs/call
312 }
313 return @parents;
314}
315
316
# spent 7.43ms (632µs+6.80) within Moose::Meta::TypeConstraint::create_child_type which was called 17 times, avg 437µs/call: # 17 times (632µs+6.80ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 547 of Moose/Util/TypeConstraints.pm, avg 437µs/call
sub create_child_type {
31751621µs my ($self, %opts) = @_;
318 my $class = ref $self;
319176.79ms return $class->new(%opts, parent => $self);
# spent 6.79ms making 17 calls to Moose::Meta::TypeConstraint::new, avg 400µs/call
320}
321
322158µs1;
323
324__END__