← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:06 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint.pm
StatementsExecuted 2636 statements in 18.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
97935.59ms6.69msMoose::Meta::TypeConstraint::::_inline_checkMoose::Meta::TypeConstraint::_inline_check (recurses: max depth 2, inclusive time 150µs)
77444.89ms28.6msMoose::Meta::TypeConstraint::::compile_type_constraintMoose::Meta::TypeConstraint::compile_type_constraint
77114.63ms23.4msMoose::Meta::TypeConstraint::::_actually_compile_type_constraintMoose::Meta::TypeConstraint::_actually_compile_type_constraint
5096880µs28.1msMoose::Meta::TypeConstraint::::newMoose::Meta::TypeConstraint::new
20063781µs1.10msMoose::Meta::TypeConstraint::::can_be_inlinedMoose::Meta::TypeConstraint::can_be_inlined (recurses: max depth 1, inclusive time 8µs)
9354387µs528µsMoose::Meta::TypeConstraint::::inline_environmentMoose::Meta::TypeConstraint::inline_environment (recurses: max depth 1, inclusive time 4µs)
111216µs624µsMoose::Meta::TypeConstraint::::BEGIN@6Moose::Meta::TypeConstraint::BEGIN@6
2111152µs308µsMoose::Meta::TypeConstraint::::equalsMoose::Meta::TypeConstraint::equals
5011133µs133µsMoose::Meta::TypeConstraint::::__ANON__[:72]Moose::Meta::TypeConstraint::__ANON__[:72]
711114µs508µsMoose::Meta::TypeConstraint::::is_subtype_ofMoose::Meta::TypeConstraint::is_subtype_of
1558476µs76µsMoose::Meta::TypeConstraint::::__ANON__[:10]Moose::Meta::TypeConstraint::__ANON__[:10]
421159µs69µsMoose::Meta::TypeConstraint::::__ANON__[:8]Moose::Meta::TypeConstraint::__ANON__[:8]
161152µs6.46msMoose::Meta::TypeConstraint::::create_child_typeMoose::Meta::TypeConstraint::create_child_type
502152µs52µsMoose::Meta::TypeConstraint::::__ANON__[:89]Moose::Meta::TypeConstraint::__ANON__[:89]
11111µs28µsMoose::Meta::TypeConstraint::::BEGIN@15Moose::Meta::TypeConstraint::BEGIN@15
11110µs12µsMoose::Meta::TypeConstraint::::BEGIN@4Moose::Meta::TypeConstraint::BEGIN@4
1119µs36µsMoose::Meta::TypeConstraint::::BEGIN@8Moose::Meta::TypeConstraint::BEGIN@8
1116µs12µsMoose::Meta::TypeConstraint::::BEGIN@5Moose::Meta::TypeConstraint::BEGIN@5
1116µs26µsMoose::Meta::TypeConstraint::::BEGIN@16Moose::Meta::TypeConstraint::BEGIN@16
1116µs19µsMoose::Meta::TypeConstraint::::BEGIN@14Moose::Meta::TypeConstraint::BEGIN@14
1116µs52µsMoose::Meta::TypeConstraint::::BEGIN@18Moose::Meta::TypeConstraint::BEGIN@18
1115µs31µsMoose::Meta::TypeConstraint::::BEGIN@13Moose::Meta::TypeConstraint::BEGIN@13
1115µs128µsMoose::Meta::TypeConstraint::::BEGIN@20Moose::Meta::TypeConstraint::BEGIN@20
3114µs4µsMoose::Meta::TypeConstraint::::__ANON__[:36]Moose::Meta::TypeConstraint::__ANON__[:36]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:32]Moose::Meta::TypeConstraint::__ANON__[:32]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:330]Moose::Meta::TypeConstraint::__ANON__[:330]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:343]Moose::Meta::TypeConstraint::__ANON__[:343]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:63]Moose::Meta::TypeConstraint::__ANON__[:63]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:71]Moose::Meta::TypeConstraint::__ANON__[:71]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:9]Moose::Meta::TypeConstraint::__ANON__[:9]
0000s0sMoose::Meta::TypeConstraint::::_collect_all_parentsMoose::Meta::TypeConstraint::_collect_all_parents
0000s0sMoose::Meta::TypeConstraint::::_compile_subtypeMoose::Meta::TypeConstraint::_compile_subtype
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::::checkMoose::Meta::TypeConstraint::check
0000s0sMoose::Meta::TypeConstraint::::coerceMoose::Meta::TypeConstraint::coerce
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::::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
1package Moose::Meta::TypeConstraint;
21300nsour $VERSION = '2.1605';
3
4216µs214µs
# spent 12µs (10+2) within Moose::Meta::TypeConstraint::BEGIN@4 which was called: # once (10µs+2µs) by Moose::BEGIN@25 at line 4
use strict;
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@4 # spent 2µs making 1 call to strict::import
5213µs217µs
# spent 12µs (6+5) within Moose::Meta::TypeConstraint::BEGIN@5 which was called: # once (6µs+5µs) by Moose::BEGIN@25 at line 5
use warnings;
# spent 12µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@5 # spent 5µs making 1 call to warnings::import
6299µs2997µs
# spent 624µs (216+408) within Moose::Meta::TypeConstraint::BEGIN@6 which was called: # once (216µs+408µs) by Moose::BEGIN@25 at line 6
use metaclass;
# spent 624µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@6 # spent 373µs making 1 call to metaclass::import
7
84297µs4210µs
# spent 69µs (59+10) within Moose::Meta::TypeConstraint::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint.pm:8] which was called 42 times, avg 2µs/call: # 42 times (59µs+10µs) by Moose::Meta::TypeConstraint::equals at line 237, avg 2µs/call # spent 36µs (9+26) within Moose::Meta::TypeConstraint::BEGIN@8 which was called: # once (9µs+26µs) by Moose::BEGIN@25 at line 11
use overload '0+' => sub { refaddr(shift) }, # id an object
# spent 10µs making 42 calls to Scalar::Util::refaddr, avg 243ns/call
9 '""' => sub { shift->name }, # stringify to tc name
10155193µs
# spent 76µs within Moose::Meta::TypeConstraint::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint.pm:10] which was called 155 times, avg 490ns/call: # 50 times (43µs+0s) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 47 of Moose/Meta/TypeConstraint/Registry.pm, avg 854ns/call # 21 times (8µs+0s) by Moose::Meta::TypeConstraint::equals at line 235, avg 367ns/call # 21 times (7µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 268, avg 343ns/call # 20 times (4µs+0s) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 246 of Moose/Util/TypeConstraints.pm, avg 210ns/call # 18 times (8µs+0s) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 260 of Moose/Util/TypeConstraints.pm, avg 417ns/call # 16 times (3µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 572 of Moose/Util/TypeConstraints.pm, avg 200ns/call # 7 times (3µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 264, avg 414ns/call # 2 times (600ns+0s) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 78 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 300ns/call
bool => sub { 1 },
11220µs262µs fallback => 1;
# spent 36µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@8 # spent 26µs making 1 call to overload::import
12
13220µs256µs
# spent 31µs (5+25) within Moose::Meta::TypeConstraint::BEGIN@13 which was called: # once (5µs+25µs) by Moose::BEGIN@25 at line 13
use Eval::Closure;
# spent 31µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@13 # spent 25µs making 1 call to Exporter::import
14228µs233µs
# spent 19µs (6+14) within Moose::Meta::TypeConstraint::BEGIN@14 which was called: # once (6µs+14µs) by Moose::BEGIN@25 at line 14
use Scalar::Util qw(refaddr);
# spent 19µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14 # spent 14µs making 1 call to Exporter::import
15226µs245µs
# spent 28µs (11+17) within Moose::Meta::TypeConstraint::BEGIN@15 which was called: # once (11µs+17µs) by Moose::BEGIN@25 at line 15
use Sub::Name qw(subname);
# spent 28µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@15 # spent 17µs making 1 call to Exporter::import
16217µs246µs
# spent 26µs (6+20) within Moose::Meta::TypeConstraint::BEGIN@16 which was called: # once (6µs+20µs) by Moose::BEGIN@25 at line 16
use Try::Tiny;
# spent 26µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@16 # spent 20µs making 1 call to Exporter::import
17
18216µs299µs
# spent 52µs (6+47) within Moose::Meta::TypeConstraint::BEGIN@18 which was called: # once (6µs+47µs) by Moose::BEGIN@25 at line 18
use base 'Class::MOP::Object';
# spent 52µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@18 # spent 47µs making 1 call to base::import
19
202868µs2251µs
# spent 128µs (5+123) within Moose::Meta::TypeConstraint::BEGIN@20 which was called: # once (5µs+123µs) by Moose::BEGIN@25 at line 20
use Moose::Util 'throw_exception';
# spent 128µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@20 # spent 123µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
21
2213µs3249µs__PACKAGE__->meta->add_attribute('name' => (
# spent 231µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 14µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µs making 1 call to Class::MOP::_definition_context
23 reader => 'name',
24 Class::MOP::_definition_context(),
25));
2612µs3304µs__PACKAGE__->meta->add_attribute('parent' => (
# spent 294µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 7µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µs making 1 call to Class::MOP::_definition_context
27 reader => 'parent',
28 predicate => 'has_parent',
29 Class::MOP::_definition_context(),
30));
31
321600nsmy $null_constraint = sub { 1 };
33__PACKAGE__->meta->add_attribute('constraint' => (
34 reader => 'constraint',
35 writer => '_set_constraint',
3636µs
# spent 4µs within Moose::Meta::TypeConstraint::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint.pm:36] which was called 3 times, avg 1µs/call: # 3 times (4µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new or Moose::Meta::TypeConstraint::_new at line 24 of (eval 33)[Eval/Closure.pm:142], avg 1µs/call
default => sub { $null_constraint },
3713µs3290µs Class::MOP::_definition_context(),
# spent 281µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 3µs making 1 call to Class::MOP::_definition_context
38));
39
4012µs3273µs__PACKAGE__->meta->add_attribute('message' => (
# spent 264µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 3µs making 1 call to Class::MOP::_definition_context
41 accessor => 'message',
42 predicate => 'has_message',
43 Class::MOP::_definition_context(),
44));
45
4612µs3200µs__PACKAGE__->meta->add_attribute('_default_message' => (
# spent 191µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 3µs making 1 call to Class::MOP::_definition_context
47 accessor => '_default_message',
48 Class::MOP::_definition_context(),
49));
50
51# can't make this a default because it has to close over the type name, and
52# cmop attributes don't have lazy
53
# spent 133µs within Moose::Meta::TypeConstraint::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint.pm:72] which was called 50 times, avg 3µs/call: # 50 times (133µs+0s) by Moose::Meta::TypeConstraint::new at line 127, avg 3µs/call
my $_default_message_generator = sub {
545015µs my $name = shift;
55 sub {
56 my $value = shift;
57 # have to load it late like this, since it uses Moose itself
58 my $can_partialdump = try {
59 # versions prior to 0.14 had a potential infinite loop bug
60 require Devel::PartialDump;
61 Devel::PartialDump->VERSION(0.14);
62 1;
63 };
64 if ($can_partialdump) {
65 $value = Devel::PartialDump->new->dump($value);
66 }
67 else {
68 $value = (defined $value ? overload::StrVal($value) : 'undef');
69 }
70 return "Validation failed for '" . $name . "' with value $value";
71 }
7251147µs};
7312µs3265µs__PACKAGE__->meta->add_attribute('coercion' => (
# spent 257µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 3µs making 1 call to Class::MOP::_definition_context
74 accessor => 'coercion',
75 predicate => 'has_coercion',
76 Class::MOP::_definition_context(),
77));
78
7912µs3272µs__PACKAGE__->meta->add_attribute('inlined' => (
# spent 264µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 3µs making 1 call to Class::MOP::_definition_context
80 init_arg => 'inlined',
81 accessor => 'inlined',
82 predicate => '_has_inlined_type_constraint',
83 Class::MOP::_definition_context(),
84));
85
86__PACKAGE__->meta->add_attribute('inline_environment' => (
87 init_arg => 'inline_environment',
88 accessor => '_inline_environment',
895089µs
# spent 52µs within Moose::Meta::TypeConstraint::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Meta/TypeConstraint.pm:89] which was called 50 times, avg 1µs/call: # 31 times (29µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new or Moose::Meta::TypeConstraint::Role::_new or Moose::Meta::TypeConstraint::_new at line 30 of (eval 33)[Eval/Closure.pm:142], avg 942ns/call # 19 times (23µs+0s) by Moose::Meta::TypeConstraint::Class::_new or Moose::Meta::TypeConstraint::Parameterizable::_new at line 33 of (eval 33)[Eval/Closure.pm:142], avg 1µs/call
default => sub { {} },
9012µs3176µs Class::MOP::_definition_context(),
# spent 167µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 5µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 3µs making 1 call to Class::MOP::_definition_context
91));
92
93sub parents {
94 my $self = shift;
95 $self->parent;
96}
97
98# private accessors
99
10012µs3328µs__PACKAGE__->meta->add_attribute('compiled_type_constraint' => (
# spent 309µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 3µs making 1 call to Class::MOP::_definition_context
101 accessor => '_compiled_type_constraint',
102 predicate => '_has_compiled_type_constraint',
103 Class::MOP::_definition_context(),
104));
105
10612µs3221µs__PACKAGE__->meta->add_attribute('package_defined_in' => (
# spent 212µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 6µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 3µs making 1 call to Class::MOP::_definition_context
107 accessor => '_package_defined_in',
108 Class::MOP::_definition_context(),
109));
110
111
# spent 28.1ms (880µs+27.2) within Moose::Meta::TypeConstraint::new which was called 50 times, avg 561µs/call: # 16 times (202µs+6.21ms) by Moose::Meta::TypeConstraint::create_child_type at line 362, avg 401µs/call # 15 times (316µs+11.7ms) by Moose::Meta::TypeConstraint::Class::new at line 38 of Moose/Meta/TypeConstraint/Class.pm, avg 801µs/call # 12 times (231µs+6.92ms) by Moose::Meta::TypeConstraint::Role::new at line 39 of Moose/Meta/TypeConstraint/Role.pm, avg 596µs/call # 2 times (43µs+1.23ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 90 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 637µs/call # once (25µs+613µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 582 of Moose/Util/TypeConstraints.pm # once (23µs+174µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 198 of Moose/Util/TypeConstraints/Builtins.pm # once (14µs+117µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 233 of Moose/Util/TypeConstraints/Builtins.pm # once (14µs+115µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 294 of Moose/Util/TypeConstraints/Builtins.pm # once (13µs+112µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 268 of Moose/Util/TypeConstraints/Builtins.pm
sub new {
112509µs my $class = shift;
1135033µs my ($first, @rest) = @_;
1145090µs my %args = ref $first ? %$first : $first ? ($first, @rest) : ();
1155045µs $args{name} = $args{name} ? "$args{name}" : "__ANON__";
116
1175012µs if ( exists $args{message}
118 && (!ref($args{message}) || ref($args{message}) ne 'CODE') ) {
119 throw_exception( MessageParameterMustBeCodeRef => params => \%args,
120 class => $class
121 );
122 }
123
1245091µs50903µs my $self = $class->_new(%args);
# spent 315µs making 15 calls to Moose::Meta::TypeConstraint::Class::_new, avg 21µs/call # spent 231µs making 12 calls to Moose::Meta::TypeConstraint::Role::_new, avg 19µs/call # spent 203µs making 17 calls to Moose::Meta::TypeConstraint::_new, avg 12µs/call # spent 86µs making 4 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 22µs/call # spent 67µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::_new, avg 34µs/call
12550133µs10026.0ms $self->compile_type_constraint()
# spent 24.8ms making 48 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 516µs/call # spent 1.15ms making 2 calls to Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint, avg 575µs/call # spent 53µs making 50 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 1µs/call
126 unless $self->_has_compiled_type_constraint;
12750209µs200302µs $self->_default_message($_default_message_generator->($self->name))
# spent 133µs making 50 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:72], avg 3µs/call # spent 69µs making 50 calls to Moose::Meta::TypeConstraint::_default_message, avg 1µs/call # spent 53µs making 50 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call # spent 46µs making 50 calls to Moose::Meta::TypeConstraint::has_message, avg 924ns/call
128 unless $self->has_message;
12950139µs return $self;
130}
131
- -
134sub coerce {
135 my $self = shift;
136
137 my $coercion = $self->coercion;
138
139 unless ($coercion) {
140 throw_exception( CoercingWithoutCoercions => type_name => $self->name );
141 }
142
143 return $_[0] if $self->check($_[0]);
144
145 return $coercion->coerce(@_);
146}
147
148sub assert_coerce {
149 my $self = shift;
150
151 my $result = $self->coerce(@_);
152
153 $self->assert_valid($result);
154
155 return $result;
156}
157
158sub check {
159 my ($self, @args) = @_;
160 my $constraint_subref = $self->_compiled_type_constraint;
161 return $constraint_subref->(@args) ? 1 : undef;
162}
163
164sub validate {
165 my ($self, $value) = @_;
166 if ($self->_compiled_type_constraint->($value)) {
167 return undef;
168 }
169 else {
170 $self->get_message($value);
171 }
172}
173
174
# spent 1.10ms (781µs+323µs) within Moose::Meta::TypeConstraint::can_be_inlined which was called 200 times, avg 6µs/call: # 97 times (307µs+112µs) by Moose::Meta::TypeConstraint::_inline_check at line 187, avg 4µs/call # 75 times (370µs+177µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288, avg 7µs/call # 15 times (54µs+20µs) by Moose::Meta::TypeConstraint::Parameterized::can_be_inlined at line 72 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 5µs/call # 8 times (33µs+15µs) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 6µs/call # 3 times (12µs+5µs) by Moose::Meta::Attribute::_eval_environment at line 766 of Moose/Meta/Attribute.pm, avg 6µs/call # 2 times (6µs+-6µs) by Moose::Meta::TypeConstraint::can_be_inlined at line 177, avg 0s/call
sub can_be_inlined {
17520027µs my $self = shift;
176
177200273µs399222µs if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 115µs making 195 calls to Moose::Meta::TypeConstraint::constraint, avg 592ns/call # spent 105µs making 200 calls to Moose::Meta::TypeConstraint::has_parent, avg 523ns/call # spent 2µs making 2 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call # spent 8µs making 2 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 4µs/call, recursion: max depth 1, sum of overlapping time 8µs
178 return $self->parent->can_be_inlined;
179 }
180
1811984.45ms198101µs return $self->_has_inlined_type_constraint;
# spent 101µs making 198 calls to Moose::Meta::TypeConstraint::_has_inlined_type_constraint, avg 512ns/call
182}
183
184
# spent 6.69ms (5.59+1.11) within Moose::Meta::TypeConstraint::_inline_check which was called 97 times, avg 69µs/call: # 75 times (5.44ms+1.04ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288, avg 86µs/call # 8 times (60µs+79µs) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 17µs/call # 5 times (32µs+38µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Util/TypeConstraints/Builtins.pm:266] at line 258 of Moose/Util/TypeConstraints/Builtins.pm, avg 14µs/call # 4 times (24µs+-24µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Util/TypeConstraints/Builtins.pm:60] at line 58 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # once (6µs+-6µs) by Moose::Meta::TypeConstraint::_inline_check at line 191 # once (6µs+-6µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Util/TypeConstraints/Builtins.pm:170] at line 165 of Moose/Util/TypeConstraints/Builtins.pm # once (6µs+-6µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Util/TypeConstraints/Builtins.pm:106] at line 97 of Moose/Util/TypeConstraints/Builtins.pm # once (5µs+-5µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Util/TypeConstraints/Builtins.pm:114] at line 112 of Moose/Util/TypeConstraints/Builtins.pm # once (6µs+-6µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Moose/Util/TypeConstraints/Builtins.pm:77] at line 72 of Moose/Util/TypeConstraints/Builtins.pm
sub _inline_check {
1859714µs my $self = shift;
186
1879748µs97420µs unless ( $self->can_be_inlined ) {
# spent 420µs making 97 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 4µs/call
188 throw_exception( CannotInlineTypeConstraintCheck => type_name => $self->name );
189 }
190
191974.97ms19466µs if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 36µs making 95 calls to Moose::Meta::TypeConstraint::constraint, avg 375ns/call # spent 30µs making 97 calls to Moose::Meta::TypeConstraint::has_parent, avg 306ns/call # spent 200ns making 1 call to Moose::Meta::TypeConstraint::parent # spent 10µs making 1 call to Moose::Meta::TypeConstraint::_inline_check, recursion: max depth 1, sum of overlapping time 10µs
192 return $self->parent->_inline_check(@_);
193 }
194
19596308µs192761µs return '( do { ' . $self->inlined->( $self, @_ ) . ' } )';
# spent 290µs making 35 calls to Moose::Meta::TypeConstraint::Class::__ANON__[Moose/Meta/TypeConstraint/Class.pm:25], avg 8µs/call # spent 181µs making 24 calls to Moose::Meta::TypeConstraint::Role::__ANON__[Moose/Meta/TypeConstraint/Role.pm:27], avg 8µs/call # spent 66µs making 4 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:60], avg 17µs/call # spent 66µs making 96 calls to Moose::Meta::TypeConstraint::inlined, avg 682ns/call # spent 33µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:77] # spent 32µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:114] # spent 31µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:106] # spent 20µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:170] # spent 16µs making 9 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:52], avg 2µs/call # spent 4µs making 5 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:40], avg 880ns/call # spent 3µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:146] # spent 2µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:157], avg 1µs/call # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:126] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:189] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:151] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:252] # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:119] # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:131] # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:217] # spent 1µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:22], avg 600ns/call # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:33] # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:66] # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:285]
196}
197
198
# spent 528µs (387+141) within Moose::Meta::TypeConstraint::inline_environment which was called 93 times, avg 6µs/call: # 75 times (321µs+122µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288, avg 6µs/call # 11 times (40µs+15µs) by Moose::Meta::TypeConstraint::Parameterized::inline_environment at line 85 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 5µs/call # 3 times (12µs+4µs) by Moose::Meta::Attribute::_eval_environment at line 777 of Moose/Meta/Attribute.pm, avg 5µs/call # 3 times (11µs+4µs) by Moose::Meta::Class::_eval_environment at line 542 of Moose/Meta/Class.pm, avg 5µs/call # once (3µs+-3µs) by Moose::Meta::TypeConstraint::inline_environment at line 201
sub inline_environment {
1999314µs my $self = shift;
200
20193102µs18669µs if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 36µs making 91 calls to Moose::Meta::TypeConstraint::constraint, avg 395ns/call # spent 33µs making 93 calls to Moose::Meta::TypeConstraint::has_parent, avg 355ns/call # spent 300ns making 1 call to Moose::Meta::TypeConstraint::parent # spent 4µs making 1 call to Moose::Meta::TypeConstraint::inline_environment, recursion: max depth 1, sum of overlapping time 4µs
202 return $self->parent->inline_environment;
203 }
204
20592158µs9272µs return $self->_inline_environment;
# spent 72µs making 92 calls to Moose::Meta::TypeConstraint::_inline_environment, avg 783ns/call
206}
207
208sub assert_valid {
209 my ( $self, $value ) = @_;
210
211 return 1 if $self->check($value);
212
213 throw_exception(
214 'ValidationFailedForTypeConstraint',
215 type => $self,
216 value => $value
217 );
218}
219
220sub get_message {
221 my ($self, $value) = @_;
222 my $msg = $self->has_message
223 ? $self->message
224 : $self->_default_message;
225 local $_ = $value;
226 return $msg->($value);
227}
228
229## type predicates ...
230
231
# spent 308µs (152+156) within Moose::Meta::TypeConstraint::equals which was called 21 times, avg 15µs/call: # 21 times (152µs+156µs) by Moose::Meta::TypeConstraint::is_subtype_of at line 269, avg 15µs/call
sub equals {
232213µs my ( $self, $type_or_name ) = @_;
233
2342111µs2159µs my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
# spent 59µs making 21 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 3µs/call
2352112µs218µs return if not $other;
# spent 8µs making 21 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 367ns/call
236
2372128µs4269µs return 1 if $self == $other;
# spent 69µs making 42 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 2µs/call
238
2391936µs3820µs return unless $self->constraint == $other->constraint;
# spent 20µs making 38 calls to Moose::Meta::TypeConstraint::constraint, avg 516ns/call
240
241 if ( $self->has_parent ) {
242 return unless $other->has_parent;
243 return unless $self->parent->equals( $other->parent );
244 } else {
245 return if $other->has_parent;
246 }
247
248 return;
249}
250
251sub is_a_type_of {
252 my ($self, $type_or_name) = @_;
253
254 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
255 return if not $type;
256
257 ($self->equals($type) || $self->is_subtype_of($type));
258}
259
260
# spent 508µs (114+394) within Moose::Meta::TypeConstraint::is_subtype_of which was called 7 times, avg 73µs/call: # 7 times (114µs+394µs) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 33 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 73µs/call
sub is_subtype_of {
26171µs my ($self, $type_or_name) = @_;
262
26374µs762µs my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
# spent 62µs making 7 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 9µs/call
26475µs73µs return if not $type;
# spent 3µs making 7 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 414ns/call
265
2667900ns my $current = $self;
267
268729µs4720µs while (my $parent = $current->parent) {
# spent 13µs making 26 calls to Moose::Meta::TypeConstraint::parent, avg 500ns/call # spent 7µs making 21 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 343ns/call
2692117µs21308µs return 1 if $parent->equals($type);
# spent 308µs making 21 calls to Moose::Meta::TypeConstraint::equals, avg 15µs/call
270193µs $current = $parent;
271 }
272
27356µs return 0;
274}
275
276## compiling the type constraint
277
278
# spent 28.6ms (4.89+23.7) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 77 times, avg 371µs/call: # 48 times (4.80ms+20.0ms) by Moose::Meta::TypeConstraint::new at line 125, avg 516µs/call # 15 times (45µs+1.83ms) by Moose::Meta::TypeConstraint::Class::new at line 40 of Moose/Meta/TypeConstraint/Class.pm, avg 125µs/call # 12 times (33µs+1.40ms) by Moose::Meta::TypeConstraint::Role::new at line 41 of Moose/Meta/TypeConstraint/Role.pm, avg 120µs/call # 2 times (10µs+487µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 57 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 249µs/call
sub compile_type_constraint {
2797712µs my $self = shift;
28077231µs15423.7ms $self->_compiled_type_constraint($self->_actually_compile_type_constraint);
# spent 23.4ms making 77 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 304µs/call # spent 277µs making 77 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 4µs/call
281}
282
283## type compilers ...
284
285
# spent 23.4ms (4.63+18.8) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 77 times, avg 304µs/call: # 77 times (4.63ms+18.8ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 280, avg 304µs/call
sub _actually_compile_type_constraint {
2867710µs my $self = shift;
287
288774.98ms30818.8ms if ( $self->can_be_inlined ) {
# spent 11.1ms making 77 calls to Eval::Closure::eval_closure, avg 144µs/call # spent 6.49ms making 75 calls to Moose::Meta::TypeConstraint::_inline_check, avg 86µs/call # spent 547µs making 75 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 7µs/call # spent 443µs making 75 calls to Moose::Meta::TypeConstraint::inline_environment, avg 6µs/call # spent 146µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::_inline_check, avg 73µs/call # spent 65µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 32µs/call # spent 49µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 25µs/call
289 return eval_closure(
290 source => 'sub { ' . $self->_inline_check('$_[0]') . ' }',
291 environment => $self->inline_environment,
292 );
293 }
294
295 my $check = $self->constraint;
296 unless ( defined $check ) {
297 throw_exception( NoConstraintCheckForTypeConstraint => type_name => $self->name );
298 }
299
300 return $self->_compile_subtype($check)
301 if $self->has_parent;
302
303 return $self->_compile_type($check);
304}
305
306sub _compile_subtype {
307 my ($self, $check) = @_;
308
309 # gather all the parent constraints in order
310 my @parents;
311 foreach my $parent ($self->_collect_all_parents) {
312 push @parents => $parent->constraint;
313 }
314
315 @parents = grep { $_ != $null_constraint } reverse @parents;
316
317 unless ( @parents ) {
318 return $self->_compile_type($check);
319 } else {
320 # general case, check all the constraints, from the first parent to ourselves
321 my @checks = @parents;
322 push @checks, $check if $check != $null_constraint;
323 return subname($self->name => sub {
324 my (@args) = @_;
325 local $_ = $args[0];
326 foreach my $check (@checks) {
327 return undef unless $check->(@args);
328 }
329 return 1;
330 });
331 }
332}
333
334sub _compile_type {
335 my ($self, $check) = @_;
336
337 return $check if $check == $null_constraint; # Item, Any
338
339 return subname($self->name => sub {
340 my (@args) = @_;
341 local $_ = $args[0];
342 $check->(@args);
343 });
344}
345
346## other utils ...
347
348sub _collect_all_parents {
349 my $self = shift;
350 my @parents;
351 my $current = $self->parent;
352 while (defined $current) {
353 push @parents => $current;
354 $current = $current->parent;
355 }
356 return @parents;
357}
358
359
# spent 6.46ms (52µs+6.41) within Moose::Meta::TypeConstraint::create_child_type which was called 16 times, avg 404µs/call: # 16 times (52µs+6.41ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 572 of Moose/Util/TypeConstraints.pm, avg 404µs/call
sub create_child_type {
3601612µs my ($self, %opts) = @_;
361164µs my $class = ref $self;
3621640µs166.41ms return $class->new(%opts, parent => $self);
# spent 6.41ms making 16 calls to Moose::Meta::TypeConstraint::new, avg 401µs/call
363}
364
365110µs1;
366
367# ABSTRACT: The Moose Type Constraint metaclass
368
369__END__