← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:13 2014

Filename/usr/local/lib/perl/5.14.2/Moose/Meta/TypeConstraint.pm
StatementsExecuted 4036 statements in 8.83ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
480733.03ms4.60msMoose::Meta::TypeConstraint::::can_be_inlinedMoose::Meta::TypeConstraint::can_be_inlined (recurses: max depth 1, inclusive time 143µs)
2621042.62ms6.89msMoose::Meta::TypeConstraint::::_inline_checkMoose::Meta::TypeConstraint::_inline_check (recurses: max depth 3, inclusive time 4.64ms)
14654946µs1.42msMoose::Meta::TypeConstraint::::inline_environmentMoose::Meta::TypeConstraint::inline_environment (recurses: max depth 1, inclusive time 43µs)
3685838µs10.2msMoose::Meta::TypeConstraint::::newMoose::Meta::TypeConstraint::new
4611486µs9.48msMoose::Meta::TypeConstraint::::_actually_compile_type_constraintMoose::Meta::TypeConstraint::_actually_compile_type_constraint
111391µs1.02msMoose::Meta::TypeConstraint::::BEGIN@12Moose::Meta::TypeConstraint::BEGIN@12
4722234µs9.93msMoose::Meta::TypeConstraint::::compile_type_constraintMoose::Meta::TypeConstraint::compile_type_constraint
19963174µs174µsMoose::Meta::TypeConstraint::::__ANON__[:16]Moose::Meta::TypeConstraint::__ANON__[:16]
3611144µs144µsMoose::Meta::TypeConstraint::::__ANON__[:77]Moose::Meta::TypeConstraint::__ANON__[:77]
191199µs5.15msMoose::Meta::TypeConstraint::::create_child_typeMoose::Meta::TypeConstraint::create_child_type
362148µs48µsMoose::Meta::TypeConstraint::::__ANON__[:101]Moose::Meta::TypeConstraint::__ANON__[:101]
11143µs82µsMoose::Meta::TypeConstraint::::_compile_subtypeMoose::Meta::TypeConstraint::_compile_subtype
51136µs79µsMoose::Meta::TypeConstraint::::checkMoose::Meta::TypeConstraint::check
11118µs24µsMoose::Meta::TypeConstraint::::_collect_all_parentsMoose::Meta::TypeConstraint::_collect_all_parents
11110µs45µsMoose::Meta::TypeConstraint::::BEGIN@14Moose::Meta::TypeConstraint::BEGIN@14
11110µs34µsMoose::Meta::TypeConstraint::::BEGIN@19Moose::Meta::TypeConstraint::BEGIN@19
1118µs8µsMoose::Meta::TypeConstraint::::BEGIN@3Moose::Meta::TypeConstraint::BEGIN@3
1118µs11µsMoose::Meta::TypeConstraint::::BEGIN@10Moose::Meta::TypeConstraint::BEGIN@10
1117µs12µsMoose::Meta::TypeConstraint::::BEGIN@11Moose::Meta::TypeConstraint::BEGIN@11
1117µs28µsMoose::Meta::TypeConstraint::::BEGIN@21Moose::Meta::TypeConstraint::BEGIN@21
1117µs38µsMoose::Meta::TypeConstraint::::BEGIN@24Moose::Meta::TypeConstraint::BEGIN@24
1116µs28µsMoose::Meta::TypeConstraint::::BEGIN@20Moose::Meta::TypeConstraint::BEGIN@20
1116µs31µsMoose::Meta::TypeConstraint::::BEGIN@22Moose::Meta::TypeConstraint::BEGIN@22
1116µs26µsMoose::Meta::TypeConstraint::::BEGIN@23Moose::Meta::TypeConstraint::BEGIN@23
1116µs44µsMoose::Meta::TypeConstraint::::BEGIN@26Moose::Meta::TypeConstraint::BEGIN@26
4116µs6µsMoose::Meta::TypeConstraint::::__ANON__[:42]Moose::Meta::TypeConstraint::__ANON__[:42]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:14]Moose::Meta::TypeConstraint::__ANON__[:14]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:15]Moose::Meta::TypeConstraint::__ANON__[:15]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:378]Moose::Meta::TypeConstraint::__ANON__[:378]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:38]Moose::Meta::TypeConstraint::__ANON__[:38]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:391]Moose::Meta::TypeConstraint::__ANON__[:391]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:404]Moose::Meta::TypeConstraint::__ANON__[:404]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:68]Moose::Meta::TypeConstraint::__ANON__[:68]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:76]Moose::Meta::TypeConstraint::__ANON__[:76]
0000s0sMoose::Meta::TypeConstraint::::_compile_hand_optimized_type_constraintMoose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint
0000s0sMoose::Meta::TypeConstraint::::_compile_typeMoose::Meta::TypeConstraint::_compile_type
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::::equalsMoose::Meta::TypeConstraint::equals
0000s0sMoose::Meta::TypeConstraint::::get_messageMoose::Meta::TypeConstraint::get_message
0000s0sMoose::Meta::TypeConstraint::::is_a_type_ofMoose::Meta::TypeConstraint::is_a_type_of
0000s0sMoose::Meta::TypeConstraint::::is_subtype_ofMoose::Meta::TypeConstraint::is_subtype_of
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
# spent 8µs within Moose::Meta::TypeConstraint::BEGIN@3 which was called: # once (8µs+0s) by Moose::BEGIN@28 at line 5
BEGIN {
415µs $Moose::Meta::TypeConstraint::AUTHORITY = 'cpan:STEVAN';
5130µs18µs}
# spent 8µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@3
6{
721µs $Moose::Meta::TypeConstraint::VERSION = '2.1005';
8}
9
10222µs214µs
# spent 11µs (8+3) within Moose::Meta::TypeConstraint::BEGIN@10 which was called: # once (8µs+3µs) by Moose::BEGIN@28 at line 10
use strict;
# spent 11µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@10 # spent 3µs making 1 call to strict::import
11220µs217µs
# spent 12µs (7+5) within Moose::Meta::TypeConstraint::BEGIN@11 which was called: # once (7µs+5µs) by Moose::BEGIN@28 at line 11
use warnings;
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@11 # spent 5µs making 1 call to warnings::import
122154µs21.49ms
# spent 1.02ms (391µs+626µs) within Moose::Meta::TypeConstraint::BEGIN@12 which was called: # once (391µs+626µs) by Moose::BEGIN@28 at line 12
use metaclass;
# spent 1.02ms making 1 call to Moose::Meta::TypeConstraint::BEGIN@12 # spent 472µs making 1 call to metaclass::import
13
14
# spent 45µs (10+35) within Moose::Meta::TypeConstraint::BEGIN@14 which was called: # once (10µs+35µs) by Moose::BEGIN@28 at line 17
use overload '0+' => sub { refaddr(shift) }, # id an object
15 '""' => sub { shift->name }, # stringify to tc name
16199363µs
# spent 174µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Meta/TypeConstraint.pm:16] which was called 199 times, avg 877ns/call: # 72 times (77µs+0s) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 274 of Moose/Util/TypeConstraints.pm, avg 1µs/call # 69 times (49µs+0s) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 260 of Moose/Util/TypeConstraints.pm, avg 713ns/call # 35 times (33µs+0s) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 51 of Moose/Meta/TypeConstraint/Registry.pm, avg 946ns/call # 19 times (11µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 565 of Moose/Util/TypeConstraints.pm, avg 605ns/call # 2 times (2µs+0s) by Moose::init_meta at line 165 of Moose.pm, avg 1µs/call # 2 times (1µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint_union at line 104 of Moose/Util/TypeConstraints.pm, avg 650ns/call
bool => sub { 1 },
17228µs279µs fallback => 1;
# spent 45µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14 # spent 34µs making 1 call to overload::import
18
19225µs259µs
# spent 34µs (10+24) within Moose::Meta::TypeConstraint::BEGIN@19 which was called: # once (10µs+24µs) by Moose::BEGIN@28 at line 19
use Carp qw(confess);
# spent 34µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@19 # spent 24µs making 1 call to Exporter::import
20226µs249µs
# spent 28µs (6+22) within Moose::Meta::TypeConstraint::BEGIN@20 which was called: # once (6µs+22µs) by Moose::BEGIN@28 at line 20
use Class::Load qw(load_class);
# spent 28µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@20 # spent 22µs making 1 call to Exporter::import
21223µs249µs
# spent 28µs (7+21) within Moose::Meta::TypeConstraint::BEGIN@21 which was called: # once (7µs+21µs) by Moose::BEGIN@28 at line 21
use Eval::Closure;
# spent 28µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@21 # spent 21µs making 1 call to Exporter::import
22223µs256µs
# spent 31µs (6+25) within Moose::Meta::TypeConstraint::BEGIN@22 which was called: # once (6µs+25µs) by Moose::BEGIN@28 at line 22
use Scalar::Util qw(blessed refaddr);
# spent 31µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@22 # spent 25µs making 1 call to Exporter::import
23221µs247µs
# spent 26µs (6+20) within Moose::Meta::TypeConstraint::BEGIN@23 which was called: # once (6µs+20µs) by Moose::BEGIN@28 at line 23
use Sub::Name qw(subname);
# spent 26µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@23 # spent 20µs making 1 call to Exporter::import
24227µs269µs
# spent 38µs (7+31) within Moose::Meta::TypeConstraint::BEGIN@24 which was called: # once (7µs+31µs) by Moose::BEGIN@28 at line 24
use Try::Tiny;
# spent 38µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@24 # spent 31µs making 1 call to Exporter::import
25
2621.64ms281µs
# spent 44µs (6+38) within Moose::Meta::TypeConstraint::BEGIN@26 which was called: # once (6µs+38µs) by Moose::BEGIN@28 at line 26
use base qw(Class::MOP::Object);
# spent 44µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@26 # spent 38µs making 1 call to base::import
27
2815µs3451µs__PACKAGE__->meta->add_attribute('name' => (
# spent 426µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 19µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 6µs making 1 call to Class::MOP::_definition_context
29 reader => 'name',
30 Class::MOP::_definition_context(),
31));
3214µs3495µs__PACKAGE__->meta->add_attribute('parent' => (
# spent 478µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 6µs making 1 call to Class::MOP::_definition_context
33 reader => 'parent',
34 predicate => 'has_parent',
35 Class::MOP::_definition_context(),
36));
37
3812µsmy $null_constraint = sub { 1 };
39__PACKAGE__->meta->add_attribute('constraint' => (
40 reader => 'constraint',
41 writer => '_set_constraint',
42411µs
# spent 6µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Meta/TypeConstraint.pm:42] which was called 4 times, avg 1µs/call: # 4 times (6µs+0s) by Moose::Meta::TypeConstraint::Union::_new or Moose::Meta::TypeConstraint::_new at line 24 of (eval 62)[Eval/Closure.pm:144], avg 1µs/call
default => sub { $null_constraint },
4315µs3504µs Class::MOP::_definition_context(),
# spent 488µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 5µs making 1 call to Class::MOP::_definition_context
44));
45
4614µs3478µs__PACKAGE__->meta->add_attribute('message' => (
# spent 462µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 5µs making 1 call to Class::MOP::_definition_context
47 accessor => 'message',
48 predicate => 'has_message',
49 Class::MOP::_definition_context(),
50));
51
5213µs3301µs__PACKAGE__->meta->add_attribute('_default_message' => (
# spent 285µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 5µs making 1 call to Class::MOP::_definition_context
53 accessor => '_default_message',
54 Class::MOP::_definition_context(),
55));
56
57# can't make this a default because it has to close over the type name, and
58# cmop attributes don't have lazy
59
# spent 144µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Meta/TypeConstraint.pm:77] which was called 36 times, avg 4µs/call: # 36 times (144µs+0s) by Moose::Meta::TypeConstraint::new at line 146, avg 4µs/call
my $_default_message_generator = sub {
6072172µs my $name = shift;
61 sub {
62 my $value = shift;
63 # have to load it late like this, since it uses Moose itself
64 my $can_partialdump = try {
65 # versions prior to 0.14 had a potential infinite loop bug
66 load_class('Devel::PartialDump', { -version => 0.14 });
67 1;
68 };
69 if ($can_partialdump) {
70 $value = Devel::PartialDump->new->dump($value);
71 }
72 else {
73 $value = (defined $value ? overload::StrVal($value) : 'undef');
74 }
75 return "Validation failed for '" . $name . "' with value $value";
76 }
7712µs};
7814µs3487µs__PACKAGE__->meta->add_attribute('coercion' => (
# spent 472µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 5µs making 1 call to Class::MOP::_definition_context
79 accessor => 'coercion',
80 predicate => 'has_coercion',
81 Class::MOP::_definition_context(),
82));
83
8414µs3512µs__PACKAGE__->meta->add_attribute('hand_optimized_type_constraint' => (
# spent 497µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 10µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 5µs making 1 call to Class::MOP::_definition_context
85 init_arg => 'optimized',
86 accessor => 'hand_optimized_type_constraint',
87 predicate => 'has_hand_optimized_type_constraint',
88 Class::MOP::_definition_context(),
89));
90
9114µs3472µs__PACKAGE__->meta->add_attribute('inlined' => (
# spent 457µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 5µs making 1 call to Class::MOP::_definition_context
92 init_arg => 'inlined',
93 accessor => 'inlined',
94 predicate => '_has_inlined_type_constraint',
95 Class::MOP::_definition_context(),
96));
97
98__PACKAGE__->meta->add_attribute('inline_environment' => (
99 init_arg => 'inline_environment',
100 accessor => '_inline_environment',
1013685µs
# spent 48µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Meta/TypeConstraint.pm:101] which was called 36 times, avg 1µs/call: # 21 times (28µs+0s) by Moose::Meta::TypeConstraint::Union::_new or Moose::Meta::TypeConstraint::_new at line 33 of (eval 62)[Eval/Closure.pm:144], avg 1µs/call # 15 times (20µs+0s) by Moose::Meta::TypeConstraint::Class::_new or Moose::Meta::TypeConstraint::Parameterizable::_new at line 36 of (eval 62)[Eval/Closure.pm:144], avg 1µs/call
default => sub { {} },
10215µs3317µs Class::MOP::_definition_context(),
# spent 298µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 9µs making 1 call to Class::MOP::_definition_context
103));
104
105sub parents {
106 my $self = shift;
107 $self->parent;
108}
109
110# private accessors
111
11214µs3495µs__PACKAGE__->meta->add_attribute('compiled_type_constraint' => (
# spent 480µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 5µs making 1 call to Class::MOP::_definition_context
113 accessor => '_compiled_type_constraint',
114 predicate => '_has_compiled_type_constraint',
115 Class::MOP::_definition_context(),
116));
117
11814µs3331µs__PACKAGE__->meta->add_attribute('package_defined_in' => (
# spent 314µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 11µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 6µs making 1 call to Class::MOP::_definition_context
119 accessor => '_package_defined_in',
120 Class::MOP::_definition_context(),
121));
122
123
# spent 10.2ms (838µs+9.37) within Moose::Meta::TypeConstraint::new which was called 36 times, avg 283µs/call: # 19 times (424µs+4.63ms) by Moose::Meta::TypeConstraint::create_child_type at line 423, avg 266µs/call # 11 times (247µs+3.49ms) by Moose::Meta::TypeConstraint::Class::new at line 43 of Moose/Meta/TypeConstraint/Class.pm, avg 340µs/call # once (37µs+295µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 204 of Moose/Util/TypeConstraints/Builtins.pm # once (28µs+239µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 575 of Moose/Util/TypeConstraints.pm # once (22µs+200µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 239 of Moose/Util/TypeConstraints/Builtins.pm # once (28µs+194µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 274 of Moose/Util/TypeConstraints/Builtins.pm # once (21µs+193µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 300 of Moose/Util/TypeConstraints/Builtins.pm # once (30µs+129µs) by Moose::Meta::TypeConstraint::Union::new at line 33 of Moose/Meta/TypeConstraint/Union.pm
sub new {
124360708µs my $class = shift;
125 my ($first, @rest) = @_;
126 my %args = ref $first ? %$first : $first ? ($first, @rest) : ();
127 $args{name} = $args{name} ? "$args{name}" : "__ANON__";
128
129 if ( $args{optimized} ) {
130 Moose::Deprecated::deprecated(
131 feature => 'optimized type constraint sub ref',
132 message =>
133 'Providing an optimized subroutine ref for type constraints is deprecated.'
134 . ' Use the inlining feature (inline_as) instead.'
135 );
136 }
137
138 if ( exists $args{message}
139 && (!ref($args{message}) || ref($args{message}) ne 'CODE') ) {
140 confess("The 'message' parameter must be a coderef");
141 }
142
143361.14ms my $self = $class->_new(%args);
# spent 475µs making 20 calls to Moose::Meta::TypeConstraint::_new, avg 24µs/call # spent 413µs making 11 calls to Moose::Meta::TypeConstraint::Class::_new, avg 38µs/call # spent 153µs making 4 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 38µs/call # spent 96µs making 1 call to Moose::Meta::TypeConstraint::Union::_new
144727.89ms $self->compile_type_constraint()
# spent 7.83ms making 36 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 218µs/call # spent 57µs making 36 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 2µs/call
145 unless $self->_has_compiled_type_constraint;
146144338µs $self->_default_message($_default_message_generator->($self->name))
# spent 144µs making 36 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:77], avg 4µs/call # spent 93µs making 36 calls to Moose::Meta::TypeConstraint::_default_message, avg 3µs/call # spent 50µs making 36 calls to Moose::Meta::TypeConstraint::has_message, avg 1µs/call # spent 50µs making 36 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
147 unless $self->has_message;
148 return $self;
149}
150
- -
153sub coerce {
154 my $self = shift;
155
156 my $coercion = $self->coercion;
157
158 unless ($coercion) {
159 require Moose;
160 Moose->throw_error("Cannot coerce without a type coercion");
161 }
162
163 return $_[0] if $self->check($_[0]);
164
165 return $coercion->coerce(@_);
166}
167
168sub assert_coerce {
169 my $self = shift;
170
171 my $result = $self->coerce(@_);
172
173 $self->assert_valid($result);
174
175 return $result;
176}
177
178
# spent 79µs (36+42) within Moose::Meta::TypeConstraint::check which was called 5 times, avg 16µs/call: # 5 times (36µs+42µs) by Moose::Meta::Attribute::verify_against_type_constraint at line 1279 of Moose/Meta/Attribute.pm, avg 16µs/call
sub check {
1791530µs my ($self, @args) = @_;
18057µs my $constraint_subref = $self->_compiled_type_constraint;
# spent 7µs making 5 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 1µs/call
181535µs return $constraint_subref->(@args) ? 1 : undef;
182}
183
184sub validate {
185 my ($self, $value) = @_;
186 if ($self->_compiled_type_constraint->($value)) {
187 return undef;
188 }
189 else {
190 $self->get_message($value);
191 }
192}
193
194
# spent 4.60ms (3.03+1.58) within Moose::Meta::TypeConstraint::can_be_inlined which was called 480 times, avg 10µs/call: # 262 times (1.50ms+835µs) by Moose::Meta::TypeConstraint::_inline_check at line 207, avg 9µs/call # 90 times (630µs+355µs) by Moose::Meta::Attribute::_inline_check_constraint at line 711 of Moose/Meta/Attribute.pm, avg 11µs/call # 56 times (406µs+230µs) by Moose::Meta::Attribute::_eval_environment at line 789 of Moose/Meta/Attribute.pm, avg 11µs/call # 46 times (332µs+196µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 311, avg 11µs/call # 16 times (95µs+-95µs) by Moose::Meta::TypeConstraint::can_be_inlined at line 198, avg 0s/call # 8 times (52µs+30µs) by Moose::Meta::TypeConstraint::Union::can_be_inlined at line 87 of Moose/Meta/TypeConstraint/Union.pm, avg 10µs/call # 2 times (17µs+26µs) by Moose::Meta::Attribute::_inline_check_coercion at line 687 of Moose/Meta/Attribute.pm, avg 22µs/call
sub can_be_inlined {
19514402.19ms my $self = shift;
196
1979551.04ms if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 520µs making 475 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call # spent 517µs making 480 calls to Moose::Meta::TypeConstraint::has_parent, avg 1µs/call
1983219µs return $self->parent->can_be_inlined;
# spent 19µs making 16 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call # spent 143µs making 16 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 9µs/call, recursion: max depth 1, sum of overlapping time 143µs
199 }
200
201464521µs return $self->_has_inlined_type_constraint;
# spent 521µs making 464 calls to Moose::Meta::TypeConstraint::_has_inlined_type_constraint, avg 1µs/call
202}
203
204
# spent 6.89ms (2.62+4.27) within Moose::Meta::TypeConstraint::_inline_check which was called 262 times, avg 26µs/call: # 88 times (879µs+3.63ms) by Moose::Meta::Attribute::_inline_check_constraint at line 713 of Moose/Meta/Attribute.pm, avg 51µs/call # 57 times (560µs+-560µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Util/TypeConstraints/Builtins.pm:66] at line 64 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 45 times (484µs+1.22ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 312, avg 38µs/call # 29 times (269µs+-269µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Util/TypeConstraints/Builtins.pm:120] at line 118 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 26 times (255µs+-255µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Util/TypeConstraints/Builtins.pm:83] at line 78 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 7 times (74µs+-74µs) by Moose::Meta::TypeConstraint::_inline_check at line 213, avg 0s/call # 6 times (58µs+394µs) by Moose::Meta::TypeConstraint::Union::_inline_check at line 97 of Moose/Meta/TypeConstraint/Union.pm, avg 75µs/call # 2 times (19µs+200µs) by Moose::Meta::Attribute::_inline_check_coercion at line 689 of Moose/Meta/Attribute.pm, avg 110µs/call # once (9µs+-9µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Util/TypeConstraints/Builtins.pm:112] at line 103 of Moose/Util/TypeConstraints/Builtins.pm # once (10µs+-10µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.14.2/Moose/Util/TypeConstraints/Builtins.pm:176] at line 171 of Moose/Util/TypeConstraints/Builtins.pm
sub _inline_check {
20510481.80ms my $self = shift;
206
2072622.33ms unless ( $self->can_be_inlined ) {
# spent 2.33ms making 262 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 9µs/call
208 require Moose;
209 Moose->throw_error( 'Cannot inline a type constraint check for ' . $self->name );
210 }
211
212522514µs if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 263µs making 262 calls to Moose::Meta::TypeConstraint::has_parent, avg 1µs/call # spent 251µs making 260 calls to Moose::Meta::TypeConstraint::constraint, avg 966ns/call
213147µs return $self->parent->_inline_check(@_);
# spent 7µs making 7 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call # spent 503µs making 7 calls to Moose::Meta::TypeConstraint::_inline_check, avg 72µs/call, recursion: max depth 1, sum of overlapping time 503µs
214 }
215
2165105.56ms return '( do { ' . $self->inlined->( $self, @_ ) . ' } )';
# spent 1.67ms making 57 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:66], avg 29µs/call # spent 1.56ms making 29 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:120], avg 54µs/call # spent 1.49ms making 26 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:83], avg 57µs/call # spent 288µs making 255 calls to Moose::Meta::TypeConstraint::inlined, avg 1µs/call # spent 266µs making 28 calls to Moose::Meta::TypeConstraint::Class::__ANON__[Moose/Meta/TypeConstraint/Class.pm:30], avg 9µs/call # spent 87µs making 37 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:58], avg 2µs/call # spent 82µs making 58 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:46], avg 1µs/call # spent 58µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:112] # spent 34µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:176] # spent 7µs making 4 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:258], avg 2µs/call # spent 3µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:163], avg 2µs/call # spent 3µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:152] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:195] # spent 2µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:28], avg 1µs/call # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:157] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:125] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:132] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:223] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:137] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:39] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:72] # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:291]
217}
218
219
# spent 1.42ms (946µs+475µs) within Moose::Meta::TypeConstraint::inline_environment which was called 146 times, avg 10µs/call: # 56 times (374µs+200µs) by Moose::Meta::Attribute::_eval_environment at line 800 of Moose/Meta/Attribute.pm, avg 10µs/call # 45 times (295µs+178µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 312, avg 10µs/call # 36 times (223µs+113µs) by Moose::Meta::Class::_eval_environment at line 543 of Moose/Meta/Class.pm, avg 9µs/call # 5 times (29µs+-29µs) by Moose::Meta::TypeConstraint::inline_environment at line 223, avg 0s/call # 4 times (24µs+13µs) by Moose::Meta::TypeConstraint::Union::inline_environment at line 108 of Moose/Meta/TypeConstraint/Union.pm, avg 9µs/call
sub inline_environment {
220438659µs my $self = shift;
221
222290300µs if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 154µs making 144 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call # spent 147µs making 146 calls to Moose::Meta::TypeConstraint::has_parent, avg 1µs/call
223106µs return $self->parent->inline_environment;
# spent 6µs making 5 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call # spent 43µs making 5 calls to Moose::Meta::TypeConstraint::inline_environment, avg 9µs/call, recursion: max depth 1, sum of overlapping time 43µs
224 }
225
226141169µs return $self->_inline_environment;
# spent 169µs making 141 calls to Moose::Meta::TypeConstraint::_inline_environment, avg 1µs/call
227}
228
229sub assert_valid {
230 my ($self, $value) = @_;
231
232 my $error = $self->validate($value);
233 return 1 if ! defined $error;
234
235 require Moose;
236 Moose->throw_error($error);
237}
238
239sub get_message {
240 my ($self, $value) = @_;
241 my $msg = $self->has_message
242 ? $self->message
243 : $self->_default_message;
244 local $_ = $value;
245 return $msg->($value);
246}
247
248## type predicates ...
249
250sub equals {
251 my ( $self, $type_or_name ) = @_;
252
253 my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
254
255 return 1 if $self == $other;
256
257 if ( $self->has_hand_optimized_type_constraint and $other->has_hand_optimized_type_constraint ) {
258 return 1 if $self->hand_optimized_type_constraint == $other->hand_optimized_type_constraint;
259 }
260
261 return unless $self->constraint == $other->constraint;
262
263 if ( $self->has_parent ) {
264 return unless $other->has_parent;
265 return unless $self->parent->equals( $other->parent );
266 } else {
267 return if $other->has_parent;
268 }
269
270 return;
271}
272
273sub is_a_type_of {
274 my ($self, $type_or_name) = @_;
275
276 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
277
278 ($self->equals($type) || $self->is_subtype_of($type));
279}
280
281sub is_subtype_of {
282 my ($self, $type_or_name) = @_;
283
284 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
285
286 my $current = $self;
287
288 while (my $parent = $current->parent) {
289 return 1 if $parent->equals($type);
290 $current = $parent;
291 }
292
293 return 0;
294}
295
296## compiling the type constraint
297
298
# spent 9.93ms (234µs+9.69) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 47 times, avg 211µs/call: # 36 times (181µs+7.65ms) by Moose::Meta::TypeConstraint::new at line 144, avg 218µs/call # 11 times (53µs+2.04ms) by Moose::Meta::TypeConstraint::Class::new at line 45 of Moose/Meta/TypeConstraint/Class.pm, avg 191µs/call
sub compile_type_constraint {
29994194µs my $self = shift;
300949.69ms $self->_compiled_type_constraint($self->_actually_compile_type_constraint);
# spent 9.48ms making 46 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 206µs/call # spent 207µs making 47 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 4µs/call # spent 12µs making 1 call to Moose::Meta::TypeConstraint::Union::_actually_compile_type_constraint
301}
302
303## type compilers ...
304
305
# spent 9.48ms (486µs+8.99) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 46 times, avg 206µs/call: # 46 times (486µs+8.99ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 300, avg 206µs/call
sub _actually_compile_type_constraint {
306186339µs my $self = shift;
307
3084662µs return $self->_compile_hand_optimized_type_constraint
# spent 62µs making 46 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 1µs/call
309 if $self->has_hand_optimized_type_constraint;
310
31146527µs if ( $self->can_be_inlined ) {
# spent 527µs making 46 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 11µs/call
3121358.32ms return eval_closure(
# spent 6.14ms making 45 calls to Eval::Closure::eval_closure, avg 136µs/call # spent 1.70ms making 45 calls to Moose::Meta::TypeConstraint::_inline_check, avg 38µs/call # spent 472µs making 45 calls to Moose::Meta::TypeConstraint::inline_environment, avg 10µs/call
313 source => 'sub { ' . $self->_inline_check('$_[0]') . ' }',
314 environment => $self->inline_environment,
315 );
316 }
317
31811µs my $check = $self->constraint;
# spent 1µs making 1 call to Moose::Meta::TypeConstraint::constraint
319 unless ( defined $check ) {
320 require Moose;
321 Moose->throw_error( "Could not compile type constraint '"
322 . $self->name
323 . "' because no constraint check" );
324 }
325
326283µs return $self->_compile_subtype($check)
# spent 82µs making 1 call to Moose::Meta::TypeConstraint::_compile_subtype # spent 900ns making 1 call to Moose::Meta::TypeConstraint::has_parent
327 if $self->has_parent;
328
329 return $self->_compile_type($check);
330}
331
332sub _compile_hand_optimized_type_constraint {
333 my $self = shift;
334
335 my $type_constraint = $self->hand_optimized_type_constraint;
336
337 unless ( ref $type_constraint ) {
338 require Moose;
339 Moose->throw_error("Hand optimized type constraint is not a code reference");
340 }
341
342 return $type_constraint;
343}
344
345
# spent 82µs (43+39) within Moose::Meta::TypeConstraint::_compile_subtype which was called: # once (43µs+39µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 326
sub _compile_subtype {
3462436µs my ($self, $check) = @_;
347
348 # gather all the parent constraints in order
349 my @parents;
350 my $optimized_parent;
351124µs foreach my $parent ($self->_collect_all_parents) {
352 # if a parent is optimized, the optimized constraint already includes
353 # all of its parents tcs, so we can break the loop
35456µs if ($parent->has_hand_optimized_type_constraint) {
# spent 6µs making 5 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 1µs/call
355 push @parents => $optimized_parent = $parent->hand_optimized_type_constraint;
356 last;
357 }
358 else {
35955µs push @parents => $parent->constraint;
# spent 5µs making 5 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call
360 }
361 }
362
363 @parents = grep { $_ != $null_constraint } reverse @parents;
364
365 unless ( @parents ) {
366 return $self->_compile_type($check);
367 } elsif( $optimized_parent and @parents == 1 ) {
368 # the case of just one optimized parent is optimized to prevent
369 # looping and the unnecessary localization
370 if ( $check == $null_constraint ) {
371 return $optimized_parent;
372 } else {
373 return subname($self->name, sub {
374 return undef unless $optimized_parent->($_[0]);
375 my (@args) = @_;
376 local $_ = $args[0];
377 $check->(@args);
378 });
379 }
380 } else {
381 # general case, check all the constraints, from the first parent to ourselves
382 my @checks = @parents;
383 push @checks, $check if $check != $null_constraint;
384 return subname($self->name => sub {
385915µs my (@args) = @_;
386 local $_ = $args[0];
387 foreach my $check (@checks) {
388517µs return undef unless $check->(@args);
389 }
390 return 1;
39125µs });
# spent 3µs making 1 call to Sub::Name::subname # spent 2µs making 1 call to Moose::Meta::TypeConstraint::name
392 }
393}
394
395sub _compile_type {
396 my ($self, $check) = @_;
397
398 return $check if $check == $null_constraint; # Item, Any
399
400 return subname($self->name => sub {
401 my (@args) = @_;
402 local $_ = $args[0];
403 $check->(@args);
404 });
405}
406
407## other utils ...
408
409
# spent 24µs (18+6) within Moose::Meta::TypeConstraint::_collect_all_parents which was called: # once (18µs+6µs) by Moose::Meta::TypeConstraint::_compile_subtype at line 351
sub _collect_all_parents {
4101512µs my $self = shift;
411 my @parents;
41211µs my $current = $self->parent;
# spent 1µs making 1 call to Moose::Meta::TypeConstraint::parent
413 while (defined $current) {
414 push @parents => $current;
41555µs $current = $current->parent;
# spent 5µs making 5 calls to Moose::Meta::TypeConstraint::parent, avg 960ns/call
416 }
417 return @parents;
418}
419
420
# spent 5.15ms (99µs+5.05) within Moose::Meta::TypeConstraint::create_child_type which was called 19 times, avg 271µs/call: # 19 times (99µs+5.05ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 572 of Moose/Util/TypeConstraints.pm, avg 271µs/call
sub create_child_type {
42157100µs my ($self, %opts) = @_;
422 my $class = ref $self;
423195.05ms return $class->new(%opts, parent => $self);
# spent 5.05ms making 19 calls to Moose::Meta::TypeConstraint::new, avg 266µs/call
424}
425
426118µs1;
427
428# ABSTRACT: The Moose Type Constraint metaclass
429
430__END__