← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:46:02 2015

Filename/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint.pm
StatementsExecuted 10400 statements in 22.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
14176310.3ms16.4msMoose::Meta::TypeConstraint::::can_be_inlinedMoose::Meta::TypeConstraint::can_be_inlined (recurses: max depth 1, inclusive time 16µs)
796939.29ms25.1msMoose::Meta::TypeConstraint::::_inline_checkMoose::Meta::TypeConstraint::_inline_check (recurses: max depth 2, inclusive time 15.7ms)
444543.70ms5.67msMoose::Meta::TypeConstraint::::inline_environmentMoose::Meta::TypeConstraint::inline_environment (recurses: max depth 1, inclusive time 8µs)
48961.54ms17.4msMoose::Meta::TypeConstraint::::newMoose::Meta::TypeConstraint::new
7311806µs15.8msMoose::Meta::TypeConstraint::::_actually_compile_type_constraintMoose::Meta::TypeConstraint::_actually_compile_type_constraint
111578µs1.70msMoose::Meta::TypeConstraint::::BEGIN@6Moose::Meta::TypeConstraint::BEGIN@6
49084565µs565µsMoose::Meta::TypeConstraint::::__ANON__[:10]Moose::Meta::TypeConstraint::__ANON__[:10]
7344478µs16.7msMoose::Meta::TypeConstraint::::compile_type_constraintMoose::Meta::TypeConstraint::compile_type_constraint
2011276µs597µsMoose::Meta::TypeConstraint::::equalsMoose::Meta::TypeConstraint::equals
4811234µs234µsMoose::Meta::TypeConstraint::::__ANON__[:72]Moose::Meta::TypeConstraint::__ANON__[:72]
811226µs1.03msMoose::Meta::TypeConstraint::::is_subtype_ofMoose::Meta::TypeConstraint::is_subtype_of
1611117µs4.15msMoose::Meta::TypeConstraint::::create_child_typeMoose::Meta::TypeConstraint::create_child_type
4011108µs134µsMoose::Meta::TypeConstraint::::__ANON__[:8]Moose::Meta::TypeConstraint::__ANON__[:8]
482187µs87µsMoose::Meta::TypeConstraint::::__ANON__[:89]Moose::Meta::TypeConstraint::__ANON__[:89]
11126µs55µsMoose::Meta::TypeConstraint::::BEGIN@4Moose::Meta::TypeConstraint::BEGIN@4
11123µs73µsMoose::Meta::TypeConstraint::::BEGIN@8Moose::Meta::TypeConstraint::BEGIN@8
11114µs25µsMoose::Meta::TypeConstraint::::BEGIN@5Moose::Meta::TypeConstraint::BEGIN@5
11111µs47µsMoose::Meta::TypeConstraint::::BEGIN@14Moose::Meta::TypeConstraint::BEGIN@14
11111µs283µsMoose::Meta::TypeConstraint::::BEGIN@13Moose::Meta::TypeConstraint::BEGIN@13
11110µs40µsMoose::Meta::TypeConstraint::::BEGIN@16Moose::Meta::TypeConstraint::BEGIN@16
11110µs92µsMoose::Meta::TypeConstraint::::BEGIN@18Moose::Meta::TypeConstraint::BEGIN@18
11110µs31µsMoose::Meta::TypeConstraint::::BEGIN@15Moose::Meta::TypeConstraint::BEGIN@15
1119µs153µsMoose::Meta::TypeConstraint::::BEGIN@20Moose::Meta::TypeConstraint::BEGIN@20
3116µs6µsMoose::Meta::TypeConstraint::::__ANON__[:36]Moose::Meta::TypeConstraint::__ANON__[:36]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:327]Moose::Meta::TypeConstraint::__ANON__[:327]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:32]Moose::Meta::TypeConstraint::__ANON__[:32]
0000s0sMoose::Meta::TypeConstraint::::__ANON__[:340]Moose::Meta::TypeConstraint::__ANON__[:340]
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;
212µsour $VERSION = '2.1403';
3
4244µs284µs
# spent 55µs (26+29) within Moose::Meta::TypeConstraint::BEGIN@4 which was called: # once (26µs+29µs) by Moose::BEGIN@25 at line 4
use strict;
# spent 55µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@4 # spent 29µs making 1 call to strict::import
5239µs236µs
# spent 25µs (14+11) within Moose::Meta::TypeConstraint::BEGIN@5 which was called: # once (14µs+11µs) by Moose::BEGIN@25 at line 5
use warnings;
# spent 25µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@5 # spent 11µs making 1 call to warnings::import
62253µs22.71ms
# spent 1.70ms (578µs+1.12) within Moose::Meta::TypeConstraint::BEGIN@6 which was called: # once (578µs+1.12ms) by Moose::BEGIN@25 at line 6
use metaclass;
# spent 1.70ms making 1 call to Moose::Meta::TypeConstraint::BEGIN@6 # spent 1.00ms making 1 call to metaclass::import
7
840160µs4025µs
# spent 134µs (108+25) within Moose::Meta::TypeConstraint::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint.pm:8] which was called 40 times, avg 3µs/call: # 40 times (108µs+25µs) by Moose::Meta::TypeConstraint::equals at line 236, avg 3µs/call # spent 73µs (23+50) within Moose::Meta::TypeConstraint::BEGIN@8 which was called: # once (23µs+50µs) by Moose::BEGIN@25 at line 11
use overload '0+' => sub { refaddr(shift) }, # id an object
# spent 25µs making 40 calls to Scalar::Util::refaddr, avg 635ns/call
9 '""' => sub { shift->name }, # stringify to tc name
104901.02ms
# spent 565µs within Moose::Meta::TypeConstraint::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint.pm:10] which was called 490 times, avg 1µs/call: # 189 times (166µs+0s) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 246 of Moose/Util/TypeConstraints.pm, avg 878ns/call # 187 times (266µs+0s) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 260 of Moose/Util/TypeConstraints.pm, avg 1µs/call # 48 times (76µs+0s) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 47 of Moose/Meta/TypeConstraint/Registry.pm, avg 2µs/call # 20 times (17µs+0s) by Moose::Meta::TypeConstraint::equals at line 234, avg 865ns/call # 20 times (17µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 265, avg 860ns/call # 16 times (12µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 572 of Moose/Util/TypeConstraints.pm, avg 756ns/call # 8 times (8µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 261, avg 1µs/call # 2 times (2µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 78 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 800ns/call
bool => sub { 1 },
11243µs2123µs fallback => 1;
# spent 73µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@8 # spent 50µs making 1 call to overload::import
12
13237µs2555µs
# spent 283µs (11+272) within Moose::Meta::TypeConstraint::BEGIN@13 which was called: # once (11µs+272µs) by Moose::BEGIN@25 at line 13
use Eval::Closure;
# spent 283µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@13 # spent 272µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
14230µs283µs
# spent 47µs (11+36) within Moose::Meta::TypeConstraint::BEGIN@14 which was called: # once (11µs+36µs) by Moose::BEGIN@25 at line 14
use Scalar::Util qw(refaddr);
# spent 47µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14 # spent 36µs making 1 call to Exporter::import
15226µs252µs
# spent 31µs (10+21) within Moose::Meta::TypeConstraint::BEGIN@15 which was called: # once (10µs+21µs) by Moose::BEGIN@25 at line 15
use Sub::Name qw(subname);
# spent 31µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@15 # spent 21µs making 1 call to Exporter::import
16232µs271µs
# spent 40µs (10+30) within Moose::Meta::TypeConstraint::BEGIN@16 which was called: # once (10µs+30µs) by Moose::BEGIN@25 at line 16
use Try::Tiny;
# spent 40µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@16 # spent 30µs making 1 call to Exporter::import
17
18229µs2174µs
# spent 92µs (10+82) within Moose::Meta::TypeConstraint::BEGIN@18 which was called: # once (10µs+82µs) by Moose::BEGIN@25 at line 18
use base 'Class::MOP::Object';
# spent 92µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@18 # spent 82µs making 1 call to base::import
19
2022.05ms2297µs
# spent 153µs (9+144) within Moose::Meta::TypeConstraint::BEGIN@20 which was called: # once (9µs+144µs) by Moose::BEGIN@25 at line 20
use Moose::Util 'throw_exception';
# spent 153µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@20 # spent 144µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
21
22119µs31.07ms__PACKAGE__->meta->add_attribute('name' => (
# spent 1.00ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 54µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 17µs making 1 call to Class::MOP::_definition_context
23 reader => 'name',
24 Class::MOP::_definition_context(),
25));
2619µs3936µs__PACKAGE__->meta->add_attribute('parent' => (
# spent 907µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 20µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 10µs making 1 call to Class::MOP::_definition_context
27 reader => 'parent',
28 predicate => 'has_parent',
29 Class::MOP::_definition_context(),
30));
31
3213µsmy $null_constraint = sub { 1 };
33__PACKAGE__->meta->add_attribute('constraint' => (
34 reader => 'constraint',
35 writer => '_set_constraint',
3639µs
# spent 6µs within Moose::Meta::TypeConstraint::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint.pm:36] which was called 3 times, avg 2µs/call: # 3 times (6µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new or Moose::Meta::TypeConstraint::_new at line 24 of (eval 25)[Eval/Closure.pm:125], avg 2µs/call
default => sub { $null_constraint },
37113µs31.04ms Class::MOP::_definition_context(),
# spent 1.01ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 22µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 10µs making 1 call to Class::MOP::_definition_context
38));
39
4017µs3580µs__PACKAGE__->meta->add_attribute('message' => (
# spent 555µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 18µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 8µs making 1 call to Class::MOP::_definition_context
41 accessor => 'message',
42 predicate => 'has_message',
43 Class::MOP::_definition_context(),
44));
45
4615µs3321µs__PACKAGE__->meta->add_attribute('_default_message' => (
# spent 296µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 21µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 5µ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 234µs within Moose::Meta::TypeConstraint::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint.pm:72] which was called 48 times, avg 5µs/call: # 48 times (234µs+0s) by Moose::Meta::TypeConstraint::new at line 127, avg 5µs/call
my $_default_message_generator = sub {
544831µ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 }
7249227µs};
7316µs3699µs__PACKAGE__->meta->add_attribute('coercion' => (
# spent 684µ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
74 accessor => 'coercion',
75 predicate => 'has_coercion',
76 Class::MOP::_definition_context(),
77));
78
7916µs3514µs__PACKAGE__->meta->add_attribute('inlined' => (
# spent 488µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 8µ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',
8948135µs
# spent 87µs within Moose::Meta::TypeConstraint::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Meta/TypeConstraint.pm:89] which was called 48 times, avg 2µs/call: # 26 times (58µs+0s) by Moose::Meta::TypeConstraint::Class::_new or Moose::Meta::TypeConstraint::Parameterizable::_new at line 33 of (eval 25)[Eval/Closure.pm:125], avg 2µs/call # 22 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 25)[Eval/Closure.pm:125], avg 1µs/call
default => sub { {} },
9017µs3315µs Class::MOP::_definition_context(),
# spent 299µ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
91));
92
93sub parents {
94 my $self = shift;
95 $self->parent;
96}
97
98# private accessors
99
10015µs3500µs__PACKAGE__->meta->add_attribute('compiled_type_constraint' => (
# spent 484µ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
101 accessor => '_compiled_type_constraint',
102 predicate => '_has_compiled_type_constraint',
103 Class::MOP::_definition_context(),
104));
105
10615µs3308µs__PACKAGE__->meta->add_attribute('package_defined_in' => (
# spent 292µ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
107 accessor => '_package_defined_in',
108 Class::MOP::_definition_context(),
109));
110
111
# spent 17.4ms (1.54+15.9) within Moose::Meta::TypeConstraint::new which was called 48 times, avg 363µs/call: # 22 times (820µs+7.43ms) by Moose::Meta::TypeConstraint::Class::new at line 38 of Moose/Meta/TypeConstraint/Class.pm, avg 375µs/call # 16 times (373µs+3.66ms) by Moose::Meta::TypeConstraint::create_child_type at line 359, avg 252µs/call # 3 times (119µs+1.13ms) by Moose::Meta::TypeConstraint::Role::new at line 39 of Moose/Meta/TypeConstraint/Role.pm, avg 417µs/call # 2 times (79µs+2.40ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 90 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 1.24ms/call # once (36µs+342µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 198 of Moose/Util/TypeConstraints/Builtins.pm # once (38µs+309µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 582 of Moose/Util/TypeConstraints.pm # once (23µs+239µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 294 of Moose/Util/TypeConstraints/Builtins.pm # once (27µs+182µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 233 of Moose/Util/TypeConstraints/Builtins.pm # once (27µs+182µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 268 of Moose/Util/TypeConstraints/Builtins.pm
sub new {
1124824µs my $class = shift;
1134872µs my ($first, @rest) = @_;
11448134µs my %args = ref $first ? %$first : $first ? ($first, @rest) : ();
1154853µs $args{name} = $args{name} ? "$args{name}" : "__ANON__";
116
1174815µ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
12448188µs482.31ms my $self = $class->_new(%args);
# spent 1.23ms making 22 calls to Moose::Meta::TypeConstraint::Class::_new, avg 56µs/call # spent 361µs making 17 calls to Moose::Meta::TypeConstraint::_new, avg 21µs/call # spent 336µs making 3 calls to Moose::Meta::TypeConstraint::Role::_new, avg 112µs/call # spent 223µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::_new, avg 112µs/call # spent 162µs making 4 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 40µs/call
12548227µs9613.0ms $self->compile_type_constraint()
# spent 10.7ms making 46 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 233µs/call # spent 2.14ms making 2 calls to Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint, avg 1.07ms/call # spent 112µs making 48 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 2µs/call
126 unless $self->_has_compiled_type_constraint;
12748356µs192566µs $self->_default_message($_default_message_generator->($self->name))
# spent 234µs making 48 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:72], avg 5µs/call # spent 126µs making 48 calls to Moose::Meta::TypeConstraint::_default_message, avg 3µs/call # spent 106µs making 48 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call # spent 100µs making 48 calls to Moose::Meta::TypeConstraint::has_message, avg 2µs/call
128 unless $self->has_message;
12948212µ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 16.4ms (10.3+6.09) within Moose::Meta::TypeConstraint::can_be_inlined which was called 1417 times, avg 12µs/call: # 796 times (5.20ms+2.98ms) by Moose::Meta::TypeConstraint::_inline_check at line 187, avg 10µs/call # 350 times (2.72ms+1.66ms) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 13µs/call # 182 times (1.55ms+994µs) by Moose::Meta::Attribute::_eval_environment at line 766 of Moose/Meta/Attribute.pm, avg 14µs/call # 71 times (652µs+388µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 285, avg 15µs/call # 16 times (142µs+79µs) by Moose::Meta::TypeConstraint::Parameterized::can_be_inlined at line 72 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 14µs/call # 2 times (11µs+-11µs) by Moose::Meta::TypeConstraint::can_be_inlined at line 177, avg 0s/call
sub can_be_inlined {
1751417211µs my $self = shift;
176
17714173.13ms28334.04ms if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 2.08ms making 1412 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call # spent 1.95ms making 1417 calls to Moose::Meta::TypeConstraint::has_parent, avg 1µs/call # spent 4µs making 2 calls to Moose::Meta::TypeConstraint::parent, avg 2µs/call # spent 16µs making 2 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 8µs/call, recursion: max depth 1, sum of overlapping time 16µs
178 return $self->parent->can_be_inlined;
179 }
180
18114153.76ms14152.05ms return $self->_has_inlined_type_constraint;
# spent 2.05ms making 1415 calls to Moose::Meta::TypeConstraint::_has_inlined_type_constraint, avg 1µs/call
182}
183
184
# spent 25.1ms (9.29+15.8) within Moose::Meta::TypeConstraint::_inline_check which was called 796 times, avg 32µs/call: # 350 times (4.11ms+17.6ms) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 62µs/call # 184 times (2.06ms+-2.06ms) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Util/TypeConstraints/Builtins.pm:60] at line 58 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 125 times (1.39ms+-1.39ms) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Util/TypeConstraints/Builtins.pm:77] at line 72 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 71 times (982µs+2.15ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 285, avg 44µs/call # 36 times (413µs+-413µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Util/TypeConstraints/Builtins.pm:114] at line 112 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 22 times (236µs+-236µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Util/TypeConstraints/Builtins.pm:106] at line 97 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 6 times (78µs+242µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Util/TypeConstraints/Builtins.pm:292] at line 290 of Moose/Util/TypeConstraints/Builtins.pm, avg 53µs/call # once (10µs+-10µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/ap13/perl5/lib/perl5/darwin-2level/Moose/Util/TypeConstraints/Builtins.pm:170] at line 165 of Moose/Util/TypeConstraints/Builtins.pm # once (10µs+-10µs) by Moose::Meta::TypeConstraint::_inline_check at line 191
sub _inline_check {
185796172µs my $self = shift;
186
187796710µs7968.17ms unless ( $self->can_be_inlined ) {
# spent 8.17ms making 796 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 10µs/call
188 throw_exception( CannotInlineTypeConstraintCheck => type_name => $self->name );
189 }
190
1917961.65ms15921.96ms if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 1.01ms making 796 calls to Moose::Meta::TypeConstraint::has_parent, avg 1µs/call # spent 949µs making 794 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call # spent 1µs making 1 call to Moose::Meta::TypeConstraint::parent # spent 20µs making 1 call to Moose::Meta::TypeConstraint::_inline_check, recursion: max depth 1, sum of overlapping time 20µs
192 return $self->parent->_inline_check(@_);
193 }
194
1957953.80ms159021.4ms return '( do { ' . $self->inlined->( $self, @_ ) . ' } )';
# spent 8.36ms making 125 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:77], avg 67µs/call # spent 6.26ms making 184 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:60], avg 34µs/call # spent 2.40ms making 36 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:114], avg 67µs/call # spent 1.37ms making 22 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:106], avg 62µs/call # spent 1.14ms making 83 calls to Moose::Meta::TypeConstraint::Class::__ANON__[Moose/Meta/TypeConstraint/Class.pm:25], avg 14µs/call # spent 1.09ms making 795 calls to Moose::Meta::TypeConstraint::inlined, avg 1µs/call # spent 326µs making 185 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:40], avg 2µs/call # spent 135µs making 45 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:52], avg 3µs/call # spent 122µs making 55 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:252], avg 2µs/call # spent 93µs making 40 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:217], avg 2µs/call # spent 81µs making 6 calls to Moose::Meta::TypeConstraint::Role::__ANON__[Moose/Meta/TypeConstraint/Role.pm:27], avg 13µs/call # spent 37µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:170] # spent 4µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:157], avg 2µs/call # spent 4µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:146] # spent 3µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:119] # spent 3µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:189] # spent 2µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:22], avg 1µs/call # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:131] # 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:126] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:66] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:285] # spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:33]
196}
197
198
# spent 5.67ms (3.70+1.96) within Moose::Meta::TypeConstraint::inline_environment which was called 444 times, avg 13µs/call: # 182 times (1.56ms+795µs) by Moose::Meta::Attribute::_eval_environment at line 777 of Moose/Meta/Attribute.pm, avg 13µs/call # 170 times (1.39ms+773µs) by Moose::Meta::Class::_eval_environment at line 535 of Moose/Meta/Class.pm, avg 13µs/call # 71 times (588µs+307µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 285, avg 13µs/call # 20 times (161µs+95µs) by Moose::Meta::TypeConstraint::Parameterized::inline_environment at line 85 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 13µs/call # once (6µs+-6µs) by Moose::Meta::TypeConstraint::inline_environment at line 201
sub inline_environment {
199444128µs my $self = shift;
200
201444958µs8881.19ms if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 598µs making 444 calls to Moose::Meta::TypeConstraint::has_parent, avg 1µs/call # spent 588µs making 442 calls to Moose::Meta::TypeConstraint::constraint, avg 1µs/call # spent 1µs making 1 call to Moose::Meta::TypeConstraint::parent # spent 8µs making 1 call to Moose::Meta::TypeConstraint::inline_environment, recursion: max depth 1, sum of overlapping time 8µs
202 return $self->parent->inline_environment;
203 }
204
2054431.39ms443777µs return $self->_inline_environment;
# spent 777µs making 443 calls to Moose::Meta::TypeConstraint::_inline_environment, avg 2µs/call
206}
207
208sub assert_valid {
209 my ($self, $value) = @_;
210
211 my $error = $self->validate($value);
212 return 1 if ! defined $error;
213
214 throw_exception( ValidationFailedForTypeConstraint => type => $self,
215 error_message => $error,
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 597µs (276+321) within Moose::Meta::TypeConstraint::equals which was called 20 times, avg 30µs/call: # 20 times (276µs+321µs) by Moose::Meta::TypeConstraint::is_subtype_of at line 266, avg 30µs/call
sub equals {
2322010µs my ( $self, $type_or_name ) = @_;
233
2342042µs40133µs my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 116µs making 20 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 6µs/call # spent 17µs making 20 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 865ns/call
235
2362050µs40134µs return 1 if $self == $other;
# spent 134µs making 40 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 3µs/call
237
2381873µs3654µs return unless $self->constraint == $other->constraint;
# spent 54µs making 36 calls to Moose::Meta::TypeConstraint::constraint, avg 2µs/call
239
240 if ( $self->has_parent ) {
241 return unless $other->has_parent;
242 return unless $self->parent->equals( $other->parent );
243 } else {
244 return if $other->has_parent;
245 }
246
247 return;
248}
249
250sub is_a_type_of {
251 my ($self, $type_or_name) = @_;
252
253 my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
254
255 ($self->equals($type) || $self->is_subtype_of($type));
256}
257
258
# spent 1.03ms (226µs+802µs) within Moose::Meta::TypeConstraint::is_subtype_of which was called 8 times, avg 128µs/call: # 8 times (226µs+802µs) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 33 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 128µs/call
sub is_subtype_of {
25985µs my ($self, $type_or_name) = @_;
260
261820µs16150µs my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return;
# spent 142µs making 8 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 18µs/call # spent 8µs making 8 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 1µs/call
262
26381µs my $current = $self;
264
265862µs4655µs while (my $parent = $current->parent) {
# spent 38µs making 26 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call # spent 17µs making 20 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 860ns/call
2662028µs20597µs return 1 if $parent->equals($type);
# spent 597µs making 20 calls to Moose::Meta::TypeConstraint::equals, avg 30µs/call
267187µs $current = $parent;
268 }
269
270615µs return 0;
271}
272
273## compiling the type constraint
274
275
# spent 16.7ms (478µs+16.3) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 73 times, avg 229µs/call: # 46 times (325µs+10.4ms) by Moose::Meta::TypeConstraint::new at line 125, avg 233µs/call # 22 times (120µs+4.56ms) by Moose::Meta::TypeConstraint::Class::new at line 40 of Moose/Meta/TypeConstraint/Class.pm, avg 213µs/call # 3 times (15µs+540µs) by Moose::Meta::TypeConstraint::Role::new at line 41 of Moose/Meta/TypeConstraint/Role.pm, avg 185µs/call # 2 times (18µs+762µs) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 57 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 390µs/call
sub compile_type_constraint {
2767320µs my $self = shift;
27773384µs14616.3ms $self->_compiled_type_constraint($self->_actually_compile_type_constraint);
# spent 15.8ms making 73 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 217µs/call # spent 450µs making 73 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 6µs/call
278}
279
280## type compilers ...
281
282
# spent 15.8ms (806µs+15.0) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 73 times, avg 217µs/call: # 73 times (806µs+15.0ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 277, avg 217µs/call
sub _actually_compile_type_constraint {
2837312µs my $self = shift;
284
28573557µs29215.0ms if ( $self->can_be_inlined ) {
# spent 9.51ms making 73 calls to Eval::Closure::eval_closure, avg 130µs/call # spent 3.13ms making 71 calls to Moose::Meta::TypeConstraint::_inline_check, avg 44µs/call # spent 1.04ms making 71 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 15µs/call # spent 895µs making 71 calls to Moose::Meta::TypeConstraint::inline_environment, avg 13µs/call # spent 268µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::_inline_check, avg 134µs/call # spent 91µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 46µs/call # spent 77µs making 2 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 38µs/call
286 return eval_closure(
287 source => 'sub { ' . $self->_inline_check('$_[0]') . ' }',
288 environment => $self->inline_environment,
289 );
290 }
291
292 my $check = $self->constraint;
293 unless ( defined $check ) {
294 throw_exception( NoConstraintCheckForTypeConstraint => type_name => $self->name );
295 }
296
297 return $self->_compile_subtype($check)
298 if $self->has_parent;
299
300 return $self->_compile_type($check);
301}
302
303sub _compile_subtype {
304 my ($self, $check) = @_;
305
306 # gather all the parent constraints in order
307 my @parents;
308 foreach my $parent ($self->_collect_all_parents) {
309 push @parents => $parent->constraint;
310 }
311
312 @parents = grep { $_ != $null_constraint } reverse @parents;
313
314 unless ( @parents ) {
315 return $self->_compile_type($check);
316 } else {
317 # general case, check all the constraints, from the first parent to ourselves
318 my @checks = @parents;
319 push @checks, $check if $check != $null_constraint;
320 return subname($self->name => sub {
321 my (@args) = @_;
322 local $_ = $args[0];
323 foreach my $check (@checks) {
324 return undef unless $check->(@args);
325 }
326 return 1;
327 });
328 }
329}
330
331sub _compile_type {
332 my ($self, $check) = @_;
333
334 return $check if $check == $null_constraint; # Item, Any
335
336 return subname($self->name => sub {
337 my (@args) = @_;
338 local $_ = $args[0];
339 $check->(@args);
340 });
341}
342
343## other utils ...
344
345sub _collect_all_parents {
346 my $self = shift;
347 my @parents;
348 my $current = $self->parent;
349 while (defined $current) {
350 push @parents => $current;
351 $current = $current->parent;
352 }
353 return @parents;
354}
355
356
# spent 4.15ms (117µs+4.03) within Moose::Meta::TypeConstraint::create_child_type which was called 16 times, avg 259µs/call: # 16 times (117µs+4.03ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 572 of Moose/Util/TypeConstraints.pm, avg 259µs/call
sub create_child_type {
3571624µs my ($self, %opts) = @_;
358169µs my $class = ref $self;
3591684µs164.03ms return $class->new(%opts, parent => $self);
# spent 4.03ms making 16 calls to Moose::Meta::TypeConstraint::new, avg 252µs/call
360}
361
362144µs1;
363
364# ABSTRACT: The Moose Type Constraint metaclass
365
366__END__