Filename | /Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint.pm |
Statements | Executed 4390 statements in 7.88ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
73 | 4 | 4 | 4.31ms | 13.9ms | compile_type_constraint | Moose::Meta::TypeConstraint::
444 | 8 | 5 | 2.41ms | 3.62ms | can_be_inlined (recurses: max depth 1, inclusive time 12µs) | Moose::Meta::TypeConstraint::
219 | 12 | 5 | 2.01ms | 5.10ms | _inline_check (recurses: max depth 2, inclusive time 2.30ms) | Moose::Meta::TypeConstraint::
49 | 10 | 7 | 983µs | 12.4ms | new | Moose::Meta::TypeConstraint::
157 | 7 | 6 | 885µs | 1.30ms | inline_environment (recurses: max depth 1, inclusive time 7µs) | Moose::Meta::TypeConstraint::
72 | 1 | 1 | 587µs | 9.34ms | _actually_compile_type_constraint | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 387µs | 967µs | BEGIN@12 | Moose::Meta::TypeConstraint::
27 | 2 | 1 | 312µs | 630µs | equals | Moose::Meta::TypeConstraint::
288 | 14 | 5 | 201µs | 201µs | __ANON__[:16] | Moose::Meta::TypeConstraint::
8 | 2 | 2 | 185µs | 891µs | is_subtype_of | Moose::Meta::TypeConstraint::
49 | 1 | 1 | 152µs | 152µs | __ANON__[:77] | Moose::Meta::TypeConstraint::
54 | 1 | 1 | 107µs | 126µs | __ANON__[:14] | Moose::Meta::TypeConstraint::
16 | 1 | 1 | 74µs | 3.55ms | create_child_type | Moose::Meta::TypeConstraint::
49 | 2 | 1 | 60µs | 60µs | __ANON__[:101] | Moose::Meta::TypeConstraint::
19 | 1 | 1 | 58µs | 74µs | _compile_hand_optimized_type_constraint | Moose::Meta::TypeConstraint::
4 | 1 | 1 | 38µs | 57µs | check | Moose::Meta::TypeConstraint::
4 | 1 | 1 | 36µs | 208µs | is_a_type_of | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 9µs | 48µs | BEGIN@14 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 8µs | 8µs | BEGIN@3 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 7µs | 23µs | BEGIN@23 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 6µs | 24µs | BEGIN@21 | Moose::Meta::TypeConstraint::
5 | 1 | 1 | 6µs | 6µs | __ANON__[:42] | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 6µs | 25µs | BEGIN@19 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 6µs | 16µs | BEGIN@10 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 6µs | 9µs | BEGIN@11 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 6µs | 28µs | BEGIN@24 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 6µs | 24µs | BEGIN@20 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 6µs | 27µs | BEGIN@22 | Moose::Meta::TypeConstraint::
1 | 1 | 1 | 5µs | 52µs | BEGIN@26 | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | __ANON__[:15] | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | __ANON__[:378] | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | __ANON__[:38] | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | __ANON__[:391] | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | __ANON__[:404] | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | __ANON__[:68] | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | __ANON__[:76] | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | _collect_all_parents | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | _compile_subtype | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | _compile_type | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | assert_coerce | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | assert_valid | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | coerce | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | get_message | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | parents | Moose::Meta::TypeConstraint::
0 | 0 | 0 | 0s | 0s | validate | Moose::Meta::TypeConstraint::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | package Moose::Meta::TypeConstraint; | ||||
3 | # spent 8µs within Moose::Meta::TypeConstraint::BEGIN@3 which was called:
# once (8µs+0s) by Moose::BEGIN@28 at line 5 | ||||
4 | 1 | 4µs | $Moose::Meta::TypeConstraint::AUTHORITY = 'cpan:STEVAN'; | ||
5 | 1 | 28µs | 1 | 8µs | } # spent 8µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@3 |
6 | { | ||||
7 | 2 | 900ns | $Moose::Meta::TypeConstraint::VERSION = '2.1005'; | ||
8 | } | ||||
9 | |||||
10 | 2 | 23µs | 2 | 26µs | # spent 16µs (6+10) within Moose::Meta::TypeConstraint::BEGIN@10 which was called:
# once (6µs+10µs) by Moose::BEGIN@28 at line 10 # spent 16µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@10
# spent 10µs making 1 call to strict::import |
11 | 2 | 19µs | 2 | 12µs | # spent 9µs (6+3) within Moose::Meta::TypeConstraint::BEGIN@11 which was called:
# once (6µs+3µs) by Moose::BEGIN@28 at line 11 # spent 9µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@11
# spent 3µs making 1 call to warnings::import |
12 | 2 | 139µs | 2 | 1.40ms | # spent 967µs (387+580) within Moose::Meta::TypeConstraint::BEGIN@12 which was called:
# once (387µs+580µs) by Moose::BEGIN@28 at line 12 # spent 967µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@12
# spent 436µs making 1 call to metaclass::import |
13 | |||||
14 | 54 | 164µs | 54 | 19µs | # spent 126µs (107+19) within Moose::Meta::TypeConstraint::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint.pm:14] which was called 54 times, avg 2µs/call:
# 54 times (107µs+19µs) by Moose::Meta::TypeConstraint::equals at line 255, avg 2µs/call
# spent 48µs (9+39) within Moose::Meta::TypeConstraint::BEGIN@14 which was called:
# once (9µs+39µs) by Moose::BEGIN@28 at line 17 # spent 19µs making 54 calls to Scalar::Util::refaddr, avg 348ns/call |
15 | '""' => sub { shift->name }, # stringify to tc name | ||||
16 | 288 | 474µs | # spent 201µs within Moose::Meta::TypeConstraint::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint.pm:16] which was called 288 times, avg 699ns/call:
# 49 times (38µs+0s) by Moose::Meta::TypeConstraint::Registry::add_type_constraint at line 51 of Moose/Meta/TypeConstraint/Registry.pm, avg 786ns/call
# 48 times (40µs+0s) by Moose::Util::TypeConstraints::find_or_parse_type_constraint at line 274 of Moose/Util/TypeConstraints.pm, avg 827ns/call
# 46 times (29µs+0s) by Moose::Util::TypeConstraints::find_or_create_isa_type_constraint at line 260 of Moose/Util/TypeConstraints.pm, avg 635ns/call
# 36 times (22µs+0s) by Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type at line 44 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 606ns/call
# 27 times (17µs+0s) by Moose::Meta::TypeConstraint::equals at line 253, avg 619ns/call
# 24 times (14µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 288, avg 600ns/call
# 17 times (14µs+0s) by Moose::Meta::Method::Accessor::Native::Collection::_tc_member_type at line 41 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 835ns/call
# 16 times (10µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint at line 565 of Moose/Util/TypeConstraints.pm, avg 600ns/call
# 8 times (6µs+0s) by Moose::Meta::TypeConstraint::is_subtype_of at line 284, avg 712ns/call
# 4 times (3µs+0s) by Moose::Meta::TypeConstraint::is_a_type_of at line 276, avg 725ns/call
# 4 times (3µs+0s) by Moose::Util::TypeConstraints::find_or_create_type_constraint at line 232 of Moose/Util/TypeConstraints.pm, avg 675ns/call
# 4 times (3µs+0s) by Class::MOP::Class:::around at line 149 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 675ns/call
# 3 times (2µs+0s) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 79 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 667ns/call
# 2 times (1µs+0s) by Moose::Util::TypeConstraints::_create_type_constraint_union at line 104 of Moose/Util/TypeConstraints.pm, avg 650ns/call | ||
17 | 2 | 25µs | 2 | 87µs | fallback => 1; # spent 48µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@14
# spent 39µs making 1 call to overload::import |
18 | |||||
19 | 2 | 25µs | 2 | 44µs | # spent 25µs (6+19) within Moose::Meta::TypeConstraint::BEGIN@19 which was called:
# once (6µs+19µs) by Moose::BEGIN@28 at line 19 # spent 25µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@19
# spent 19µs making 1 call to Exporter::import |
20 | 2 | 19µs | 2 | 41µs | # spent 24µs (6+18) within Moose::Meta::TypeConstraint::BEGIN@20 which was called:
# once (6µs+18µs) by Moose::BEGIN@28 at line 20 # spent 24µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@20
# spent 18µs making 1 call to Exporter::import |
21 | 2 | 21µs | 2 | 41µs | # spent 24µs (6+17) within Moose::Meta::TypeConstraint::BEGIN@21 which was called:
# once (6µs+17µs) by Moose::BEGIN@28 at line 21 # spent 24µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@21
# spent 17µs making 1 call to Exporter::import |
22 | 2 | 21µs | 2 | 49µs | # spent 27µs (6+22) within Moose::Meta::TypeConstraint::BEGIN@22 which was called:
# once (6µs+22µs) by Moose::BEGIN@28 at line 22 # spent 27µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@22
# spent 22µs making 1 call to Exporter::import |
23 | 2 | 19µs | 2 | 39µs | # spent 23µs (7+16) within Moose::Meta::TypeConstraint::BEGIN@23 which was called:
# once (7µs+16µs) by Moose::BEGIN@28 at line 23 # spent 23µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@23
# spent 16µs making 1 call to Exporter::import |
24 | 2 | 20µs | 2 | 50µs | # spent 28µs (6+22) within Moose::Meta::TypeConstraint::BEGIN@24 which was called:
# once (6µs+22µs) by Moose::BEGIN@28 at line 24 # spent 28µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@24
# spent 22µs making 1 call to Exporter::import |
25 | |||||
26 | 2 | 1.59ms | 2 | 99µs | # spent 52µs (5+47) within Moose::Meta::TypeConstraint::BEGIN@26 which was called:
# once (5µs+47µs) by Moose::BEGIN@28 at line 26 # spent 52µs making 1 call to Moose::Meta::TypeConstraint::BEGIN@26
# spent 47µs making 1 call to base::import |
27 | |||||
28 | 1 | 4µs | 3 | 302µs | __PACKAGE__->meta->add_attribute('name' => ( # spent 282µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 15µs making 1 call to Moose::Meta::TypeConstraint::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
29 | reader => 'name', | ||||
30 | Class::MOP::_definition_context(), | ||||
31 | )); | ||||
32 | 1 | 3µs | 3 | 417µs | __PACKAGE__->meta->add_attribute('parent' => ( # spent 404µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 8µs making 1 call to Moose::Meta::TypeConstraint::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
33 | reader => 'parent', | ||||
34 | predicate => 'has_parent', | ||||
35 | Class::MOP::_definition_context(), | ||||
36 | )); | ||||
37 | |||||
38 | 1 | 1µs | my $null_constraint = sub { 1 }; | ||
39 | __PACKAGE__->meta->add_attribute('constraint' => ( | ||||
40 | reader => 'constraint', | ||||
41 | writer => '_set_constraint', | ||||
42 | 5 | 13µs | # spent 6µs within Moose::Meta::TypeConstraint::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint.pm:42] which was called 5 times, avg 1µs/call:
# 5 times (6µs+0s) by Moose::Meta::TypeConstraint::Parameterized::_new or Moose::Meta::TypeConstraint::Union::_new or Moose::Meta::TypeConstraint::_new at line 24 of (eval 74)[Eval/Closure.pm:135], avg 1µs/call | ||
43 | 1 | 4µs | 3 | 421µs | Class::MOP::_definition_context(), # spent 408µ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 |
44 | )); | ||||
45 | |||||
46 | 1 | 3µs | 3 | 414µs | __PACKAGE__->meta->add_attribute('message' => ( # spent 401µ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 |
47 | accessor => 'message', | ||||
48 | predicate => 'has_message', | ||||
49 | Class::MOP::_definition_context(), | ||||
50 | )); | ||||
51 | |||||
52 | 1 | 3µs | 3 | 259µs | __PACKAGE__->meta->add_attribute('_default_message' => ( # spent 246µ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 |
53 | accessor => '_default_message', | ||||
54 | Class::MOP::_definition_context(), | ||||
55 | )); | ||||
56 | |||||
57 | # can't make this a default because it has to close over the type name, and | ||||
58 | # cmop attributes don't have lazy | ||||
59 | # spent 152µs within Moose::Meta::TypeConstraint::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint.pm:77] which was called 49 times, avg 3µs/call:
# 49 times (152µs+0s) by Moose::Meta::TypeConstraint::new at line 146, avg 3µs/call | ||||
60 | 49 | 16µs | my $name = shift; | ||
61 | sub { | ||||
62 | my $value = shift; | ||||
63 | # have to load it late like this, since it uses Moose itself | ||||
64 | my $can_partialdump = try { | ||||
65 | # versions prior to 0.14 had a potential infinite loop bug | ||||
66 | load_class('Devel::PartialDump', { -version => 0.14 }); | ||||
67 | 1; | ||||
68 | }; | ||||
69 | if ($can_partialdump) { | ||||
70 | $value = Devel::PartialDump->new->dump($value); | ||||
71 | } | ||||
72 | else { | ||||
73 | $value = (defined $value ? overload::StrVal($value) : 'undef'); | ||||
74 | } | ||||
75 | return "Validation failed for '" . $name . "' with value $value"; | ||||
76 | } | ||||
77 | 50 | 177µs | }; | ||
78 | 1 | 3µs | 3 | 400µs | __PACKAGE__->meta->add_attribute('coercion' => ( # spent 388µ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 |
79 | accessor => 'coercion', | ||||
80 | predicate => 'has_coercion', | ||||
81 | Class::MOP::_definition_context(), | ||||
82 | )); | ||||
83 | |||||
84 | 1 | 3µs | 3 | 395µs | __PACKAGE__->meta->add_attribute('hand_optimized_type_constraint' => ( # spent 383µ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 |
85 | init_arg => 'optimized', | ||||
86 | accessor => 'hand_optimized_type_constraint', | ||||
87 | predicate => 'has_hand_optimized_type_constraint', | ||||
88 | Class::MOP::_definition_context(), | ||||
89 | )); | ||||
90 | |||||
91 | 1 | 3µs | 3 | 402µs | __PACKAGE__->meta->add_attribute('inlined' => ( # spent 390µ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 |
92 | init_arg => 'inlined', | ||||
93 | accessor => 'inlined', | ||||
94 | predicate => '_has_inlined_type_constraint', | ||||
95 | Class::MOP::_definition_context(), | ||||
96 | )); | ||||
97 | |||||
98 | __PACKAGE__->meta->add_attribute('inline_environment' => ( | ||||
99 | init_arg => 'inline_environment', | ||||
100 | accessor => '_inline_environment', | ||||
101 | 49 | 104µs | # spent 60µs within Moose::Meta::TypeConstraint::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Meta/TypeConstraint.pm:101] which was called 49 times, avg 1µs/call:
# 40 times (49µ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 33 of (eval 74)[Eval/Closure.pm:135], avg 1µs/call
# 9 times (11µs+0s) by Moose::Meta::TypeConstraint::Class::_new or Moose::Meta::TypeConstraint::Parameterizable::_new at line 36 of (eval 74)[Eval/Closure.pm:135], avg 1µs/call | ||
102 | 1 | 4µs | 3 | 279µs | Class::MOP::_definition_context(), # spent 266µ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 |
103 | )); | ||||
104 | |||||
105 | sub parents { | ||||
106 | my $self = shift; | ||||
107 | $self->parent; | ||||
108 | } | ||||
109 | |||||
110 | # private accessors | ||||
111 | |||||
112 | 1 | 3µs | 3 | 415µs | __PACKAGE__->meta->add_attribute('compiled_type_constraint' => ( # spent 401µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 9µs making 1 call to Moose::Meta::TypeConstraint::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
113 | accessor => '_compiled_type_constraint', | ||||
114 | predicate => '_has_compiled_type_constraint', | ||||
115 | Class::MOP::_definition_context(), | ||||
116 | )); | ||||
117 | |||||
118 | 1 | 3µs | 3 | 283µs | __PACKAGE__->meta->add_attribute('package_defined_in' => ( # spent 260µs making 1 call to Class::MOP::Mixin::HasAttributes::add_attribute
# spent 18µs making 1 call to Moose::Meta::TypeConstraint::meta
# spent 5µs making 1 call to Class::MOP::_definition_context |
119 | accessor => '_package_defined_in', | ||||
120 | Class::MOP::_definition_context(), | ||||
121 | )); | ||||
122 | |||||
123 | # spent 12.4ms (983µs+11.4) within Moose::Meta::TypeConstraint::new which was called 49 times, avg 254µs/call:
# 19 times (366µs+3.83ms) by Moose::Meta::TypeConstraint::Role::new at line 44 of Moose/Meta/TypeConstraint/Role.pm, avg 221µs/call
# 16 times (284µs+3.19ms) by Moose::Meta::TypeConstraint::create_child_type at line 423, avg 217µs/call
# 5 times (114µs+1.10ms) by Moose::Meta::TypeConstraint::Class::new at line 43 of Moose/Meta/TypeConstraint/Class.pm, avg 242µs/call
# 3 times (75µs+2.28ms) by Moose::Meta::TypeConstraint::Parameterizable::parameterize at line 90 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 785µs/call
# once (29µs+243µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 204 of Moose/Util/TypeConstraints/Builtins.pm
# once (29µs+212µs) by Moose::Util::TypeConstraints::_create_type_constraint at line 575 of Moose/Util/TypeConstraints.pm
# once (19µs+165µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 274 of Moose/Util/TypeConstraints/Builtins.pm
# once (19µs+164µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 239 of Moose/Util/TypeConstraints/Builtins.pm
# once (19µs+159µs) by Moose::Util::TypeConstraints::Builtins::define_builtins at line 300 of Moose/Util/TypeConstraints/Builtins.pm
# once (29µs+106µs) by Moose::Meta::TypeConstraint::Union::new at line 33 of Moose/Meta/TypeConstraint/Union.pm | ||||
124 | 49 | 8µs | my $class = shift; | ||
125 | 49 | 36µs | my ($first, @rest) = @_; | ||
126 | 49 | 74µs | my %args = ref $first ? %$first : $first ? ($first, @rest) : (); | ||
127 | 49 | 26µs | $args{name} = $args{name} ? "$args{name}" : "__ANON__"; | ||
128 | |||||
129 | 49 | 6µs | if ( $args{optimized} ) { | ||
130 | Moose::Deprecated::deprecated( | ||||
131 | feature => 'optimized type constraint sub ref', | ||||
132 | message => | ||||
133 | 'Providing an optimized subroutine ref for type constraints is deprecated.' | ||||
134 | . ' Use the inlining feature (inline_as) instead.' | ||||
135 | ); | ||||
136 | } | ||||
137 | |||||
138 | 49 | 8µs | if ( exists $args{message} | ||
139 | && (!ref($args{message}) || ref($args{message}) ne 'CODE') ) { | ||||
140 | confess("The 'message' parameter must be a coderef"); | ||||
141 | } | ||||
142 | |||||
143 | 49 | 89µs | 49 | 1.18ms | my $self = $class->_new(%args); # spent 421µs making 19 calls to Moose::Meta::TypeConstraint::Role::_new, avg 22µs/call
# spent 288µs making 17 calls to Moose::Meta::TypeConstraint::_new, avg 17µs/call
# spent 152µs making 5 calls to Moose::Meta::TypeConstraint::Class::_new, avg 30µs/call
# spent 127µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::_new, avg 42µs/call
# spent 114µs making 4 calls to Moose::Meta::TypeConstraint::Parameterizable::_new, avg 28µs/call
# spent 78µs making 1 call to Moose::Meta::TypeConstraint::Union::_new |
144 | 49 | 128µs | 98 | 9.92ms | $self->compile_type_constraint() # spent 7.73ms making 46 calls to Moose::Meta::TypeConstraint::compile_type_constraint, avg 168µs/call
# spent 2.13ms making 3 calls to Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint, avg 709µs/call
# spent 65µs making 49 calls to Moose::Meta::TypeConstraint::_has_compiled_type_constraint, avg 1µs/call |
145 | unless $self->_has_compiled_type_constraint; | ||||
146 | 49 | 176µs | 196 | 345µs | $self->_default_message($_default_message_generator->($self->name)) # spent 152µs making 49 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:77], avg 3µs/call
# spent 79µs making 49 calls to Moose::Meta::TypeConstraint::_default_message, avg 2µs/call
# spent 58µs making 49 calls to Moose::Meta::TypeConstraint::name, avg 1µs/call
# spent 56µs making 49 calls to Moose::Meta::TypeConstraint::has_message, avg 1µs/call |
147 | unless $self->has_message; | ||||
148 | 49 | 138µs | return $self; | ||
149 | } | ||||
150 | |||||
- - | |||||
153 | sub coerce { | ||||
154 | my $self = shift; | ||||
155 | |||||
156 | my $coercion = $self->coercion; | ||||
157 | |||||
158 | unless ($coercion) { | ||||
159 | require Moose; | ||||
160 | Moose->throw_error("Cannot coerce without a type coercion"); | ||||
161 | } | ||||
162 | |||||
163 | return $_[0] if $self->check($_[0]); | ||||
164 | |||||
165 | return $coercion->coerce(@_); | ||||
166 | } | ||||
167 | |||||
168 | sub assert_coerce { | ||||
169 | my $self = shift; | ||||
170 | |||||
171 | my $result = $self->coerce(@_); | ||||
172 | |||||
173 | $self->assert_valid($result); | ||||
174 | |||||
175 | return $result; | ||||
176 | } | ||||
177 | |||||
178 | # spent 57µs (38+19) within Moose::Meta::TypeConstraint::check which was called 4 times, avg 14µs/call:
# 4 times (38µs+19µs) by Moose::Meta::Attribute::verify_against_type_constraint at line 1279 of Moose/Meta/Attribute.pm, avg 14µs/call | ||||
179 | 4 | 2µs | my ($self, @args) = @_; | ||
180 | 4 | 5µs | 4 | 6µs | my $constraint_subref = $self->_compiled_type_constraint; # spent 6µs making 4 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 2µs/call |
181 | 4 | 27µs | 4 | 12µs | return $constraint_subref->(@args) ? 1 : undef; # spent 12µs making 4 calls to Eval::Closure::Sandbox_50::__ANON__[(eval 123)[Eval/Closure.pm:135]:3], avg 3µs/call |
182 | } | ||||
183 | |||||
184 | sub validate { | ||||
185 | my ($self, $value) = @_; | ||||
186 | if ($self->_compiled_type_constraint->($value)) { | ||||
187 | return undef; | ||||
188 | } | ||||
189 | else { | ||||
190 | $self->get_message($value); | ||||
191 | } | ||||
192 | } | ||||
193 | |||||
194 | # spent 3.62ms (2.41+1.21) within Moose::Meta::TypeConstraint::can_be_inlined which was called 444 times, avg 8µs/call:
# 219 times (1.08ms+538µs) by Moose::Meta::TypeConstraint::_inline_check at line 207, avg 7µs/call
# 71 times (425µs+221µs) by Moose::Meta::Attribute::_inline_check_constraint at line 711 of Moose/Meta/Attribute.pm, avg 9µs/call
# 50 times (306µs+168µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 311, avg 9µs/call
# 47 times (277µs+140µs) by Moose::Meta::Attribute::_eval_environment at line 789 of Moose/Meta/Attribute.pm, avg 9µs/call
# 45 times (263µs+127µs) by Moose::Meta::TypeConstraint::Parameterized::can_be_inlined at line 78 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 9µs/call
# 8 times (44µs+23µs) by Moose::Meta::TypeConstraint::Union::can_be_inlined at line 87 of Moose/Meta/TypeConstraint/Union.pm, avg 8µs/call
# 2 times (12µs+6µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint at line 108 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 9µs/call
# 2 times (9µs+-9µs) by Moose::Meta::TypeConstraint::can_be_inlined at line 197, avg 0s/call | ||||
195 | 444 | 35µs | my $self = shift; | ||
196 | |||||
197 | 444 | 611µs | 887 | 791µs | if ( $self->has_parent && $self->constraint == $null_constraint ) { # spent 404µs making 439 calls to Moose::Meta::TypeConstraint::constraint, avg 919ns/call
# spent 385µs making 444 calls to Moose::Meta::TypeConstraint::has_parent, avg 867ns/call
# spent 2µ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 |
198 | return $self->parent->can_be_inlined; | ||||
199 | } | ||||
200 | |||||
201 | 442 | 842µs | 442 | 423µs | return $self->_has_inlined_type_constraint; # spent 423µs making 442 calls to Moose::Meta::TypeConstraint::_has_inlined_type_constraint, avg 956ns/call |
202 | } | ||||
203 | |||||
204 | # spent 5.10ms (2.01+3.09) within Moose::Meta::TypeConstraint::_inline_check which was called 219 times, avg 23µs/call:
# 71 times (639µs+1.96ms) by Moose::Meta::Attribute::_inline_check_constraint at line 711 of Moose/Meta/Attribute.pm, avg 37µs/call
# 50 times (509µs+1.04ms) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 311, avg 31µs/call
# 36 times (322µs+-322µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Util/TypeConstraints/Builtins.pm:66] at line 64 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call
# 16 times (139µs+440µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Util/TypeConstraints/Builtins.pm:237] at line 229 of Moose/Util/TypeConstraints/Builtins.pm, avg 36µs/call
# 13 times (111µs+-111µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Util/TypeConstraints/Builtins.pm:112] at line 103 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call
# 12 times (104µs+-104µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Util/TypeConstraints/Builtins.pm:120] at line 118 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call
# 10 times (88µs+-88µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Util/TypeConstraints/Builtins.pm:83] at line 78 of Moose/Util/TypeConstraints/Builtins.pm, avg 0s/call
# 6 times (52µs+206µs) by Moose::Meta::TypeConstraint::Union::_inline_check at line 97 of Moose/Meta/TypeConstraint/Union.pm, avg 43µs/call
# 2 times (18µs+35µs) by Moose::Meta::Method::Accessor::Native::Collection::_inline_check_member_constraint at line 108 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 26µs/call
# once (9µs+63µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Util/TypeConstraints/Builtins.pm:272] at line 264 of Moose/Util/TypeConstraints/Builtins.pm
# once (9µs+-9µs) by Moose::Util::TypeConstraints::Builtins::__ANON__[/Users/dde/perl5/perlbrew/perls/5.18.0t/lib/site_perl/5.18.0/darwin-thread-multi-2level/Moose/Util/TypeConstraints/Builtins.pm:176] at line 171 of Moose/Util/TypeConstraints/Builtins.pm
# once (9µs+-9µs) by Moose::Meta::TypeConstraint::_inline_check at line 212 | ||||
205 | 219 | 23µs | my $self = shift; | ||
206 | |||||
207 | 219 | 124µs | 219 | 1.61ms | unless ( $self->can_be_inlined ) { # spent 1.61ms making 219 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 7µs/call |
208 | require Moose; | ||||
209 | Moose->throw_error( 'Cannot inline a type constraint check for ' . $self->name ); | ||||
210 | } | ||||
211 | |||||
212 | 219 | 290µs | 438 | 372µs | if ( $self->has_parent && $self->constraint == $null_constraint ) { # spent 188µs making 219 calls to Moose::Meta::TypeConstraint::has_parent, avg 856ns/call
# spent 184µs making 217 calls to Moose::Meta::TypeConstraint::constraint, avg 846ns/call
# spent 1µs making 1 call to Moose::Meta::TypeConstraint::parent
# spent 17µs making 1 call to Moose::Meta::TypeConstraint::_inline_check, recursion: max depth 1, sum of overlapping time 17µs |
213 | return $self->parent->_inline_check(@_); | ||||
214 | } | ||||
215 | |||||
216 | 218 | 769µs | 436 | 3.39ms | return '( do { ' . $self->inlined->( $self, @_ ) . ' } )'; # spent 926µs making 36 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:66], avg 26µs/call
# spent 623µs making 13 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:112], avg 48µs/call
# spent 574µs making 12 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:120], avg 48µs/call
# spent 524µs making 10 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:83], avg 52µs/call
# spent 211µs making 218 calls to Moose::Meta::TypeConstraint::inlined, avg 969ns/call
# spent 191µs making 24 calls to Moose::Meta::TypeConstraint::Class::__ANON__[Moose/Meta/TypeConstraint/Class.pm:30], avg 8µs/call
# spent 175µs making 19 calls to Moose::Meta::TypeConstraint::Role::__ANON__[Moose/Meta/TypeConstraint/Role.pm:32], avg 9µs/call
# spent 42µs making 37 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:46], avg 1µs/call
# spent 38µs making 31 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:223], avg 1µs/call
# spent 29µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:176]
# spent 18µs making 13 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:125], avg 1µs/call
# spent 15µs making 5 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:58], avg 3µs/call
# spent 8µs making 4 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:195], avg 2µs/call
# spent 4µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:157], avg 2µs/call
# spent 3µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:152]
# spent 3µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:163], avg 1µs/call
# spent 2µs making 2 calls to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:28], avg 950ns/call
# spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:137]
# spent 2µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:258]
# spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:132]
# spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:39]
# spent 1µs making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:72]
# spent 900ns making 1 call to Moose::Util::TypeConstraints::Builtins::__ANON__[Moose/Util/TypeConstraints/Builtins.pm:291] |
217 | } | ||||
218 | |||||
219 | # spent 1.30ms (885µs+416µs) within Moose::Meta::TypeConstraint::inline_environment which was called 157 times, avg 8µs/call:
# 50 times (294µs+142µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 311, avg 9µs/call
# 47 times (273µs+127µs) by Moose::Meta::Attribute::_eval_environment at line 800 of Moose/Meta/Attribute.pm, avg 9µs/call
# 32 times (171µs+82µs) by Moose::Meta::TypeConstraint::Parameterized::inline_environment at line 91 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 8µs/call
# 19 times (99µs+48µs) by Moose::Meta::Class::_eval_environment at line 543 of Moose/Meta/Class.pm, avg 8µs/call
# 4 times (23µs+11µs) by Class::MOP::Class:::around at line 161 of Moose/Meta/Method/Accessor/Native/Collection.pm, avg 8µs/call
# 4 times (21µs+10µs) by Moose::Meta::TypeConstraint::Union::inline_environment at line 108 of Moose/Meta/TypeConstraint/Union.pm, avg 8µs/call
# once (5µs+-5µs) by Moose::Meta::TypeConstraint::inline_environment at line 222 | ||||
220 | 157 | 17µs | my $self = shift; | ||
221 | |||||
222 | 157 | 189µs | 314 | 258µs | if ( $self->has_parent && $self->constraint == $null_constraint ) { # spent 135µs making 155 calls to Moose::Meta::TypeConstraint::constraint, avg 868ns/call
# spent 122µs making 157 calls to Moose::Meta::TypeConstraint::has_parent, avg 778ns/call
# spent 1µs making 1 call to Moose::Meta::TypeConstraint::parent
# spent 7µs making 1 call to Moose::Meta::TypeConstraint::inline_environment, recursion: max depth 1, sum of overlapping time 7µs |
223 | return $self->parent->inline_environment; | ||||
224 | } | ||||
225 | |||||
226 | 156 | 318µs | 156 | 158µs | return $self->_inline_environment; # spent 158µs making 156 calls to Moose::Meta::TypeConstraint::_inline_environment, avg 1µs/call |
227 | } | ||||
228 | |||||
229 | sub assert_valid { | ||||
230 | my ($self, $value) = @_; | ||||
231 | |||||
232 | my $error = $self->validate($value); | ||||
233 | return 1 if ! defined $error; | ||||
234 | |||||
235 | require Moose; | ||||
236 | Moose->throw_error($error); | ||||
237 | } | ||||
238 | |||||
239 | sub get_message { | ||||
240 | my ($self, $value) = @_; | ||||
241 | my $msg = $self->has_message | ||||
242 | ? $self->message | ||||
243 | : $self->_default_message; | ||||
244 | local $_ = $value; | ||||
245 | return $msg->($value); | ||||
246 | } | ||||
247 | |||||
248 | ## type predicates ... | ||||
249 | |||||
250 | # spent 630µs (312+318) within Moose::Meta::TypeConstraint::equals which was called 27 times, avg 23µs/call:
# 24 times (283µs+283µs) by Moose::Meta::TypeConstraint::is_subtype_of at line 289, avg 24µs/call
# 3 times (29µs+35µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 278, avg 21µs/call | ||||
251 | 27 | 6µs | my ( $self, $type_or_name ) = @_; | ||
252 | |||||
253 | 27 | 41µs | 54 | 132µs | my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; # spent 116µs making 27 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 4µs/call
# spent 17µs making 27 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 619ns/call |
254 | |||||
255 | 27 | 59µs | 54 | 126µs | return 1 if $self == $other; # spent 126µs making 54 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:14], avg 2µs/call |
256 | |||||
257 | 20 | 18µs | 20 | 22µs | if ( $self->has_hand_optimized_type_constraint and $other->has_hand_optimized_type_constraint ) { # spent 22µs making 20 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 1µs/call |
258 | return 1 if $self->hand_optimized_type_constraint == $other->hand_optimized_type_constraint; | ||||
259 | } | ||||
260 | |||||
261 | 20 | 52µs | 40 | 37µs | return unless $self->constraint == $other->constraint; # spent 37µs making 40 calls to Moose::Meta::TypeConstraint::constraint, avg 935ns/call |
262 | |||||
263 | if ( $self->has_parent ) { | ||||
264 | return unless $other->has_parent; | ||||
265 | return unless $self->parent->equals( $other->parent ); | ||||
266 | } else { | ||||
267 | return if $other->has_parent; | ||||
268 | } | ||||
269 | |||||
270 | return; | ||||
271 | } | ||||
272 | |||||
273 | # spent 208µs (36+172) within Moose::Meta::TypeConstraint::is_a_type_of which was called 4 times, avg 52µs/call:
# 4 times (36µs+172µs) by Moose::Meta::Attribute::Native::Trait::_check_helper_type at line 114 of Moose/Meta/Attribute/Native/Trait.pm, avg 52µs/call | ||||
274 | 4 | 2µs | my ($self, $type_or_name) = @_; | ||
275 | |||||
276 | 4 | 7µs | 8 | 62µs | my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; # spent 59µs making 4 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 15µs/call
# spent 3µs making 4 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 725ns/call |
277 | |||||
278 | 4 | 14µs | 5 | 110µs | ($self->equals($type) || $self->is_subtype_of($type)); # spent 64µs making 3 calls to Moose::Meta::TypeConstraint::equals, avg 21µs/call
# spent 33µs making 1 call to Moose::Meta::TypeConstraint::is_subtype_of
# spent 14µs making 1 call to Moose::Meta::TypeConstraint::Parameterized::equals |
279 | } | ||||
280 | |||||
281 | # spent 891µs (185+706) within Moose::Meta::TypeConstraint::is_subtype_of which was called 8 times, avg 111µs/call:
# 7 times (175µs+682µs) by Moose::Meta::TypeConstraint::Parameterizable::generate_constraint_for at line 36 of Moose/Meta/TypeConstraint/Parameterizable.pm, avg 122µs/call
# once (10µs+23µs) by Moose::Meta::TypeConstraint::is_a_type_of at line 278 | ||||
282 | 8 | 2µs | my ($self, $type_or_name) = @_; | ||
283 | |||||
284 | 8 | 14µs | 16 | 98µs | my $type = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; # spent 92µs making 8 calls to Moose::Util::TypeConstraints::find_type_constraint, avg 11µs/call
# spent 6µs making 8 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 712ns/call |
285 | |||||
286 | 8 | 1µs | my $current = $self; | ||
287 | |||||
288 | 8 | 45µs | 52 | 42µs | while (my $parent = $current->parent) { # spent 27µs making 28 calls to Moose::Meta::TypeConstraint::parent, avg 971ns/call
# spent 14µs making 24 calls to Moose::Meta::TypeConstraint::__ANON__[Moose/Meta/TypeConstraint.pm:16], avg 600ns/call |
289 | 24 | 26µs | 24 | 566µs | return 1 if $parent->equals($type); # spent 566µs making 24 calls to Moose::Meta::TypeConstraint::equals, avg 24µs/call |
290 | 20 | 5µs | $current = $parent; | ||
291 | } | ||||
292 | |||||
293 | 4 | 8µs | return 0; | ||
294 | } | ||||
295 | |||||
296 | ## compiling the type constraint | ||||
297 | |||||
298 | # spent 13.9ms (4.31+9.64) within Moose::Meta::TypeConstraint::compile_type_constraint which was called 73 times, avg 191µs/call:
# 46 times (207µs+7.52ms) by Moose::Meta::TypeConstraint::new at line 144, avg 168µs/call
# 19 times (4.06ms+302µs) by Moose::Meta::TypeConstraint::Role::new at line 47 of Moose/Meta/TypeConstraint/Role.pm, avg 230µs/call
# 5 times (21µs+809µs) by Moose::Meta::TypeConstraint::Class::new at line 45 of Moose/Meta/TypeConstraint/Class.pm, avg 166µs/call
# 3 times (17µs+1.01ms) by Moose::Meta::TypeConstraint::Parameterized::compile_type_constraint at line 63 of Moose/Meta/TypeConstraint/Parameterized.pm, avg 342µs/call | ||||
299 | 73 | 8µs | my $self = shift; | ||
300 | 73 | 217µs | 146 | 9.64ms | $self->_compiled_type_constraint($self->_actually_compile_type_constraint); # spent 9.34ms making 72 calls to Moose::Meta::TypeConstraint::_actually_compile_type_constraint, avg 130µs/call
# spent 289µs making 73 calls to Moose::Meta::TypeConstraint::_compiled_type_constraint, avg 4µs/call
# spent 10µs making 1 call to Moose::Meta::TypeConstraint::Union::_actually_compile_type_constraint |
301 | } | ||||
302 | |||||
303 | ## type compilers ... | ||||
304 | |||||
305 | # spent 9.34ms (587µs+8.75) within Moose::Meta::TypeConstraint::_actually_compile_type_constraint which was called 72 times, avg 130µs/call:
# 72 times (587µs+8.75ms) by Moose::Meta::TypeConstraint::compile_type_constraint at line 300, avg 130µs/call | ||||
306 | 72 | 3µs | my $self = shift; | ||
307 | |||||
308 | 72 | 96µs | 91 | 148µs | return $self->_compile_hand_optimized_type_constraint # spent 74µs making 19 calls to Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint, avg 4µs/call
# spent 74µs making 72 calls to Moose::Meta::TypeConstraint::has_hand_optimized_type_constraint, avg 1µs/call |
309 | if $self->has_hand_optimized_type_constraint; | ||||
310 | |||||
311 | 53 | 260µs | 212 | 8.60ms | if ( $self->can_be_inlined ) { # spent 5.64ms making 53 calls to Eval::Closure::eval_closure, avg 107µs/call
# spent 1.54ms making 50 calls to Moose::Meta::TypeConstraint::_inline_check, avg 31µs/call
# spent 474µs making 50 calls to Moose::Meta::TypeConstraint::can_be_inlined, avg 9µs/call
# spent 436µs making 50 calls to Moose::Meta::TypeConstraint::inline_environment, avg 9µs/call
# spent 323µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::_inline_check, avg 108µs/call
# spent 98µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::inline_environment, avg 33µs/call
# spent 84µs making 3 calls to Moose::Meta::TypeConstraint::Parameterized::can_be_inlined, avg 28µs/call |
312 | return eval_closure( | ||||
313 | source => 'sub { ' . $self->_inline_check('$_[0]') . ' }', | ||||
314 | environment => $self->inline_environment, | ||||
315 | ); | ||||
316 | } | ||||
317 | |||||
318 | my $check = $self->constraint; | ||||
319 | unless ( defined $check ) { | ||||
320 | require Moose; | ||||
321 | Moose->throw_error( "Could not compile type constraint '" | ||||
322 | . $self->name | ||||
323 | . "' because no constraint check" ); | ||||
324 | } | ||||
325 | |||||
326 | return $self->_compile_subtype($check) | ||||
327 | if $self->has_parent; | ||||
328 | |||||
329 | return $self->_compile_type($check); | ||||
330 | } | ||||
331 | |||||
332 | # spent 74µs (58+16) within Moose::Meta::TypeConstraint::_compile_hand_optimized_type_constraint which was called 19 times, avg 4µs/call:
# 19 times (58µs+16µs) by Moose::Meta::TypeConstraint::_actually_compile_type_constraint at line 308, avg 4µs/call | ||||
333 | 19 | 2µs | my $self = shift; | ||
334 | |||||
335 | 19 | 12µs | 19 | 16µs | my $type_constraint = $self->hand_optimized_type_constraint; # spent 16µs making 19 calls to Moose::Meta::TypeConstraint::hand_optimized_type_constraint, avg 847ns/call |
336 | |||||
337 | 19 | 2µs | unless ( ref $type_constraint ) { | ||
338 | require Moose; | ||||
339 | Moose->throw_error("Hand optimized type constraint is not a code reference"); | ||||
340 | } | ||||
341 | |||||
342 | 19 | 30µs | return $type_constraint; | ||
343 | } | ||||
344 | |||||
345 | sub _compile_subtype { | ||||
346 | my ($self, $check) = @_; | ||||
347 | |||||
348 | # gather all the parent constraints in order | ||||
349 | my @parents; | ||||
350 | my $optimized_parent; | ||||
351 | foreach my $parent ($self->_collect_all_parents) { | ||||
352 | # if a parent is optimized, the optimized constraint already includes | ||||
353 | # all of its parents tcs, so we can break the loop | ||||
354 | if ($parent->has_hand_optimized_type_constraint) { | ||||
355 | push @parents => $optimized_parent = $parent->hand_optimized_type_constraint; | ||||
356 | last; | ||||
357 | } | ||||
358 | else { | ||||
359 | push @parents => $parent->constraint; | ||||
360 | } | ||||
361 | } | ||||
362 | |||||
363 | @parents = grep { $_ != $null_constraint } reverse @parents; | ||||
364 | |||||
365 | unless ( @parents ) { | ||||
366 | return $self->_compile_type($check); | ||||
367 | } elsif( $optimized_parent and @parents == 1 ) { | ||||
368 | # the case of just one optimized parent is optimized to prevent | ||||
369 | # looping and the unnecessary localization | ||||
370 | if ( $check == $null_constraint ) { | ||||
371 | return $optimized_parent; | ||||
372 | } else { | ||||
373 | return subname($self->name, sub { | ||||
374 | return undef unless $optimized_parent->($_[0]); | ||||
375 | my (@args) = @_; | ||||
376 | local $_ = $args[0]; | ||||
377 | $check->(@args); | ||||
378 | }); | ||||
379 | } | ||||
380 | } else { | ||||
381 | # general case, check all the constraints, from the first parent to ourselves | ||||
382 | my @checks = @parents; | ||||
383 | push @checks, $check if $check != $null_constraint; | ||||
384 | return subname($self->name => sub { | ||||
385 | my (@args) = @_; | ||||
386 | local $_ = $args[0]; | ||||
387 | foreach my $check (@checks) { | ||||
388 | return undef unless $check->(@args); | ||||
389 | } | ||||
390 | return 1; | ||||
391 | }); | ||||
392 | } | ||||
393 | } | ||||
394 | |||||
395 | sub _compile_type { | ||||
396 | my ($self, $check) = @_; | ||||
397 | |||||
398 | return $check if $check == $null_constraint; # Item, Any | ||||
399 | |||||
400 | return subname($self->name => sub { | ||||
401 | my (@args) = @_; | ||||
402 | local $_ = $args[0]; | ||||
403 | $check->(@args); | ||||
404 | }); | ||||
405 | } | ||||
406 | |||||
407 | ## other utils ... | ||||
408 | |||||
409 | sub _collect_all_parents { | ||||
410 | my $self = shift; | ||||
411 | my @parents; | ||||
412 | my $current = $self->parent; | ||||
413 | while (defined $current) { | ||||
414 | push @parents => $current; | ||||
415 | $current = $current->parent; | ||||
416 | } | ||||
417 | return @parents; | ||||
418 | } | ||||
419 | |||||
420 | # spent 3.55ms (74µs+3.47) within Moose::Meta::TypeConstraint::create_child_type which was called 16 times, avg 222µs/call:
# 16 times (74µs+3.47ms) by Moose::Util::TypeConstraints::_create_type_constraint at line 565 of Moose/Util/TypeConstraints.pm, avg 222µs/call | ||||
421 | 16 | 14µs | my ($self, %opts) = @_; | ||
422 | 16 | 5µs | my $class = ref $self; | ||
423 | 16 | 46µs | 16 | 3.47ms | return $class->new(%opts, parent => $self); # spent 3.47ms making 16 calls to Moose::Meta::TypeConstraint::new, avg 217µs/call |
424 | } | ||||
425 | |||||
426 | 1 | 13µs | 1; | ||
427 | |||||
428 | # ABSTRACT: The Moose Type Constraint metaclass | ||||
429 | |||||
430 | __END__ |