← Index
NYTProf Performance Profile   « block view • line view • sub view »
For -e
  Run on Wed Nov 17 22:00:36 2010
Reported on Wed Nov 17 22:13:21 2010

Filename/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint.pm
StatementsExecuted 3906 statements in 56.7ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10771479.20ms9.20msMoose::Meta::TypeConstraint::::__ANON__[:10]Moose::Meta::TypeConstraint::__ANON__[:10]
53215.35ms12.0msMoose::Meta::TypeConstraint::::equalsMoose::Meta::TypeConstraint::equals
125115.28ms19.1msMoose::Meta::TypeConstraint::::_actually_compile_type_constraintMoose::Meta::TypeConstraint::_actually_compile_type_constraint
98224.51ms12.9msMoose::Meta::TypeConstraint::::checkMoose::Meta::TypeConstraint::check
125554.48ms25.7msMoose::Meta::TypeConstraint::::compile_type_constraintMoose::Meta::TypeConstraint::compile_type_constraint
36733.62ms43.0msMoose::Meta::TypeConstraint::::newMoose::Meta::TypeConstraint::new
104113.16ms4.34msMoose::Meta::TypeConstraint::::_compile_hand_optimized_type_constraintMoose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint
18223.11ms17.6msMoose::Meta::TypeConstraint::::is_subtype_ofMoose::Meta::TypeConstraint::is_subtype_of
20112.63ms7.36msMoose::Meta::TypeConstraint::::_compile_subtypeMoose::Meta::TypeConstraint::_compile_subtype
20112.27ms3.41msMoose::Meta::TypeConstraint::::_collect_all_parentsMoose::Meta::TypeConstraint::_collect_all_parents
106111.80ms2.25msMoose::Meta::TypeConstraint::::__ANON__[:8]Moose::Meta::TypeConstraint::__ANON__[:8]
1111.55ms5.45msMoose::Meta::TypeConstraint::::BEGIN@6Moose::Meta::TypeConstraint::BEGIN@6
96211.00ms1.00msMoose::Meta::TypeConstraint::::__ANON__[:32]Moose::Meta::TypeConstraint::__ANON__[:32]
2522971µs15.0msMoose::Meta::TypeConstraint::::create_child_typeMoose::Meta::TypeConstraint::create_child_type
611387µs3.46msMoose::Meta::TypeConstraint::::is_a_type_ofMoose::Meta::TypeConstraint::is_a_type_of
11182µs109µsMoose::Meta::TypeConstraint::::_compile_typeMoose::Meta::TypeConstraint::_compile_type
11177µs96µsMoose::Meta::TypeConstraint::::BEGIN@4Moose::Meta::TypeConstraint::BEGIN@4
11152µs289µsMoose::Meta::TypeConstraint::::BEGIN@8Moose::Meta::TypeConstraint::BEGIN@8
11143µs112µsMoose::Meta::TypeConstraint::::BEGIN@5Moose::Meta::TypeConstraint::BEGIN@5
11142µs237µsMoose::Meta::TypeConstraint::::BEGIN@13Moose::Meta::TypeConstraint::BEGIN@13
11139µs172µsMoose::Meta::TypeConstraint::::BEGIN@14Moose::Meta::TypeConstraint::BEGIN@14
11138µs269µ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
43132µs2115µs
# spent 96µs (77+19) within Moose::Meta::TypeConstraint::BEGIN@4 which was called: # once (77µs+19µs) by Moose::BEGIN@20 at line 4
use strict;
# spent 96µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@4 # spent 19µs making 1 call to strict::import
5398µs2182µs
# spent 112µs (43+70) within Moose::Meta::TypeConstraint::BEGIN@5 which was called: # once (43µs+70µs) by Moose::BEGIN@20 at line 5
use warnings;
# spent 112µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@5 # spent 70µs making 1 call to warnings::import
63631µs28.57ms
# spent 5.45ms (1.55+3.90) within Moose::Meta::TypeConstraint::BEGIN@6 which was called: # once (1.55ms+3.90ms) by Moose::BEGIN@20 at line 6
use metaclass;
# spent 5.45ms making 1 call to Moose::Meta::TypeConstraint::BEGIN@6 # spent 3.13ms making 1 call to metaclass::import
7
81062.50ms106450µs
# spent 2.25ms (1.80+450µs) within Moose::Meta::TypeConstraint::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint.pm:8] which was called 106 times, avg 21µs/call: # 106 times (1.80ms+450µs) by Moose::Meta::TypeConstraint::equals at line 157, avg 21µs/call # spent 289µs (52+237) within Moose::Meta::TypeConstraint::BEGIN@8 which was called: # once (52µs+237µs) by Moose::BEGIN@20 at line 11
use overload '0+' => sub { refaddr(shift) }, # id an object
# spent 450µs making 106 calls to Scalar::Util::refaddr, avg 4µs/call
9 '""' => sub { shift->name }, # stringify to tc name
10107713.7ms
# spent 9.20ms within Moose::Meta::TypeConstraint::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint.pm:10] which was called 1077 times, avg 9µs/call: # 639 times (5.56ms+0s) by MooseX::Types::Base::import at line 83 of MooseX/Types/Base.pm, avg 9µs/call # 116 times (971µs+0s) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 47 of Moose/Meta/TypeConstraint/Registry.pm, avg 8µs/call # 59 times (526µs+0s) by MooseX::Types::TypeDecorator::new at line 76 of MooseX/Types/TypeDecorator.pm, avg 9µs/call # 53 times (395µs+0s) by Moose::Meta::TypeConstraint::equals at line 155, avg 7µs/call # 50 times (365µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 190, avg 7µs/call # 44 times (404µs+0s) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 218 of Moose/Util/TypeConstraints.pm, avg 9µs/call # 33 times (240µs+0s) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 204 of Moose/Util/TypeConstraints.pm, avg 7µs/call # 25 times (279µs+0s) by Moose::Meta::Method::Accessor::_eval_environment at line 46 of Moose/Meta/Method/Accessor.pm, avg 11µs/call # 18 times (143µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 186, avg 8µs/call # 17 times (118µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 547 of Moose/Util/TypeConstraints.pm, avg 7µs/call # 6 times (57µs+0s) by Moose::Meta::TypeConstraint::is_a_type_of at line 178, avg 10µs/call # 6 times (51µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 58 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 8µs/call # 6 times (48µs+0s) by Moose::Util::TypeConstraints::find_or_create_type_constraint at line 176 of Moose/Util/TypeConstraints.pm, avg 8µs/call # 5 times (38µs+0s) by Moose::Util::TypeConstraints::find_or_create_does_type_constraint at line 210 of Moose/Util/TypeConstraints.pm, avg 7µs/call
bool => sub { 1 },
113151µs2525µs fallback => 1;
# spent 289µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@8 # spent 237µs making 1 call to overload::import
12
133112µs2431µs
# spent 237µs (42+194) within Moose::Meta::TypeConstraint::BEGIN@13 which was called: # once (42µs+194µs) by Moose::BEGIN@20 at line 13
use Scalar::Util qw(blessed refaddr);
# spent 237µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@13 # spent 194µs making 1 call to Exporter::import
143104µs2305µs
# spent 172µs (39+133) within Moose::Meta::TypeConstraint::BEGIN@14 which was called: # once (39µs+133µs) by Moose::BEGIN@20 at line 14
use Sub::Name qw(subname);
# spent 172µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14 # spent 133µs making 1 call to Exporter::import
15
1634.98ms2501µs
# spent 269µs (38+232) within Moose::Meta::TypeConstraint::BEGIN@16 which was called: # once (38µs+232µs) by Moose::BEGIN@20 at line 16
use base qw(Class::MOP::Object);
# spent 269µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@16 # spent 232µs making 1 call to base::import
17
1815µsour $VERSION = '1.19';
19164µs$VERSION = eval $VERSION;
# spent 11µs executing statements in string eval
2014µsour $AUTHORITY = 'cpan:STEVAN';
21
22127µs22.53ms__PACKAGE__->meta->add_attribute('name' => (reader => 'name'));
# spent 2.41ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 122µs making 1 call to Moose::Meta::TypeConstraint::meta
23124µs23.08ms__PACKAGE__->meta->add_attribute('parent' => (
# spent 3.00ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 88µs making 1 call to Moose::Meta::TypeConstraint::meta
24 reader => 'parent',
25 predicate => 'has_parent',
26));
27
2819µsmy $null_constraint = sub { 1 };
29__PACKAGE__->meta->add_attribute('constraint' => (
30 reader => 'constraint',
31 writer => '_set_constraint',
32961.35ms
# spent 1.00ms within Moose::Meta::TypeConstraint::__ANON__[/home/doy/coding/src/Moose/blib/lib//Moose/Meta/TypeConstraint.pm:32] which was called 96 times, avg 10µs/call: # 49 times (506µs+0s) by Moose::Meta::TypeConstraint::Enum::_new or Moose::Meta::TypeConstraint::Parameterized::_new or Moose::Meta::TypeConstraint::Role::_new or Moose::Meta::TypeConstraint::_new at line 18 of generated method (unknown origin), avg 10µs/call # 47 times (497µs+0s) by Moose::Meta::TypeConstraint::Class::_new at line 21 of generated method (unknown origin), avg 11µs/call
default => sub { $null_constraint }
33132µs23.08ms));
# spent 2.99ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 89µs making 1 call to Moose::Meta::TypeConstraint::meta
34123µs23.57ms__PACKAGE__->meta->add_attribute('message' => (
# spent 3.48ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 86µs making 1 call to Moose::Meta::TypeConstraint::meta
35 accessor => 'message',
36 predicate => 'has_message'
37));
38136µs24.50ms__PACKAGE__->meta->add_attribute('coercion' => (
# spent 4.37ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 125µs making 1 call to Moose::Meta::TypeConstraint::meta
39 accessor => 'coercion',
40 predicate => 'has_coercion'
41));
42
43132µs24.17ms__PACKAGE__->meta->add_attribute('hand_optimized_type_constraint' => (
# spent 4.05ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 120µ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
56134µs24.00ms__PACKAGE__->meta->add_attribute('compiled_type_constraint' => (
# spent 3.89ms 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));
60132µs22.81ms__PACKAGE__->meta->add_attribute('package_defined_in' => (
# spent 2.69ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 123µs making 1 call to Moose::Meta::TypeConstraint::meta
61 accessor => '_package_defined_in'
62));
63
64
# spent 43.0ms (3.62+39.4) within Moose::Meta::TypeConstraint::new which was called 36 times, avg 1.19ms/call: # 25 times (2.41ms+11.6ms) by Moose::Meta::TypeConstraint::create_child_type at line 319, avg 560µs/call # 6 times (739µs+25.6ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 69 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 4.39ms/call # once (95µs+622µs) by Moose::Meta::Attribute::BEGIN@20 at line 847 of Moose/Util/TypeConstraints.pm # once (113µs+573µs) by Moose::Meta::Attribute::BEGIN@20 at line 788 of Moose/Util/TypeConstraints.pm # once (101µs+564µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 557 of Moose/Util/TypeConstraints.pm # once (81µs+233µs) by Moose::Meta::Attribute::BEGIN@20 at line 830 of Moose/Util/TypeConstraints.pm # once (83µs+219µs) by Moose::Meta::Attribute::BEGIN@20 at line 809 of Moose/Util/TypeConstraints.pm
sub new {
6536124µs my $class = shift;
6636350µs my ($first, @rest) = @_;
6736384µs my %args = ref $first ? %$first : $first ? ($first, @rest) : ();
6836323µs16738µs $args{name} = $args{name} ? "$args{name}" : "__ANON__";
# spent 680µs making 8 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:26], avg 85µs/call # spent 57µs making 8 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:27], avg 7µs/call
69
7036625µs364.83ms my $self = $class->_new(%args);
# spent 2.68ms making 25 calls to Moose::Meta::TypeConstraint::_new, avg 107µs/call # spent 1.13ms making 6 calls to Moose::Meta::TypeConstraint::Parameterized::_new, avg 188µs/call # spent 1.03ms making 5 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 206µs/call
7136818µs7233.8ms $self->compile_type_constraint()
# spent 24.4ms making 6 calls to Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint, avg 4.06ms/call # spent 9.01ms making 30 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 300µs/call # spent 414µs making 36 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 11µs/call
72 unless $self->_has_compiled_type_constraint;
7336656µs 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 12.9ms (4.51+8.39) within Moose::Meta::TypeConstraint::check which was called 98 times, avg 132µs/call: # 92 times (4.26ms+7.62ms) by Moose::Meta::Attribute::verify_against_type_constraint at line 1141 of Moose/Meta/Attribute.pm, avg 129µs/call # 6 times (259µs+776µs) by MooseX::Types::TypeDecorator::AUTOLOAD at line 206 of MooseX/Types/TypeDecorator.pm, avg 173µs/call
sub check {
11398499µs my ($self, @args) = @_;
114981.30ms981.34ms my $constraint_subref = $self->_compiled_type_constraint;
# spent 1.34ms making 98 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 14µs/call
115982.22ms987.06ms return $constraint_subref->(@args) ? 1 : undef;
# spent 5.73ms making 84 calls to Moose::Meta::TypeConstraint::Class::__ANON__[Moose/Meta/TypeConstraint/Class.pm:38], avg 68µs/call # spent 695µs making 6 calls to Moose::Meta::TypeConstraint::ArrayRef[Str], avg 116µs/call # spent 552µs making 6 calls to Moose::Meta::TypeConstraint::Bool, avg 92µs/call # spent 80µs making 2 calls to Moose::Util::TypeConstraints::OptimizedConstraints::ClassName, avg 40µ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 12.0ms (5.35+6.61) within Moose::Meta::TypeConstraint::equals which was called 53 times, avg 226µs/call: # 50 times (5.09ms+6.25ms) by Moose::Meta::TypeConstraint::is_subtype_of at line 191, avg 227µs/call # 3 times (262µs+357µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 180, avg 206µs/call
sub equals {
15353166µs my ( $self, $type_or_name ) = @_;
154
15553938µs1062.42ms my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 2.02ms making 53 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 38µs/call # spent 395µs making 53 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call
156
157531.25ms1062.25ms return 1 if $self == $other;
# spent 2.25ms making 106 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 21µs/call
158
15941900µs921.04ms if ( $self->has_hand_optimized_type_constraint and $other->has_hand_optimized_type_constraint ) {
# spent 614µs making 58 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 11µs/call # spent 424µs making 34 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 12µs/call
160 return 1 if $self->hand_optimized_type_constraint == $other->hand_optimized_type_constraint;
161 }
162
163411.12ms82901µs return unless $self->constraint == $other->constraint;
# spent 901µs making 82 calls to Moose::Meta::TypeConstraint::constraint, avg 11µ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 3.46ms (387µs+3.08) within Moose::Meta::TypeConstraint::is_a_type_of which was called 6 times, avg 577µs/call: # 6 times (387µs+3.08ms) by MooseX::Types::TypeDecorator::AUTOLOAD at line 206 of MooseX/Types/TypeDecorator.pm, avg 577µs/call
sub is_a_type_of {
176626µs my ($self, $type_or_name) = @_;
177
1786123µs12854µs my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 796µs making 6 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 133µs/call # spent 57µs making 6 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 10µs/call
179
1806163µs102.22ms ($self->equals($type) || $self->is_subtype_of($type));
# spent 1.33ms making 4 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 332µs/call # spent 619µs making 3 calls to Moose::Meta::TypeConstraint::equals, avg 206µs/call # spent 278µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::equals, avg 93µs/call
181}
182
183
# spent 17.6ms (3.11+14.5) within Moose::Meta::TypeConstraint::is_subtype_of which was called 18 times, avg 977µs/call: # 14 times (2.70ms+13.6ms) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 1.16ms/call # 4 times (405µs+923µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 180, avg 332µs/call
sub is_subtype_of {
1841866µs my ($self, $type_or_name) = @_;
185
18618355µs362.11ms my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 1.97ms making 18 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 109µs/call # spent 143µs making 18 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call
187
1881843µs my $current = $self;
189
190181.16ms1081.03ms while (my $parent = $current->parent) {
# spent 668µs making 58 calls to Moose::Meta::TypeConstraint::parent, avg 12µs/call # spent 365µs making 50 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call
19150669µs5011.3ms return 1 if $parent->equals($type);
# spent 11.3ms making 50 calls to Moose::Meta::TypeConstraint::equals, avg 227µs/call
19240136µs $current = $parent;
193 }
194
195896µs return 0;
196}
197
198## compiling the type constraint
199
200
# spent 25.7ms (4.48+21.2) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 125 times, avg 206µs/call: # 47 times (1.76ms+5.01ms) by Moose::Meta::TypeConstraint::Class::new at line 27 of Moose/Meta/TypeConstraint/Class.pm, avg 144µs/call # 41 times (1.43ms+4.44ms) by Moose::Meta::TypeConstraint::Role::new at line 27 of Moose/Meta/TypeConstraint/Role.pm, avg 143µs/call # 30 times (985µs+8.03ms) by Moose::Meta::TypeConstraint::new at line 71, avg 300µs/call # 6 times (251µs+3.02ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 54 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 546µs/call # once (51µs+718µs) by Moose::Meta::TypeConstraint::Enum::new at line 42 of Moose/Meta/TypeConstraint/Enum.pm
sub compile_type_constraint {
201125387µs my $self = shift;
2021253.74ms25021.2ms $self->_compiled_type_constraint($self->_actually_compile_type_constraint);
# spent 19.1ms making 125 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 153µs/call # spent 2.08ms making 125 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 17µs/call
203}
204
205## type compilers ...
206
207
# spent 19.1ms (5.28+13.9) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 125 times, avg 153µs/call: # 125 times (5.28ms+13.9ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 202, avg 153µs/call
sub _actually_compile_type_constraint {
208125353µs my $self = shift;
209
2101253.28ms2295.84ms return $self->_compile_hand_optimized_type_constraint
# spent 4.34ms making 104 calls to Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint, avg 42µs/call # spent 1.50ms making 125 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 12µs/call
211 if $self->has_hand_optimized_type_constraint;
212
21321254µs21322µs my $check = $self->constraint;
# spent 258µs making 20 calls to Moose::Meta::TypeConstraint::constraint, avg 13µs/call # spent 65µs making 1 call to Moose::Meta::TypeConstraint::Enum::constraint
2142146µs 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
22121663µs417.60ms return $self->_compile_subtype($check)
# spent 7.36ms making 20 calls to Moose::Meta::TypeConstraint::_compile_subtype, avg 368µs/call # spent 233µs making 21 calls to Moose::Meta::TypeConstraint::has_parent, avg 11µs/call
222 if $self->has_parent;
223
224125µs1109µs return $self->_compile_type($check);
# spent 109µs making 1 call to Moose::Meta::TypeConstraint::_compile_type
225}
226
227
# spent 4.34ms (3.16+1.18) within Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint which was called 104 times, avg 42µs/call: # 104 times (3.16ms+1.18ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 210, avg 42µs/call
sub _compile_hand_optimized_type_constraint {
228104278µs my $self = shift;
229
2301041.14ms1041.18ms my $type_constraint = $self->hand_optimized_type_constraint;
# spent 1.18ms making 104 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 11µs/call
231
232104298µs 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
2381041.28ms return $type_constraint;
239}
240
241
# spent 7.36ms (2.63+4.73) within Moose::Meta::TypeConstraint::_compile_subtype which was called 20 times, avg 368µs/call: # 20 times (2.63ms+4.73ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 221, avg 368µs/call
sub _compile_subtype {
2422076µs my ($self, $check) = @_;
243
244 # gather all the parent constraintss in order
2452039µs my @parents;
2462038µs my $optimized_parent;
24720281µs203.41ms foreach my $parent ($self->_collect_all_parents) {
# spent 3.41ms making 20 calls to Moose::Meta::TypeConstraint::_collect_all_parents, avg 171µ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
25024319µs24256µs if ($parent->has_hand_optimized_type_constraint) {
# spent 256µs making 24 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 11µs/call
25114176µs14183µs push @parents => $optimized_parent = $parent->hand_optimized_type_constraint;
# spent 183µs making 14 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 13µs/call
2521485µs last;
253 }
254 else {
25510107µs10110µs push @parents => $parent->constraint;
# spent 110µs making 10 calls to Moose::Meta::TypeConstraint::constraint, avg 11µs/call
256 }
257 }
258
25920179µs @parents = grep { $_ != $null_constraint } reverse @parents;
260
2612083µs 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
2661430µs if ( $check == $null_constraint ) {
267 return $optimized_parent;
268 } else {
269 return subname($self->name, sub {
270672µs677µs return undef unless $optimized_parent->($_[0]);
# spent 77µs making 6 calls to Moose::Util::TypeConstraints::OptimizedConstraints::ArrayRef, avg 13µs/call
271626µs my (@args) = @_;
272619µs local $_ = $args[0];
2736137µs6330µs $check->(@args);
# spent 330µs making 6 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:806], avg 55µs/call
27414904µs29703µs });
# spent 406µs making 14 calls to Sub::Name::subname, avg 29µs/call # spent 196µs making 14 calls to Moose::Meta::TypeConstraint::name, avg 14µs/call # spent 101µs making 1 call to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:26]
275 }
276 } else {
277 # general case, check all the constraints, from the first parent to ourselves
278623µs my @checks = @parents;
279616µs push @checks, $check if $check != $null_constraint;
280 return subname($self->name => sub {
281627µs my (@args) = @_;
282622µs local $_ = $args[0];
283639µs foreach my $check (@checks) {
28412190µs12165µs return undef unless $check->(@args);
# spent 103µs making 6 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:714], avg 17µs/call # spent 62µs making 6 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:707], avg 10µs/call
285 }
286677µs return 1;
2876370µs12167µs });
# spent 87µs making 6 calls to Sub::Name::subname, avg 15µs/call # spent 80µs making 6 calls to Moose::Meta::TypeConstraint::name, avg 13µs/call
288 }
289}
290
291
# spent 109µs (82+26) within Moose::Meta::TypeConstraint::_compile_type which was called: # once (82µs+26µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 224
sub _compile_type {
29214µs my ($self, $check) = @_;
293
29413µs 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);
300186µs226µs });
# spent 13µ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 3.41ms (2.27+1.15) within Moose::Meta::TypeConstraint::_collect_all_parents which was called 20 times, avg 171µs/call: # 20 times (2.27ms+1.15ms) by Moose::Meta::TypeConstraint::_compile_subtype at line 247, avg 171µs/call
sub _collect_all_parents {
3062055µs my $self = shift;
3072033µs my @parents;
30820214µs20233µs my $current = $self->parent;
# spent 233µs making 20 calls to Moose::Meta::TypeConstraint::parent, avg 12µs/call
3092083µs while (defined $current) {
31086246µs push @parents => $current;
311861.01ms86914µs $current = $current->parent;
# spent 914µs making 86 calls to Moose::Meta::TypeConstraint::parent, avg 11µs/call
312 }
31320302µs return @parents;
314}
315
316
# spent 15.0ms (971µs+14.0) within Moose::Meta::TypeConstraint::create_child_type which was called 25 times, avg 599µs/call: # 17 times (664µs+6.81ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 547 of Moose/Util/TypeConstraints.pm, avg 440µs/call # 8 times (307µs+7.19ms) by MooseX::Types::TypeDecorator::AUTOLOAD at line 206 of MooseX/Types/TypeDecorator.pm, avg 937µs/call
sub create_child_type {
31725268µs my ($self, %opts) = @_;
3182584µs my $class = ref $self;
31925611µs2514.0ms return $class->new(%opts, parent => $self);
# spent 14.0ms making 25 calls to Moose::Meta::TypeConstraint::new, avg 560µs/call
320}
321
322178µs1;
323
324__END__