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

Filename/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint.pm
StatementsExecuted 4335 statements in 67.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11191479.40ms9.40msMoose::Meta::TypeConstraint::::__ANON__[:10]Moose::Meta::TypeConstraint::__ANON__[:10]
168117.01ms23.3msMoose::Meta::TypeConstraint::::_actually_compile_type_constraintMoose::Meta::TypeConstraint::_actually_compile_type_constraint
168556.02ms32.1msMoose::Meta::TypeConstraint::::compile_type_constraintMoose::Meta::TypeConstraint::compile_type_constraint
53215.44ms12.1msMoose::Meta::TypeConstraint::::equalsMoose::Meta::TypeConstraint::equals
147114.74ms6.39msMoose::Meta::TypeConstraint::::_compile_hand_optimized_type_constraintMoose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint
98224.53ms13.1msMoose::Meta::TypeConstraint::::checkMoose::Meta::TypeConstraint::check
36733.70ms42.8msMoose::Meta::TypeConstraint::::newMoose::Meta::TypeConstraint::new
18223.07ms17.8msMoose::Meta::TypeConstraint::::is_subtype_ofMoose::Meta::TypeConstraint::is_subtype_of
20112.58ms7.44msMoose::Meta::TypeConstraint::::_compile_subtypeMoose::Meta::TypeConstraint::_compile_subtype
20112.34ms3.57msMoose::Meta::TypeConstraint::::_collect_all_parentsMoose::Meta::TypeConstraint::_collect_all_parents
1112.31ms8.61msMoose::Meta::TypeConstraint::::BEGIN@6Moose::Meta::TypeConstraint::BEGIN@6
106111.81ms2.31msMoose::Meta::TypeConstraint::::__ANON__[:8]Moose::Meta::TypeConstraint::__ANON__[:8]
139411.54ms1.54msMoose::Meta::TypeConstraint::::__ANON__[:32]Moose::Meta::TypeConstraint::__ANON__[:32]
2522975µs14.7msMoose::Meta::TypeConstraint::::create_child_typeMoose::Meta::TypeConstraint::create_child_type
611409µs3.49msMoose::Meta::TypeConstraint::::is_a_type_ofMoose::Meta::TypeConstraint::is_a_type_of
111136µs162µsMoose::Meta::TypeConstraint::::BEGIN@4Moose::Meta::TypeConstraint::BEGIN@4
11193µs439µsMoose::Meta::TypeConstraint::::BEGIN@8Moose::Meta::TypeConstraint::BEGIN@8
11184µs109µsMoose::Meta::TypeConstraint::::_compile_typeMoose::Meta::TypeConstraint::_compile_type
11172µs164µsMoose::Meta::TypeConstraint::::BEGIN@5Moose::Meta::TypeConstraint::BEGIN@5
11157µs310µsMoose::Meta::TypeConstraint::::BEGIN@13Moose::Meta::TypeConstraint::BEGIN@13
11155µs378µsMoose::Meta::TypeConstraint::::BEGIN@16Moose::Meta::TypeConstraint::BEGIN@16
11153µs257µsMoose::Meta::TypeConstraint::::BEGIN@14Moose::Meta::TypeConstraint::BEGIN@14
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
43157µs2188µs
# spent 162µs (136+26) within Moose::Meta::TypeConstraint::BEGIN@4 which was called: # once (136µs+26µs) by Moose::BEGIN@20 at line 4
use strict;
# spent 162µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@4 # spent 26µs making 1 call to strict::import
53157µs2255µs
# spent 164µs (72+91) within Moose::Meta::TypeConstraint::BEGIN@5 which was called: # once (72µs+91µs) by Moose::BEGIN@20 at line 5
use warnings;
# spent 164µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@5 # spent 91µs making 1 call to warnings::import
63962µs213.6ms
# spent 8.61ms (2.31+6.29) within Moose::Meta::TypeConstraint::BEGIN@6 which was called: # once (2.31ms+6.29ms) by Moose::BEGIN@20 at line 6
use metaclass;
# spent 8.61ms making 1 call to Moose::Meta::TypeConstraint::BEGIN@6 # spent 5.03ms making 1 call to metaclass::import
7
81062.52ms106498µs
# spent 439µs (93+346) within Moose::Meta::TypeConstraint::BEGIN@8 which was called: # once (93µs+346µs) by Moose::BEGIN@20 at line 11 # spent 2.31ms (1.81+498µs) within Moose::Meta::TypeConstraint::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint.pm:8] which was called 106 times, avg 22µs/call: # 106 times (1.81ms+498µs) by Moose::Meta::TypeConstraint::equals at line 157, avg 22µs/call
use overload '0+' => sub { refaddr(shift) }, # id an object
# spent 498µs making 106 calls to Scalar::Util::refaddr, avg 5µs/call
9 '""' => sub { shift->name }, # stringify to tc name
10111914.4ms
# spent 9.40ms within Moose::Meta::TypeConstraint::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint.pm:10] which was called 1119 times, avg 8µs/call: # 639 times (5.35ms+0s) by MooseX::Types::Base::import at line 83 of MooseX/Types/Base.pm, avg 8µs/call # 159 times (1.35ms+0s) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 47 of Moose/Meta/TypeConstraint/Registry.pm, avg 8µs/call # 59 times (532µs+0s) by MooseX::Types::TypeDecorator::new at line 76 of MooseX/Types/TypeDecorator.pm, avg 9µs/call # 53 times (452µs+0s) by Moose::Meta::TypeConstraint::equals at line 155, avg 9µs/call # 50 times (364µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 190, avg 7µs/call # 44 times (402µ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 (248µs+0s) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 204 of Moose/Util/TypeConstraints.pm, avg 8µs/call # 24 times (270µs+0s) by Moose::Meta::Method::Accessor::_eval_environment at line 41 of Moose/Meta/Method/Accessor.pm, avg 11µs/call # 18 times (144µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 186, avg 8µs/call # 17 times (112µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 547 of Moose/Util/TypeConstraints.pm, avg 7µs/call # 6 times (54µs+0s) by Moose::Meta::TypeConstraint::is_a_type_of at line 178, avg 9µs/call # 6 times (47µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 58 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 8µs/call # 6 times (43µs+0s) by Moose::Util::TypeConstraints::find_or_create_type_constraint at line 176 of Moose/Util/TypeConstraints.pm, avg 7µs/call # 5 times (36µ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 },
113317µs2785µs fallback => 1;
# spent 439µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@8 # spent 346µs making 1 call to overload::import
12
133172µs2563µs
# spent 310µs (57+253) within Moose::Meta::TypeConstraint::BEGIN@13 which was called: # once (57µs+253µs) by Moose::BEGIN@20 at line 13
use Scalar::Util qw(blessed refaddr);
# spent 310µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@13 # spent 253µs making 1 call to Exporter::import
143175µs2462µs
# spent 257µs (53+205) within Moose::Meta::TypeConstraint::BEGIN@14 which was called: # once (53µs+205µs) by Moose::BEGIN@20 at line 14
use Sub::Name qw(subname);
# spent 257µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14 # spent 205µs making 1 call to Exporter::import
15
1638.70ms2702µs
# spent 378µs (55+324) within Moose::Meta::TypeConstraint::BEGIN@16 which was called: # once (55µs+324µs) by Moose::BEGIN@20 at line 16
use base qw(Class::MOP::Object);
# spent 378µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@16 # spent 324µs making 1 call to base::import
17
1817µsour $VERSION = '1.19';
19191µs$VERSION = eval $VERSION;
# spent 15µs executing statements in string eval
2016µsour $AUTHORITY = 'cpan:STEVAN';
21
22134µs22.86ms__PACKAGE__->meta->add_attribute('name' => (reader => 'name'));
# spent 2.72ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 147µs making 1 call to Moose::Meta::TypeConstraint::meta
23123µs23.70ms__PACKAGE__->meta->add_attribute('parent' => (
# spent 3.58ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 123µ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',
321392.10ms
# spent 1.54ms within Moose::Meta::TypeConstraint::__ANON__[/home/doy/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/Moose/Meta/TypeConstraint.pm:32] which was called 139 times, avg 11µs/call: # 84 times (955µs+0s) by Moose::Meta::TypeConstraint::Role::_new at line 32 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 11µs/call # 48 times (516µs+0s) by Moose::Meta::TypeConstraint::Class::_new or Moose::Meta::TypeConstraint::Enum::_new at line 35 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 11µs/call # 6 times (61µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new at line 29 of (eval 76)[Class/MOP/Method/Generated.pm:53], avg 10µs/call # once (9µs+0s) by Moose::Meta::TypeConstraint::_new at line 26 of (eval 76)[Class/MOP/Method/Generated.pm:53]
default => sub { $null_constraint }
33131µs23.29ms));
# spent 3.20ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 86µs making 1 call to Moose::Meta::TypeConstraint::meta
34124µs23.25ms__PACKAGE__->meta->add_attribute('message' => (
# spent 3.16ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 85µs making 1 call to Moose::Meta::TypeConstraint::meta
35 accessor => 'message',
36 predicate => 'has_message'
37));
38124µs23.21ms__PACKAGE__->meta->add_attribute('coercion' => (
# spent 3.12ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 90µs making 1 call to Moose::Meta::TypeConstraint::meta
39 accessor => 'coercion',
40 predicate => 'has_coercion'
41));
42
43125µs23.88ms__PACKAGE__->meta->add_attribute('hand_optimized_type_constraint' => (
# spent 3.80ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 85µ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
56135µs24.89ms__PACKAGE__->meta->add_attribute('compiled_type_constraint' => (
# spent 4.76ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 133µs making 1 call to Moose::Meta::TypeConstraint::meta
57 accessor => '_compiled_type_constraint',
58 predicate => '_has_compiled_type_constraint'
59));
60124µs22.14ms__PACKAGE__->meta->add_attribute('package_defined_in' => (
# spent 2.04ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 91µs making 1 call to Moose::Meta::TypeConstraint::meta
61 accessor => '_package_defined_in'
62));
63
64
# spent 42.8ms (3.70+39.1) within Moose::Meta::TypeConstraint::new which was called 36 times, avg 1.19ms/call: # 25 times (2.51ms+11.3ms) by Moose::Meta::TypeConstraint::create_child_type at line 319, avg 551µs/call # 6 times (721µs+25.7ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 69 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 4.40ms/call # once (81µs+627µs) by Moose::Meta::Attribute::BEGIN@20 at line 847 of Moose/Util/TypeConstraints.pm # once (118µs+586µs) by Moose::Meta::Attribute::BEGIN@20 at line 788 of Moose/Util/TypeConstraints.pm # once (104µs+555µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 557 of Moose/Util/TypeConstraints.pm # once (87µs+201µs) by Moose::Meta::Attribute::BEGIN@20 at line 809 of Moose/Util/TypeConstraints.pm # once (82µs+197µs) by Moose::Meta::Attribute::BEGIN@20 at line 830 of Moose/Util/TypeConstraints.pm
sub new {
6536123µs my $class = shift;
6636346µs my ($first, @rest) = @_;
6736382µs my %args = ref $first ? %$first : $first ? ($first, @rest) : ();
6836366µs16792µs $args{name} = $args{name} ? "$args{name}" : "__ANON__";
# spent 700µs making 8 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:26], avg 88µs/call # spent 92µs making 8 calls to MooseX::Types::TypeDecorator::__ANON__[MooseX/Types/TypeDecorator.pm:27], avg 12µs/call
69
7036659µs364.08ms my $self = $class->_new(%args);
# spent 2.17ms making 25 calls to Moose::Meta::TypeConstraint::_new, avg 87µs/call # spent 988µs making 6 calls to Moose::Meta::TypeConstraint::Parameterized::_new, avg 165µs/call # spent 921µs making 5 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 184µs/call
7136838µs7234.3ms $self->compile_type_constraint()
# spent 24.6ms making 6 calls to Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint, avg 4.11ms/call # spent 9.20ms making 30 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 307µs/call # spent 415µs making 36 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 12µs/call
72 unless $self->_has_compiled_type_constraint;
7336661µ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 13.1ms (4.53+8.58) within Moose::Meta::TypeConstraint::check which was called 98 times, avg 134µs/call: # 92 times (4.26ms+7.74ms) by Moose::Meta::Attribute::verify_against_type_constraint at line 896 of Moose/Meta/Attribute.pm, avg 131µs/call # 6 times (262µs+834µs) by MooseX::Types::TypeDecorator::AUTOLOAD at line 206 of MooseX/Types/TypeDecorator.pm, avg 183µs/call
sub check {
11398550µs my ($self, @args) = @_;
114981.22ms981.44ms my $constraint_subref = $self->_compiled_type_constraint;
# spent 1.44ms making 98 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 15µs/call
115982.27ms987.14ms return $constraint_subref->(@args) ? 1 : undef;
# spent 5.77ms making 84 calls to Moose::Meta::TypeConstraint::Class::__ANON__[Moose/Meta/TypeConstraint/Class.pm:38], avg 69µs/call # spent 748µs making 6 calls to Moose::Meta::TypeConstraint::ArrayRef[Str], avg 125µs/call # spent 541µs making 6 calls to Moose::Meta::TypeConstraint::Bool, avg 90µ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.1ms (5.44+6.71) within Moose::Meta::TypeConstraint::equals which was called 53 times, avg 229µs/call: # 50 times (5.18ms+6.37ms) by Moose::Meta::TypeConstraint::is_subtype_of at line 191, avg 231µs/call # 3 times (259µs+342µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 180, avg 200µs/call
sub equals {
15353170µs my ( $self, $type_or_name ) = @_;
154
15553938µs1062.46ms my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 2.01ms making 53 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 38µs/call # spent 452µs making 53 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 9µs/call
156
157531.33ms1062.31ms return 1 if $self == $other;
# spent 2.31ms making 106 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 22µs/call
158
15941934µs921.05ms if ( $self->has_hand_optimized_type_constraint and $other->has_hand_optimized_type_constraint ) {
# spent 595µs making 58 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 10µs/call # spent 450µs making 34 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 13µs/call
160 return 1 if $self->hand_optimized_type_constraint == $other->hand_optimized_type_constraint;
161 }
162
163411.10ms82895µs return unless $self->constraint == $other->constraint;
# spent 895µ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.49ms (409µs+3.08) within Moose::Meta::TypeConstraint::is_a_type_of which was called 6 times, avg 582µs/call: # 6 times (409µs+3.08ms) by MooseX::Types::TypeDecorator::AUTOLOAD at line 206 of MooseX/Types/TypeDecorator.pm, avg 582µs/call
sub is_a_type_of {
176627µs my ($self, $type_or_name) = @_;
177
1786124µs12917µs my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 862µs making 6 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 144µs/call # spent 54µs making 6 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 9µs/call
179
1806168µs102.16ms ($self->equals($type) || $self->is_subtype_of($type));
# spent 1.28ms making 4 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 319µs/call # spent 601µs making 3 calls to Moose::Meta::TypeConstraint::equals, avg 200µs/call # spent 285µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::equals, avg 95µs/call
181}
182
183
# spent 17.8ms (3.07+14.7) within Moose::Meta::TypeConstraint::is_subtype_of which was called 18 times, avg 989µs/call: # 14 times (2.74ms+13.8ms) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 25 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 1.18ms/call # 4 times (332µs+946µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 180, avg 319µs/call
sub is_subtype_of {
1841870µs my ($self, $type_or_name) = @_;
185
18618349µs362.16ms my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 2.02ms making 18 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 112µs/call # spent 144µs making 18 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 8µs/call
187
1881841µs my $current = $self;
189
190181.18ms1081.02ms while (my $parent = $current->parent) {
# spent 659µs making 58 calls to Moose::Meta::TypeConstraint::parent, avg 11µs/call # spent 364µs making 50 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 7µs/call
19150656µs5011.5ms return 1 if $parent->equals($type);
# spent 11.5ms making 50 calls to Moose::Meta::TypeConstraint::equals, avg 231µs/call
19240112µs $current = $parent;
193 }
194
195895µs return 0;
196}
197
198## compiling the type constraint
199
200
# spent 32.1ms (6.02+26.1) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 168 times, avg 191µs/call: # 84 times (3.07ms+8.97ms) by Moose::Meta::TypeConstraint::Role::new at line 27 of Moose/Meta/TypeConstraint/Role.pm, avg 143µs/call # 47 times (1.68ms+5.19ms) by Moose::Meta::TypeConstraint::Class::new at line 27 of Moose/Meta/TypeConstraint/Class.pm, avg 146µs/call # 30 times (993µs+8.21ms) by Moose::Meta::TypeConstraint::new at line 71, avg 307µs/call # 6 times (224µs+2.98ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 54 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 534µs/call # once (52µs+745µs) by Moose::Meta::TypeConstraint::Enum::new at line 42 of Moose/Meta/TypeConstraint/Enum.pm
sub compile_type_constraint {
201168510µs my $self = shift;
2021685.00ms33626.1ms $self->_compiled_type_constraint($self->_actually_compile_type_constraint);
# spent 23.3ms making 168 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 139µs/call # spent 2.75ms making 168 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 16µs/call
203}
204
205## type compilers ...
206
207
# spent 23.3ms (7.01+16.3) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 168 times, avg 139µs/call: # 168 times (7.01ms+16.3ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 202, avg 139µs/call
sub _actually_compile_type_constraint {
208168500µs my $self = shift;
209
2101684.62ms3158.21ms return $self->_compile_hand_optimized_type_constraint
# spent 6.39ms making 147 calls to Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint, avg 43µs/call # spent 1.82ms making 168 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 11µs/call
211 if $self->has_hand_optimized_type_constraint;
212
21321275µs21324µs my $check = $self->constraint;
# spent 259µ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
2142145µ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
22121686µs417.69ms return $self->_compile_subtype($check)
# spent 7.44ms making 20 calls to Moose::Meta::TypeConstraint::_compile_subtype, avg 372µs/call # spent 250µs making 21 calls to Moose::Meta::TypeConstraint::has_parent, avg 12µ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 6.39ms (4.74+1.65) within Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint which was called 147 times, avg 43µs/call: # 147 times (4.74ms+1.65ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 210, avg 43µs/call
sub _compile_hand_optimized_type_constraint {
228147388µs my $self = shift;
229
2301471.50ms1471.65ms my $type_constraint = $self->hand_optimized_type_constraint;
# spent 1.65ms making 147 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 11µs/call
231
232147448µ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
2381471.92ms return $type_constraint;
239}
240
241
# spent 7.44ms (2.58+4.86) within Moose::Meta::TypeConstraint::_compile_subtype which was called 20 times, avg 372µs/call: # 20 times (2.58ms+4.86ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 221, avg 372µs/call
sub _compile_subtype {
2422079µs my ($self, $check) = @_;
243
244 # gather all the parent constraintss in order
2452045µs my @parents;
2462037µs my $optimized_parent;
24720286µs203.57ms foreach my $parent ($self->_collect_all_parents) {
# spent 3.57ms making 20 calls to Moose::Meta::TypeConstraint::_collect_all_parents, avg 178µ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
25024313µs24248µs if ($parent->has_hand_optimized_type_constraint) {
# spent 248µs making 24 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 10µs/call
25114174µs14172µs push @parents => $optimized_parent = $parent->hand_optimized_type_constraint;
# spent 172µs making 14 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 12µs/call
2521482µs last;
253 }
254 else {
25510107µs10106µs push @parents => $parent->constraint;
# spent 106µs making 10 calls to Moose::Meta::TypeConstraint::constraint, avg 11µs/call
256 }
257 }
258
25920144µ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 {
270670µs675µs return undef unless $optimized_parent->($_[0]);
# spent 75µs making 6 calls to Moose::Util::TypeConstraints::OptimizedConstraints::ArrayRef, avg 12µs/call
271627µs my (@args) = @_;
272621µs local $_ = $args[0];
2736189µs6354µs $check->(@args);
# spent 354µs making 6 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:806], avg 59µs/call
27414910µs29706µs });
# spent 414µs making 14 calls to Sub::Name::subname, avg 30µs/call # spent 186µs making 14 calls to Moose::Meta::TypeConstraint::name, avg 13µs/call # spent 105µ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
278622µs my @checks = @parents;
279619µs push @checks, $check if $check != $null_constraint;
280 return subname($self->name => sub {
281625µs my (@args) = @_;
282621µs local $_ = $args[0];
283634µs foreach my $check (@checks) {
28412188µs12158µs return undef unless $check->(@args);
# spent 97µs making 6 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:714], avg 16µs/call # spent 61µs making 6 calls to Moose::Util::TypeConstraints::__ANON__[Moose/Util/TypeConstraints.pm:707], avg 10µs/call
285 }
286687µs return 1;
2876346µs12164µs });
# spent 89µs making 6 calls to Sub::Name::subname, avg 15µs/call # spent 74µs making 6 calls to Moose::Meta::TypeConstraint::name, avg 12µs/call
288 }
289}
290
291
# spent 109µs (84+25) within Moose::Meta::TypeConstraint::_compile_type which was called: # once (84µs+25µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 224
sub _compile_type {
29214µs my ($self, $check) = @_;
293
29412µ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);
300188µs225µs });
# spent 13µs making 1 call to Sub::Name::subname # spent 12µs making 1 call to Moose::Meta::TypeConstraint::name
301}
302
303## other utils ...
304
305
# spent 3.57ms (2.34+1.23) within Moose::Meta::TypeConstraint::_collect_all_parents which was called 20 times, avg 178µs/call: # 20 times (2.34ms+1.23ms) by Moose::Meta::TypeConstraint::_compile_subtype at line 247, avg 178µs/call
sub _collect_all_parents {
3062055µs my $self = shift;
3072035µs my @parents;
30820236µs20306µs my $current = $self->parent;
# spent 306µs making 20 calls to Moose::Meta::TypeConstraint::parent, avg 15µs/call
3092087µs while (defined $current) {
31086256µs push @parents => $current;
311861.08ms86923µs $current = $current->parent;
# spent 923µs making 86 calls to Moose::Meta::TypeConstraint::parent, avg 11µs/call
312 }
31320282µs return @parents;
314}
315
316
# spent 14.7ms (975µs+13.8) within Moose::Meta::TypeConstraint::create_child_type which was called 25 times, avg 590µs/call: # 17 times (669µs+6.55ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 547 of Moose/Util/TypeConstraints.pm, avg 425µs/call # 8 times (306µs+7.22ms) by MooseX::Types::TypeDecorator::AUTOLOAD at line 206 of MooseX/Types/TypeDecorator.pm, avg 940µs/call
sub create_child_type {
31725208µs my ($self, %opts) = @_;
3182580µs my $class = ref $self;
31925680µs2513.8ms return $class->new(%opts, parent => $self);
# spent 13.8ms making 25 calls to Moose::Meta::TypeConstraint::new, avg 551µs/call
320}
321
322157µs1;
323
324__END__