← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:10 2016

Filename/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint.pm
StatementsExecuted 11727 statements in 35.4ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1321957.57ms11.5msMoose::Meta::TypeConstraint::::can_be_inlinedMoose::Meta::TypeConstraint::can_be_inlined (recurses: max depth 1, inclusive time 12µs)
961076.94ms41.5msMoose::Meta::TypeConstraint::::newMoose::Meta::TypeConstraint::new
6111355.91ms19.1msMoose::Meta::TypeConstraint::::_inline_checkMoose::Meta::TypeConstraint::_inline_check (recurses: max depth 2, inclusive time 4.64ms)
88214.96ms5.89msMoose::Meta::TypeConstraint::::equalsMoose::Meta::TypeConstraint::equals
607763.71ms5.40msMoose::Meta::TypeConstraint::::inline_environmentMoose::Meta::TypeConstraint::inline_environment (recurses: max depth 1, inclusive time 17µs)
160111.37ms32.3msMoose::Meta::TypeConstraint::::_actually_compile_type_constraintMoose::Meta::TypeConstraint::_actually_compile_type_constraint
16244850µs33.9msMoose::Meta::TypeConstraint::::compile_type_constraintMoose::Meta::TypeConstraint::compile_type_constraint
674166506µs506µsMoose::Meta::TypeConstraint::::__ANON__[:10]Moose::Meta::TypeConstraint::__ANON__[:10]
2322463µs1.99msMoose::Meta::TypeConstraint::::is_subtype_ofMoose::Meta::TypeConstraint::is_subtype_of
9611436µs436µsMoose::Meta::TypeConstraint::::__ANON__[:72]Moose::Meta::TypeConstraint::__ANON__[:72]
17611352µs421µsMoose::Meta::TypeConstraint::::__ANON__[:8]Moose::Meta::TypeConstraint::__ANON__[:8]
111290µs825µsMoose::Meta::TypeConstraint::::BEGIN@6Moose::Meta::TypeConstraint::BEGIN@6
3211260µs5.60msMoose::Meta::TypeConstraint::::is_a_type_ofMoose::Meta::TypeConstraint::is_a_type_of
9621160µs160µsMoose::Meta::TypeConstraint::::__ANON__[:89]Moose::Meta::TypeConstraint::__ANON__[:89]
161168µs3.27msMoose::Meta::TypeConstraint::::create_child_typeMoose::Meta::TypeConstraint::create_child_type
101116µs16µsMoose::Meta::TypeConstraint::::__ANON__[:36]Moose::Meta::TypeConstraint::__ANON__[:36]
11113µs47µsMoose::Meta::TypeConstraint::::BEGIN@8Moose::Meta::TypeConstraint::BEGIN@8
11110µs23µsMoose::Meta::TypeConstraint::::BEGIN@4Moose::Meta::TypeConstraint::BEGIN@4
1119µs42µsMoose::Meta::TypeConstraint::::BEGIN@13Moose::Meta::TypeConstraint::BEGIN@13
1118µs167µsMoose::Meta::TypeConstraint::::BEGIN@20Moose::Meta::TypeConstraint::BEGIN@20
1118µs14µsMoose::Meta::TypeConstraint::::BEGIN@5Moose::Meta::TypeConstraint::BEGIN@5
1117µs31µsMoose::Meta::TypeConstraint::::BEGIN@16Moose::Meta::TypeConstraint::BEGIN@16
1117µs26µsMoose::Meta::TypeConstraint::::BEGIN@14Moose::Meta::TypeConstraint::BEGIN@14
1117µs23µsMoose::Meta::TypeConstraint::::BEGIN@15Moose::Meta::TypeConstraint::BEGIN@15
1117µs72µsMoose::Meta::TypeConstraint::::BEGIN@18Moose::Meta::TypeConstraint::BEGIN@18
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::::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;
211µsour $VERSION = '2.1604';
3
4222µs237µs
# spent 23µs (10+13) within Moose::Meta::TypeConstraint::BEGIN@4 which was called: # once (10µs+13µs) by Moose::BEGIN@25 at line 4
use strict;
# spent 23µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@4 # spent 13µs making 1 call to strict::import
5219µs220µs
# spent 14µs (8+6) within Moose::Meta::TypeConstraint::BEGIN@5 which was called: # once (8µs+6µs) by Moose::BEGIN@25 at line 5
use warnings;
# spent 14µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@5 # spent 6µs making 1 call to warnings::import
62131µs21.31ms
# spent 825µs (290+535) within Moose::Meta::TypeConstraint::BEGIN@6 which was called: # once (290µs+535µs) by Moose::BEGIN@25 at line 6
use metaclass;
# spent 825µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@6 # spent 482µs making 1 call to metaclass::import
7
81764.62ms17669µs
# spent 421µs (352+69) within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint.pm:8] which was called 176 times, avg 2µs/call: # 176 times (352µs+69µs) by Moose::Meta::TypeConstraint::equals at line 237, avg 2µs/call # spent 47µs (13+34) within Moose::Meta::TypeConstraint::BEGIN@8 which was called: # once (13µs+34µs) by Moose::BEGIN@25 at line 11
use overload '0+' => sub { refaddr(shift) }, # id an object
# spent 69µs making 176 calls to Scalar::Util::refaddr, avg 390ns/call
9 '""' => sub { shift->name }, # stringify to tc name
106741.14ms
# spent 506µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint.pm:10] which was called 674 times, avg 751ns/call: # 156 times (176µs+0s) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 260 of Moose/Util/TypeConstraints.pm, avg 1µs/call # 120 times (54µs+0s) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 246 of Moose/Util/TypeConstraints.pm, avg 450ns/call # 96 times (120µs+0s) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 47 of Moose/Meta/TypeConstraint/Registry.pm, avg 1µs/call # 88 times (43µs+0s) by Moose::Meta::TypeConstraint::equals at line 235, avg 485ns/call # 61 times (26µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 268, avg 431ns/call # 32 times (17µs+0s) by Moose::Meta::TypeConstraint::is_a_type_of at line 255, avg 528ns/call # 32 times (15µs+0s) by Moose::Util::TypeConstraints::find_or_create_type_constraint at line 218 of Moose/Util/TypeConstraints.pm, avg 466ns/call # 23 times (12µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 264, avg 526ns/call # 17 times (20µs+0s) by Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type at line 36 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 1µs/call # 16 times (7µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 572 of Moose/Util/TypeConstraints.pm, avg 419ns/call # 8 times (4µs+0s) by Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type at line 39 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 450ns/call # 8 times (4µs+0s) by Moose::Util::TypeConstraints::find_or_create_does_type_constraint at line 252 of Moose/Util/TypeConstraints.pm, avg 450ns/call # 7 times (4µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 78 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 514ns/call # 5 times (3µs+0s) by Class::MOP::Class:::around at line 146 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 620ns/call # 4 times (2µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint_union at line 97 of Moose/Util/TypeConstraints.pm, avg 450ns/call # once (2µs+0s) by Moose::Role::init_meta at line 126 of Moose/Role.pm
bool => sub { 1 },
11227µs281µs fallback => 1;
# spent 47µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@8 # spent 34µs making 1 call to overload::import
12
13228µs275µs
# spent 42µs (9+33) within Moose::Meta::TypeConstraint::BEGIN@13 which was called: # once (9µs+33µs) by Moose::BEGIN@25 at line 13
use Eval::Closure;
# spent 42µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@13 # spent 33µs making 1 call to Exporter::import
14222µs246µs
# spent 26µs (7+20) within Moose::Meta::TypeConstraint::BEGIN@14 which was called: # once (7µs+20µs) by Moose::BEGIN@25 at line 14
use Scalar::Util qw(refaddr);
# spent 26µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14 # spent 20µs making 1 call to Exporter::import
15220µs239µs
# spent 23µs (7+16) within Moose::Meta::TypeConstraint::BEGIN@15 which was called: # once (7µs+16µs) by Moose::BEGIN@25 at line 15
use Sub::Name qw(subname);
# spent 23µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@15 # spent 16µs making 1 call to Exporter::import
16221µs254µs
# spent 31µs (7+24) within Moose::Meta::TypeConstraint::BEGIN@16 which was called: # once (7µs+24µs) by Moose::BEGIN@25 at line 16
use Try::Tiny;
# spent 31µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@16 # spent 24µs making 1 call to Exporter::import
17
18227µs2138µs
# spent 72µs (7+65) within Moose::Meta::TypeConstraint::BEGIN@18 which was called: # once (7µs+65µs) by Moose::BEGIN@25 at line 18
use base 'Class::MOP::Object';
# spent 72µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@18 # spent 65µs making 1 call to base::import
19
2021.30ms2326µs
# spent 167µs (8+159) within Moose::Meta::TypeConstraint::BEGIN@20 which was called: # once (8µs+159µs) by Moose::BEGIN@25 at line 20
use Moose::Util 'throw_exception';
# spent 167µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@20 # spent 159µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
21
2214µs3384µs__PACKAGE__->meta->add_attribute('name' => (
# spent 362µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 17µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 6µs making 1 call to Class::MOP::_definition_context
23 reader => 'name',
24 Class::MOP::_definition_context(),
25));
2613µs3412µs__PACKAGE__->meta->add_attribute('parent' => (
# spent 400µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µ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
3212µsmy $null_constraint = sub { 1 };
33__PACKAGE__->meta->add_attribute('constraint' => (
34 reader => 'constraint',
35 writer => '_set_constraint',
361024µs
# spent 16µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint.pm:36] which was called 10 times, avg 2µs/call: # 10 times (16µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new or Moose::Meta::TypeConstraint::Union::_new or Moose::Meta::TypeConstraint::_new at line 24 of (eval 45)[Eval/Closure.pm:144], avg 2µs/call
default => sub { $null_constraint },
3714µs3405µs Class::MOP::_definition_context(),
# spent 393µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µs making 1 call to Class::MOP::_definition_context
38));
39
4012µs3386µs__PACKAGE__->meta->add_attribute('message' => (
# spent 375µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µs making 1 call to Class::MOP::_definition_context
41 accessor => 'message',
42 predicate => 'has_message',
43 Class::MOP::_definition_context(),
44));
45
4612µs3262µs__PACKAGE__->meta->add_attribute('_default_message' => (
# spent 251µ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
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 436µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint.pm:72] which was called 96 times, avg 5µs/call: # 96 times (436µs+0s) by Moose::Meta::TypeConstraint::new at line 127, avg 5µs/call
my $_default_message_generator = sub {
549649µ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 }
7297432µs};
7313µs3372µs__PACKAGE__->meta->add_attribute('coercion' => (
# spent 360µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µs making 1 call to Class::MOP::_definition_context
74 accessor => 'coercion',
75 predicate => 'has_coercion',
76 Class::MOP::_definition_context(),
77));
78
7913µs34.35ms__PACKAGE__->meta->add_attribute('inlined' => (
# spent 4.34ms making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µ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',
89965.35ms
# spent 160µs within Moose::Meta::TypeConstraint::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Meta/TypeConstraint.pm:89] which was called 96 times, avg 2µs/call: # 61 times (99µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new or Moose::Meta::TypeConstraint::Role::_new or Moose::Meta::TypeConstraint::Union::_new or Moose::Meta::TypeConstraint::_new at line 30 of (eval 45)[Eval/Closure.pm:144], avg 2µs/call # 35 times (60µs+0s) by Moose::Meta::TypeConstraint::Class::_new or Moose::Meta::TypeConstraint::Parameterizable::_new at line 33 of (eval 45)[Eval/Closure.pm:144], avg 2µs/call
default => sub { {} },
9015µs3261µs Class::MOP::_definition_context(),
# spent 248µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 9µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µ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
10013µs3378µs__PACKAGE__->meta->add_attribute('compiled_type_constraint' => (
# spent 366µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µ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
10613µs3236µs__PACKAGE__->meta->add_attribute('package_defined_in' => (
# spent 225µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute # spent 8µs making 1 call to Moose::Meta::TypeConstraint::meta # spent 4µs making 1 call to Class::MOP::_definition_context
107 accessor => '_package_defined_in',
108 Class::MOP::_definition_context(),
109));
110
111
# spent 41.5ms (6.94+34.6) within Moose::Meta::TypeConstraint::new which was called 96 times, avg 433µs/call: # 35 times (895µs+14.0ms) by Moose::Meta::TypeConstraint::Role::new at line 39 of Moose/Meta/TypeConstraint/Role.pm, avg 424µs/call # 31 times (5.43ms+11.1ms) by Moose::Meta::TypeConstraint::Class::new at line 38 of Moose/Meta/TypeConstraint/Class.pm, avg 534µs/call # 16 times (256µs+2.95ms) by Moose::Meta::TypeConstraint::create_child_type at line 362, avg 200µs/call # 7 times (187µs+5.32ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 90 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 786µs/call # 2 times (60µs+205µs) by Moose::Meta::TypeConstraint::Union::new at line 26 of Moose/Meta/TypeConstraint/Union.pm, avg 132µs/call # once (31µs+280µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 582 of Moose/Util/TypeConstraints.pm # once (30µs+279µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 198 of Moose/Util/TypeConstraints/Builtins.pm # once (20µs+180µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 233 of Moose/Util/TypeConstraints/Builtins.pm # once (18µs+150µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 268 of Moose/Util/TypeConstraints/Builtins.pm # once (18µs+147µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 294 of Moose/Util/TypeConstraints/Builtins.pm
sub new {
1129631µs my $class = shift;
1139673µs my ($first, @rest) = @_;
11496235µs my %args = ref $first ? %$first : $first ? ($first, @rest) : ();
11596128µs $args{name} = $args{name} ? "$args{name}" : "__ANON__";
116
1179643µ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
12496262µs967.72ms my $self = $class->_new(%args);
# spent 6.06ms making 35 calls to Moose::Meta::TypeConstraint::Role::_new, avg 173µs/call # spent 828µs making 31 calls to Moose::Meta::TypeConstraint::Class::_new, avg 27µs/call # spent 286µs making 17 calls to Moose::Meta::TypeConstraint::_new, avg 17µs/call # spent 274µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::_new, avg 39µs/call # spent 139µs making 4 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 35µs/call # spent 134µs making 2 calls to Moose::Meta::TypeConstraint::Union::_new, avg 67µs/call
12596332µs19225.8ms $self->compile_type_constraint()
# spent 20.7ms making 89 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 232µs/call # spent 4.96ms making 7 calls to Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint, avg 708µs/call # spent 194µs making 96 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 2µs/call
126 unless $self->_has_compiled_type_constraint;
12796582µs3841.04ms $self->_default_message($_default_message_generator->($self->name))
# spent 436µs making 96 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:72], avg 5µs/call # spent 242µs making 96 calls to Moose::Meta::TypeConstraint::_default_message, avg 3µs/call # spent 181µs making 96 calls to Moose::Meta::TypeConstraint::name, avg 2µs/call # spent 178µs making 96 calls to Moose::Meta::TypeConstraint::has_message, avg 2µs/call
128 unless $self->has_message;
12996302µ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 11.5ms (7.57+3.94) within Moose::Meta::TypeConstraint::can_be_inlined which was called 1321 times, avg 9µs/call: # 611 times (2.91ms+1.38ms) by Moose::Meta::TypeConstraint::_inline_check at line 187, avg 7µs/call # 253 times (1.49ms+776µs) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 9µs/call # 165 times (1.19ms+694µs) by Moose::Meta::Attribute::_eval_environment at line 766 of Moose/Meta/Attribute.pm, avg 11µs/call # 153 times (1.03ms+585µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288, avg 11µs/call # 88 times (660µs+381µs) by Moose::Meta::TypeConstraint::Parameterized::can_be_inlined at line 72 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 12µs/call # 44 times (236µs+116µs) by Moose::Meta::TypeConstraint::Union::can_be_inlined at line 80 of Moose/Meta/TypeConstraint/Union.pm, avg 8µs/call # 4 times (32µs+16µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint at line 103 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 12µs/call # 2 times (9µs+-9µs) by Moose::Meta::TypeConstraint::can_be_inlined at line 177, avg 0s/call # once (6µs+2µs) by Moose::Meta::Attribute::_inline_check_coercion at line 662 of Moose/Meta/Attribute.pm
sub can_be_inlined {
1751321190µs my $self = shift;
176
17713212.28ms26412.64ms if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 1.39ms making 1321 calls to Moose::Meta::TypeConstraint::has_parent, avg 1µs/call # spent 1.25ms making 1316 calls to Moose::Meta::TypeConstraint::constraint, avg 949ns/call # spent 3µs making 2 calls to Moose::Meta::TypeConstraint::parent, avg 1µs/call # spent 12µs making 2 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 6µs/call, recursion: max depth 1, sum of overlapping time 12µs
178 return $self->parent->can_be_inlined;
179 }
180
18113193.04ms13191.30ms return $self->_has_inlined_type_constraint;
# spent 1.30ms making 1319 calls to Moose::Meta::TypeConstraint::_has_inlined_type_constraint, avg 986ns/call
182}
183
184
# spent 19.1ms (5.91+13.2) within Moose::Meta::TypeConstraint::_inline_check which was called 611 times, avg 31µs/call: # 253 times (2.32ms+6.78ms) by Moose::Meta::Attribute::_inline_check_constraint at line 686 of Moose/Meta/Attribute.pm, avg 36µs/call # 153 times (1.60ms+6.52ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288, avg 53µs/call # 75 times (640µs+-640µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Util/TypeConstraints/Builtins.pm:60] at line 58 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 60 times (515µs+-515µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Util/TypeConstraints/Builtins.pm:77] at line 72 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 18 times (228µs+471µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Util/TypeConstraints/Builtins.pm:266] at line 258 of Moose/Util/TypeConstraints/Builtins.pm, avg 39µs/call # 16 times (154µs+259µs) by Moose::Meta::TypeConstraint::Union::_inline_check at line 90 of Moose/Meta/TypeConstraint/Union.pm, avg 26µs/call # 15 times (271µs+347µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Util/TypeConstraints/Builtins.pm:231] at line 223 of Moose/Util/TypeConstraints/Builtins.pm, avg 41µs/call # 11 times (86µs+-86µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Util/TypeConstraints/Builtins.pm:114] at line 112 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # 4 times (46µs+90µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint at line 103 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 34µs/call # 3 times (25µs+-25µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.18.2/Moose/Util/TypeConstraints/Builtins.pm:106] at line 97 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call # once (9µs+20µs) by Moose::Meta::Attribute::_inline_check_coercion at line 662 of Moose/Meta/Attribute.pm # once (8µs+-8µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/usr/local/lib/perl/5.18.2/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 {
185611114µs my $self = shift;
186
187611364µs6114.29ms unless ( $self->can_be_inlined ) {
# spent 4.29ms making 611 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 7µs/call
188 throw_exception( CannotInlineTypeConstraintCheck => type_name => $self->name );
189 }
190
191611936µs1222886µs if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 466µs making 611 calls to Moose::Meta::TypeConstraint::has_parent, avg 764ns/call # spent 419µs making 609 calls to Moose::Meta::TypeConstraint::constraint, avg 687ns/call # spent 800ns making 1 call to Moose::Meta::TypeConstraint::parent # spent 28µs making 1 call to Moose::Meta::TypeConstraint::_inline_check, recursion: max depth 1, sum of overlapping time 28µs
192 return $self->parent->_inline_check(@_);
193 }
194
1956102.42ms122012.6ms return '( do { ' . $self->inlined->( $self, @_ ) . ' } )';
# spent 5.02ms making 149 calls to Moose::Meta::TypeConstraint::Class::__ANON__[Moose/Meta/TypeConstraint/Class.pm:25], avg 34µs/call # spent 3.09ms making 60 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:77], avg 52µs/call # spent 1.89ms making 75 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:60], avg 25µs/call # spent 942µs making 89 calls to Moose::Meta::TypeConstraint::Role::__ANON__[Moose/Meta/TypeConstraint/Role.pm:27], avg 11µs/call # spent 693µs making 610 calls to Moose::Meta::TypeConstraint::inlined, avg 1µs/call # spent 468µs making 11 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:114], avg 43µs/call # spent 144µs making 3 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:106], avg 48µs/call # spent 124µs making 58 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:52], avg 2µs/call # spent 104µs making 76 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:40], avg 1µs/call # spent 81µs making 53 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:252], avg 2µs/call # spent 33µs making 22 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:217], avg 2µs/call # spent 27µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:170] # spent 3µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:189] # 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 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:22], avg 800ns/call # 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:33] # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:151] # spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:285] # 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:131]
196}
197
198
# spent 5.40ms (3.71+1.69) within Moose::Meta::TypeConstraint::inline_environment which was called 607 times, avg 9µs/call: # 173 times (921µs+411µs) by Moose::Meta::Class::_eval_environment at line 535 of Moose/Meta/Class.pm, avg 8µs/call # 165 times (1.10ms+494µs) by Moose::Meta::Attribute::_eval_environment at line 777 of Moose/Meta/Attribute.pm, avg 10µs/call # 153 times (954µs+452µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 288, avg 9µs/call # 87 times (588µs+271µs) by Moose::Meta::TypeConstraint::Parameterized::inline_environment at line 85 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 10µs/call # 24 times (116µs+51µs) by Moose::Meta::TypeConstraint::Union::inline_environment at line 101 of Moose/Meta/TypeConstraint/Union.pm, avg 7µs/call # 4 times (25µs+13µs) by Class::MOP::Class:::around at line 158 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 9µs/call # once (6µs+-6µs) by Moose::Meta::TypeConstraint::inline_environment at line 201
sub inline_environment {
199607138µs my $self = shift;
200
201607920µs1214924µs if ( $self->has_parent && $self->constraint == $null_constraint ) {
# spent 464µs making 605 calls to Moose::Meta::TypeConstraint::constraint, avg 767ns/call # spent 460µs making 607 calls to Moose::Meta::TypeConstraint::has_parent, avg 757ns/call # spent 800ns making 1 call to Moose::Meta::TypeConstraint::parent # spent 17µs making 1 call to Moose::Meta::TypeConstraint::inline_environment, recursion: max depth 1, sum of overlapping time 17µs
202 return $self->parent->inline_environment;
203 }
204
2056066.97ms606761µs return $self->_inline_environment;
# spent 761µs making 606 calls to Moose::Meta::TypeConstraint::_inline_environment, avg 1µs/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 5.89ms (4.96+938µs) within Moose::Meta::TypeConstraint::equals which was called 88 times, avg 67µs/call: # 61 times (593µs+598µs) by Moose::Meta::TypeConstraint::is_subtype_of at line 269, avg 20µs/call # 27 times (4.36ms+340µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 257, avg 174µs/call
sub equals {
2328824µs my ( $self, $type_or_name ) = @_;
233
2348858µs88392µs my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
# spent 392µs making 88 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 4µs/call
2358882µs8843µs return if not $other;
# spent 43µs making 88 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 485ns/call
236
23788270µs176421µs return 1 if $self == $other;
# spent 421µs making 176 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:8], avg 2µs/call
238
23949134µs9883µs return unless $self->constraint == $other->constraint;
# spent 83µs making 98 calls to Moose::Meta::TypeConstraint::constraint, avg 849ns/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
251
# spent 5.60ms (260µs+5.34) within Moose::Meta::TypeConstraint::is_a_type_of which was called 32 times, avg 175µs/call: # 32 times (260µs+5.34ms) by Moose::Meta::Attribute::Native::Trait::_check_helper_type at line 41 of Moose/Meta/Attribute/Native/Trait.pm, avg 175µs/call
sub is_a_type_of {
2523212µs my ($self, $type_or_name) = @_;
253
2543226µs32352µs my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
# spent 352µs making 32 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 11µs/call
2553233µs3217µs return if not $type;
# spent 17µs making 32 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 528ns/call
256
25732100µs374.97ms ($self->equals($type) || $self->is_subtype_of($type));
# spent 4.70ms making 27 calls to Moose::Meta::TypeConstraint::equals, avg 174µs/call # spent 161µs making 5 calls to Moose::Meta::TypeConstraint::is_subtype_of, avg 32µs/call # spent 102µs making 5 calls to Moose::Meta::TypeConstraint::Parameterized::equals, avg 20µs/call
258}
259
260
# spent 1.99ms (463µs+1.53) within Moose::Meta::TypeConstraint::is_subtype_of which was called 23 times, avg 87µs/call: # 18 times (416µs+1.41ms) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 33 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 102µs/call # 5 times (47µs+114µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 257, avg 32µs/call
sub is_subtype_of {
261239µs my ($self, $type_or_name) = @_;
262
2632315µs23233µs my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
# spent 233µs making 23 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 10µs/call
2642324µs2312µs return if not $type;
# spent 12µs making 23 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 526ns/call
265
266234µs my $current = $self;
267
26823119µs13391µs while (my $parent = $current->parent) {
# spent 64µs making 72 calls to Moose::Meta::TypeConstraint::parent, avg 894ns/call # spent 26µs making 61 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:10], avg 431ns/call
2696169µs611.19ms return 1 if $parent->equals($type);
# spent 1.19ms making 61 calls to Moose::Meta::TypeConstraint::equals, avg 20µs/call
2704912µs $current = $parent;
271 }
272
2731120µs return 0;
274}
275
276## compiling the type constraint
277
278
# spent 33.9ms (850µs+33.0) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 162 times, avg 209µs/call: # 89 times (530µs+20.1ms) by Moose::Meta::TypeConstraint::new at line 125, avg 232µs/call # 35 times (146µs+5.42ms) by Moose::Meta::TypeConstraint::Role::new at line 41 of Moose/Meta/TypeConstraint/Role.pm, avg 159µs/call # 31 times (128µs+4.98ms) by Moose::Meta::TypeConstraint::Class::new at line 40 of Moose/Meta/TypeConstraint/Class.pm, avg 165µs/call # 7 times (46µs+2.48ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 57 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 361µs/call
sub compile_type_constraint {
27916238µs my $self = shift;
280162666µs32433.0ms $self->_compiled_type_constraint($self->_actually_compile_type_constraint);
# spent 32.3ms making 160 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 202µs/call # spent 739µs making 162 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 5µs/call # spent 22µs making 2 calls to Moose::Meta::TypeConstraint::Union::_actually_compile_type_constraint, avg 11µs/call
281}
282
283## type compilers ...
284
285
# spent 32.3ms (1.37+30.9) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 160 times, avg 202µs/call: # 160 times (1.37ms+30.9ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 280, avg 202µs/call
sub _actually_compile_type_constraint {
28616020µs my $self = shift;
287
288160958µs64030.9ms if ( $self->can_be_inlined ) {
# spent 18.6ms making 160 calls to Eval::Closure::eval_closure, avg 116µs/call # spent 8.12ms making 153 calls to Moose::Meta::TypeConstraint::_inline_check, avg 53µs/call # spent 1.62ms making 153 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 11µs/call # spent 1.41ms making 153 calls to Moose::Meta::TypeConstraint::inline_environment, avg 9µs/call # spent 661µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::_inline_check, avg 94µs/call # spent 273µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 39µs/call # spent 259µs making 7 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 37µ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 3.27ms (68µs+3.21) within Moose::Meta::TypeConstraint::create_child_type which was called 16 times, avg 205µs/call: # 16 times (68µs+3.21ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 572 of Moose/Util/TypeConstraints.pm, avg 205µs/call
sub create_child_type {
3601616µs my ($self, %opts) = @_;
361165µs my $class = ref $self;
3621645µs163.21ms return $class->new(%opts, parent => $self);
# spent 3.21ms making 16 calls to Moose::Meta::TypeConstraint::new, avg 200µs/call
363}
364
365135µs1;
366
367# ABSTRACT: The Moose Type Constraint metaclass
368
369__END__