← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:33:55 2022
Reported on Wed Dec 14 15:40:03 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm
StatementsExecuted 56854 statements in 100ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
7032110.3ms36.0msType::Tiny::::is_strictly_subtype_of Type::Tiny::is_strictly_subtype_of (recurses: max depth 7, inclusive time 69.0ms)
63823910.2ms56.7msType::Tiny::::inline_check Type::Tiny::inline_check (recurses: max depth 4, inclusive time 43.4ms)
37561248.34ms9.93msType::Tiny::::isa Type::Tiny::isa
794327.20ms18.6msType::Tiny::::strictly_equals Type::Tiny::strictly_equals
10262197.11ms11.7msType::Tiny::::can_be_inlined Type::Tiny::can_be_inlined (recurses: max depth 2, inclusive time 723µs)
1116.93ms7.41msType::Tiny::::BEGIN@21 Type::Tiny::BEGIN@21
1691416.27ms14.4msType::Tiny::::_loose_to_TypeTiny Type::Tiny::_loose_to_TypeTiny
137326.16ms51.7msType::Tiny::::inline_assert Type::Tiny::inline_assert
54114.14ms13.8msType::Tiny::::_build_coercion Type::Tiny::_build_coercion (recurses: max depth 2, inclusive time 2.90ms)
1551713.21ms4.23msType::Tiny::::_is_null_constraint Type::Tiny::_is_null_constraint
1113.08ms3.48msType::Tiny::::__ANON__[:126] Type::Tiny::__ANON__[:126]
82763.05ms5.24msType::Tiny::::new Type::Tiny::new
69222.37ms76.5msType::Tiny::::parameterize Type::Tiny::parameterize
36481212.28ms2.28msType::Tiny::::has_parent Type::Tiny::has_parent
1911032.26ms45.5msType::Tiny::::is_strictly_a_type_of Type::Tiny::is_strictly_a_type_of
3721031.75ms2.73msType::Tiny::::__ANON__[:100] Type::Tiny::__ANON__[:100] (recurses: max depth 1, inclusive time 12µs)
203218101.65ms1.65msType::Tiny::::CORE:match Type::Tiny::CORE:match (opcode)
220211.50ms35.7msType::Tiny::::_overload_coderef Type::Tiny::_overload_coderef
69111.20ms4.58msType::Tiny::::____make_key Type::Tiny::____make_key
379221.08ms4.10msType::Tiny::::check Type::Tiny::check
38221.07ms31.7msType::Tiny::::exportables Type::Tiny::exportables
155111946µs1.02msType::Tiny::::constraint Type::Tiny::constraint
6232930µs21.8msType::Tiny::::_build_compiled_check Type::Tiny::_build_compiled_check
18373737µs19.1msType::Tiny::::__ANON__[:89] Type::Tiny::__ANON__[:89]
8321715µs865µsType::Tiny::::_stringify_no_magic Type::Tiny::_stringify_no_magic
1139123686µs686µsType::Tiny::::parent Type::Tiny::parent
80411530µs530µsType::Tiny::::has_inlined Type::Tiny::has_inlined
37211492µs687µsType::Tiny::::display_name Type::Tiny::display_name (recurses: max depth 1, inclusive time 2µs)
311485µs7.32msType::Tiny::::__ANON__[:659] Type::Tiny::__ANON__[:659]
6733431µs527µsType::Tiny::::can Type::Tiny::can
169104356µs23.0msType::Tiny::::compiled_check Type::Tiny::compiled_check (recurses: max depth 1, inclusive time 14µs)
52911351µs351µsType::Tiny::::inlined Type::Tiny::inlined
10622343µs488µsType::Tiny::::is_parameterizable Type::Tiny::is_parameterizable
12932332µs424µsType::Tiny::::is_anon Type::Tiny::is_anon
245146269µs269µsType::Tiny::::__ANON__[:101] Type::Tiny::__ANON__[:101]
1622266µs662µsType::Tiny::::__ANON__[:524] Type::Tiny::__ANON__[:524]
8576247µs2.56msType::Tiny::::has_coercion Type::Tiny::has_coercion (recurses: max depth 2, inclusive time 648µs)
29552236µs236µsType::Tiny::::name Type::Tiny::name
2732222µs2.26msType::Tiny::::create_child_type Type::Tiny::create_child_type
4633188µs212µsType::Tiny::::qualified_name Type::Tiny::qualified_name
5863174µs13.9msType::Tiny::::coercion Type::Tiny::coercion (recurses: max depth 2, inclusive time 2.92ms)
885169µs169µsType::Tiny::::_install_overloads Type::Tiny::_install_overloads
3011155µs167µsType::Tiny::::__ANON__[:276] Type::Tiny::__ANON__[:276]
111154µs154µsType::Tiny::::BEGIN@29 Type::Tiny::BEGIN@29
1221149µs236µsType::Tiny::::_lookup_my_method Type::Tiny::_lookup_my_method (recurses: max depth 1, inclusive time 45µs)
10611145µs145µsType::Tiny::::has_constraint_generator Type::Tiny::has_constraint_generator
13721136µs136µsType::Tiny::::CORE:sort Type::Tiny::CORE:sort (opcode)
4411128µs172µsType::Tiny::::_build_display_name Type::Tiny::_build_display_name
10122112µs112µsType::Tiny::::deprecated Type::Tiny::deprecated
331185µs282µsType::Tiny::::CORE:subst Type::Tiny::CORE:subst (opcode)
62183µs460µsType::Tiny::::AUTOLOAD Type::Tiny::AUTOLOAD
435583µs83µsType::Tiny::::__ANON__[:55] Type::Tiny::__ANON__[:55]
151172µs72µsType::Tiny::::_build_constraint Type::Tiny::_build_constraint
181172µs75µsType::Tiny::::my_methods Type::Tiny::my_methods
31168µs7.44msType::Tiny::::__ANON__[:602] Type::Tiny::__ANON__[:602]
176265µs68µsType::Tiny::::type_default Type::Tiny::type_default (recurses: max depth 1, inclusive time 3µs)
542154µs54µsType::Tiny::::has_coercion_generator Type::Tiny::has_coercion_generator
11152µs52µsType::Tiny::::BEGIN@3 Type::Tiny::BEGIN@3
341140µs40µsType::Tiny::::constraint_generator Type::Tiny::constraint_generator
31138µs1.21msType::Tiny::::__ANON__[:1073] Type::Tiny::__ANON__[:1073]
222235µs51µsType::Tiny::::name_generator Type::Tiny::name_generator
11132µs32µsType::Tiny::::BEGIN@7 Type::Tiny::BEGIN@7
271130µs30µsType::Tiny::::child_type_class Type::Tiny::child_type_class
201130µs30µsType::Tiny::::has_inline_generator Type::Tiny::has_inline_generator
21129µs41µsType::Tiny::::find_parent Type::Tiny::find_parent
11122µs36µsType::Tiny::::BEGIN@1435 Type::Tiny::BEGIN@1435
201122µs22µsType::Tiny::::inline_generator Type::Tiny::inline_generator
31120µs7.46msType::Tiny::::is_a_type_of Type::Tiny::is_a_type_of
62120µs40µsType::Tiny::::find_constraining_type Type::Tiny::find_constraining_type
55220µs955µsType::Tiny::::where Type::Tiny::where
51116µs16µsType::Tiny::::_build_name_generator Type::Tiny::_build_name_generator
11115µs20µsType::Tiny::::DESTROY Type::Tiny::DESTROY
31113µs4.69msType::Tiny::::of Type::Tiny::of
11112µs59µsType::Tiny::::BEGIN@5 Type::Tiny::BEGIN@5
31111µs15µsType::Tiny::::is_parameterized Type::Tiny::is_parameterized
21111µs15µsType::Tiny::::type_parameter Type::Tiny::type_parameter
11110µs372µsType::Tiny::::exportables_by_tag Type::Tiny::exportables_by_tag
1119µs50µsType::Tiny::::BEGIN@20 Type::Tiny::BEGIN@20
1118µs17µsType::Tiny::::BEGIN@4 Type::Tiny::BEGIN@4
1118µs16µsType::Tiny::::BEGIN@71 Type::Tiny::BEGIN@71
1116µs37µsType::Tiny::::BEGIN@72 Type::Tiny::BEGIN@72
5226µs6µsType::Tiny::::parameters Type::Tiny::parameters
1114µs4µsType::Tiny::::BEGIN@11 Type::Tiny::BEGIN@11
3114µs4µsType::Tiny::::coercion_generator Type::Tiny::coercion_generator
3114µs4µsType::Tiny::::has_parameters Type::Tiny::has_parameters
2113µs3µsType::Tiny::::_build_my_methods Type::Tiny::_build_my_methods
1113µs3µsType::Tiny::::_swap Type::Tiny::_swap
0000s0sType::Tiny::::DOES Type::Tiny::DOES
0000s0sType::Tiny::::TIEARRAY Type::Tiny::TIEARRAY
0000s0sType::Tiny::::TIEHASH Type::Tiny::TIEHASH
0000s0sType::Tiny::::TIESCALAR Type::Tiny::TIESCALAR
0000s0sType::Tiny::::__ANON__[:1110] Type::Tiny::__ANON__[:1110]
0000s0sType::Tiny::::__ANON__[:1114] Type::Tiny::__ANON__[:1114]
0000s0sType::Tiny::::__ANON__[:1147] Type::Tiny::__ANON__[:1147]
0000s0sType::Tiny::::__ANON__[:1219] Type::Tiny::__ANON__[:1219]
0000s0sType::Tiny::::__ANON__[:1395] Type::Tiny::__ANON__[:1395]
0000s0sType::Tiny::::__ANON__[:1410] Type::Tiny::__ANON__[:1410]
0000s0sType::Tiny::::__ANON__[:150] Type::Tiny::__ANON__[:150]
0000s0sType::Tiny::::__ANON__[:151] Type::Tiny::__ANON__[:151]
0000s0sType::Tiny::::__ANON__[:152] Type::Tiny::__ANON__[:152]
0000s0sType::Tiny::::__ANON__[:1530] Type::Tiny::__ANON__[:1530]
0000s0sType::Tiny::::__ANON__[:153] Type::Tiny::__ANON__[:153]
0000s0sType::Tiny::::__ANON__[:154] Type::Tiny::__ANON__[:154]
0000s0sType::Tiny::::__ANON__[:158] Type::Tiny::__ANON__[:158]
0000s0sType::Tiny::::__ANON__[:159] Type::Tiny::__ANON__[:159]
0000s0sType::Tiny::::__ANON__[:163] Type::Tiny::__ANON__[:163]
0000s0sType::Tiny::::__ANON__[:164] Type::Tiny::__ANON__[:164]
0000s0sType::Tiny::::__ANON__[:165] Type::Tiny::__ANON__[:165]
0000s0sType::Tiny::::__ANON__[:166] Type::Tiny::__ANON__[:166]
0000s0sType::Tiny::::__ANON__[:167] Type::Tiny::__ANON__[:167]
0000s0sType::Tiny::::__ANON__[:171] Type::Tiny::__ANON__[:171]
0000s0sType::Tiny::::__ANON__[:195] Type::Tiny::__ANON__[:195]
0000s0sType::Tiny::::__ANON__[:321] Type::Tiny::__ANON__[:321]
0000s0sType::Tiny::::__ANON__[:335] Type::Tiny::__ANON__[:335]
0000s0sType::Tiny::::__ANON__[:484] Type::Tiny::__ANON__[:484]
0000s0sType::Tiny::::__ANON__[:511] Type::Tiny::__ANON__[:511]
0000s0sType::Tiny::::__ANON__[:516] Type::Tiny::__ANON__[:516]
0000s0sType::Tiny::::__ANON__[:553] Type::Tiny::__ANON__[:553]
0000s0sType::Tiny::::__ANON__[:569] Type::Tiny::__ANON__[:569]
0000s0sType::Tiny::::__ANON__[:823] Type::Tiny::__ANON__[:823]
0000s0sType::Tiny::::__ANON__[:82] Type::Tiny::__ANON__[:82]
0000s0sType::Tiny::::__ANON__[:83] Type::Tiny::__ANON__[:83]
0000s0sType::Tiny::::__is_parameterized Type::Tiny::__is_parameterized
0000s0sType::Tiny::::_actually_compile_type_constraint Type::Tiny::_actually_compile_type_constraint
0000s0sType::Tiny::::_add_type_coercions Type::Tiny::_add_type_coercions
0000s0sType::Tiny::::_as_string Type::Tiny::_as_string
0000s0sType::Tiny::::_assert_coercion Type::Tiny::_assert_coercion
0000s0sType::Tiny::::_build_complementary_type Type::Tiny::_build_complementary_type
0000s0sType::Tiny::::_build_default_message Type::Tiny::_build_default_message
0000s0sType::Tiny::::_build_moose_type Type::Tiny::_build_moose_type
0000s0sType::Tiny::::_build_mouse_type Type::Tiny::_build_mouse_type
0000s0sType::Tiny::::_build_util Type::Tiny::_build_util
0000s0sType::Tiny::::_clone Type::Tiny::_clone
0000s0sType::Tiny::::_compiled_type_coercion Type::Tiny::_compiled_type_coercion
0000s0sType::Tiny::::_compiled_type_constraint Type::Tiny::_compiled_type_constraint
0000s0sType::Tiny::::_croak Type::Tiny::_croak
0000s0sType::Tiny::::_dd Type::Tiny::_dd
0000s0sType::Tiny::::_default_message Type::Tiny::_default_message
0000s0sType::Tiny::::_failed_check Type::Tiny::_failed_check
0000s0sType::Tiny::::_has_xsub Type::Tiny::_has_xsub
0000s0sType::Tiny::::_identity Type::Tiny::_identity
0000s0sType::Tiny::::_inline_check Type::Tiny::_inline_check
0000s0sType::Tiny::::_instantiate_moose_type Type::Tiny::_instantiate_moose_type
0000s0sType::Tiny::::_perlcode Type::Tiny::_perlcode
0000s0sType::Tiny::::_process_coercion_list Type::Tiny::_process_coercion_list
0000s0sType::Tiny::::_strict_check Type::Tiny::_strict_check
0000s0sType::Tiny::::_unite Type::Tiny::_unite
0000s0sType::Tiny::::assert_coerce Type::Tiny::assert_coerce
0000s0sType::Tiny::::assert_return Type::Tiny::assert_return
0000s0sType::Tiny::::assert_valid Type::Tiny::assert_valid
0000s0sType::Tiny::::coerce Type::Tiny::coerce
0000s0sType::Tiny::::coercibles Type::Tiny::coercibles
0000s0sType::Tiny::::compile_type_constraint Type::Tiny::compile_type_constraint
0000s0sType::Tiny::::complementary_type Type::Tiny::complementary_type
0000s0sType::Tiny::::deep_explanation Type::Tiny::deep_explanation
0000s0sType::Tiny::::equals Type::Tiny::equals
0000s0sType::Tiny::::get_message Type::Tiny::get_message
0000s0sType::Tiny::::hand_optimized_type_constraint Type::Tiny::hand_optimized_type_constraint
0000s0sType::Tiny::::has_deep_explanation Type::Tiny::has_deep_explanation
0000s0sType::Tiny::::has_hand_optimized_type_constraint Type::Tiny::has_hand_optimized_type_constraint
0000s0sType::Tiny::::has_library Type::Tiny::has_library
0000s0sType::Tiny::::has_message Type::Tiny::has_message
0000s0sType::Tiny::::has_parameterized_from Type::Tiny::has_parameterized_from
0000s0sType::Tiny::::has_sorter Type::Tiny::has_sorter
0000s0sType::Tiny::::inline_environment Type::Tiny::inline_environment
0000s0sType::Tiny::::is_strictly_supertype_of Type::Tiny::is_strictly_supertype_of
0000s0sType::Tiny::::is_subtype_of Type::Tiny::is_subtype_of
0000s0sType::Tiny::::is_supertype_of Type::Tiny::is_supertype_of
0000s0sType::Tiny::::library Type::Tiny::library
0000s0sType::Tiny::::message Type::Tiny::message
0000s0sType::Tiny::::meta Type::Tiny::meta
0000s0sType::Tiny::::minus_coercions Type::Tiny::minus_coercions
0000s0sType::Tiny::::moose_type Type::Tiny::moose_type
0000s0sType::Tiny::::mouse_type Type::Tiny::mouse_type
0000s0sType::Tiny::::no_coercions Type::Tiny::no_coercions
0000s0sType::Tiny::::parameterized_from Type::Tiny::parameterized_from
0000s0sType::Tiny::::parents Type::Tiny::parents
0000s0sType::Tiny::::plus_coercions Type::Tiny::plus_coercions
0000s0sType::Tiny::::plus_fallback_coercions Type::Tiny::plus_fallback_coercions
0000s0sType::Tiny::::sorter Type::Tiny::sorter
0000s0sType::Tiny::::validate Type::Tiny::validate
0000s0sType::Tiny::::validate_explain Type::Tiny::validate_explain
0000s0sTypes::Standard::::to_AnyTypes::Standard::to_Any
0000s0sTypes::Standard::::to_ArrayRefTypes::Standard::to_ArrayRef
0000s0sTypes::Standard::::to_ClassNameTypes::Standard::to_ClassName
0000s0sTypes::Standard::::to_CodeRefTypes::Standard::to_CodeRef
0000s0sTypes::Standard::::to_ConsumerOfTypes::Standard::to_ConsumerOf
0000s0sTypes::Standard::::to_CycleTupleTypes::Standard::to_CycleTuple
0000s0sTypes::Standard::::to_DefinedTypes::Standard::to_Defined
0000s0sTypes::Standard::::to_DictTypes::Standard::to_Dict
0000s0sTypes::Standard::::to_EnumTypes::Standard::to_Enum
0000s0sTypes::Standard::::to_FileHandleTypes::Standard::to_FileHandle
0000s0sTypes::Standard::::to_GlobRefTypes::Standard::to_GlobRef
0000s0sTypes::Standard::::to_HasMethodsTypes::Standard::to_HasMethods
0000s0sTypes::Standard::::to_HashRefTypes::Standard::to_HashRef
0000s0sTypes::Standard::::to_InstanceOfTypes::Standard::to_InstanceOf
0000s0sTypes::Standard::::to_IntTypes::Standard::to_Int
0000s0sTypes::Standard::::to_ItemTypes::Standard::to_Item
0000s0sTypes::Standard::::to_LaxNumTypes::Standard::to_LaxNum
0000s0sTypes::Standard::::to_MapTypes::Standard::to_Map
0000s0sTypes::Standard::::to_MaybeTypes::Standard::to_Maybe
0000s0sTypes::Standard::::to_NumTypes::Standard::to_Num
0000s0sTypes::Standard::::to_ObjectTypes::Standard::to_Object
0000s0sTypes::Standard::::to_OptListTypes::Standard::to_OptList
0000s0sTypes::Standard::::to_OptionalTypes::Standard::to_Optional
0000s0sTypes::Standard::::to_OverloadTypes::Standard::to_Overload
0000s0sTypes::Standard::::to_RefTypes::Standard::to_Ref
0000s0sTypes::Standard::::to_RegexpRefTypes::Standard::to_RegexpRef
0000s0sTypes::Standard::::to_RoleNameTypes::Standard::to_RoleName
0000s0sTypes::Standard::::to_ScalarRefTypes::Standard::to_ScalarRef
0000s0sTypes::Standard::::to_SlurpyTypes::Standard::to_Slurpy
0000s0sTypes::Standard::::to_StrTypes::Standard::to_Str
0000s0sTypes::Standard::::to_StrMatchTypes::Standard::to_StrMatch
0000s0sTypes::Standard::::to_StrictNumTypes::Standard::to_StrictNum
0000s0sTypes::Standard::::to_TiedTypes::Standard::to_Tied
0000s0sTypes::Standard::::to_TupleTypes::Standard::to_Tuple
0000s0sTypes::Standard::::to_UndefTypes::Standard::to_Undef
0000s0sTypes::Standard::::to_ValueTypes::Standard::to_Value
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Type::Tiny;
2
3272µs152µs
# spent 52µs within Type::Tiny::BEGIN@3 which was called: # once (52µs+0s) by Type::Library::BEGIN@16 at line 3
use 5.008001;
# spent 52µs making 1 call to Type::Tiny::BEGIN@3
4240µs226µs
# spent 17µs (8+9) within Type::Tiny::BEGIN@4 which was called: # once (8µs+9µs) by Type::Library::BEGIN@16 at line 4
use strict;
# spent 17µs making 1 call to Type::Tiny::BEGIN@4 # spent 9µs making 1 call to strict::import
5283µs2106µs
# spent 59µs (12+47) within Type::Tiny::BEGIN@5 which was called: # once (12µs+47µs) by Type::Library::BEGIN@16 at line 5
use warnings;
# spent 59µs making 1 call to Type::Tiny::BEGIN@5 # spent 47µs making 1 call to warnings::import
6
7
# spent 32µs within Type::Tiny::BEGIN@7 which was called: # once (32µs+0s) by Type::Library::BEGIN@16 at line 9
BEGIN {
816µs if ( $] < 5.010 ) { require Devel::TypeTiny::Perl58Compat }
9149µs132µs}
# spent 32µs making 1 call to Type::Tiny::BEGIN@7
10
11
# spent 4µs within Type::Tiny::BEGIN@11 which was called: # once (4µs+0s) by Type::Library::BEGIN@16 at line 15
BEGIN {
1211µs $Type::Tiny::AUTHORITY = 'cpan:TOBYINK';
1310s $Type::Tiny::VERSION = '2.000001';
1417µs $Type::Tiny::XS_VERSION = '0.016';
15147µs14µs}
# spent 4µs making 1 call to Type::Tiny::BEGIN@11
16
1713µs$Type::Tiny::VERSION =~ tr/_//d;
1811µs$Type::Tiny::XS_VERSION =~ tr/_//d;
19
20229µs291µs
# spent 50µs (9+41) within Type::Tiny::BEGIN@20 which was called: # once (9µs+41µs) by Type::Library::BEGIN@16 at line 20
use Scalar::Util qw( blessed );
# spent 50µs making 1 call to Type::Tiny::BEGIN@20 # spent 41µs making 1 call to Exporter::import
212913µs17.41ms
# spent 7.41ms (6.93+477µs) within Type::Tiny::BEGIN@21 which was called: # once (6.93ms+477µs) by Type::Library::BEGIN@16 at line 21
use Types::TypeTiny ();
# spent 7.41ms making 1 call to Type::Tiny::BEGIN@21
22
2311µsour $SafePackage = sprintf 'package %s;', __PACKAGE__;
24
25sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
26
2714µs
# spent 3µs within Type::Tiny::_swap which was called: # once (3µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:126] at line 104
sub _swap { $_[2] ? @_[ 1, 0 ] : @_[ 0, 1 ] }
28
29
# spent 154µs within Type::Tiny::BEGIN@29 which was called: # once (154µs+0s) by Type::Library::BEGIN@16 at line 66
BEGIN {
3011µs my $support_smartmatch = 0+ !!( $] >= 5.010001 );
31127µs eval qq{ sub SUPPORT_SMARTMATCH () { !! $support_smartmatch } };
32
3311µs my $fixed_precedence = 0+ !!( $] >= 5.014 );
34119µs eval qq{ sub _FIXED_PRECEDENCE () { !! $fixed_precedence } };
35
36 my $try_xs =
37 exists( $ENV{PERL_TYPE_TINY_XS} ) ? !!$ENV{PERL_TYPE_TINY_XS}
38 : exists( $ENV{PERL_ONLY} ) ? !$ENV{PERL_ONLY}
3912µs : 1;
40
4110s my $use_xs = 0;
4211µs $try_xs and eval {
43191µs require Type::Tiny::XS;
44 'Type::Tiny::XS'->VERSION( $Type::Tiny::XS_VERSION );
45 $use_xs++;
46 };
47
48 *_USE_XS =
49 $use_xs
50 ? sub () { !!1 }
5112µs : sub () { !!0 };
52
53 *_USE_MOUSE =
54 $try_xs
5543108µs
# spent 83µs within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:55] which was called 43 times, avg 2µs/call: # 20 times (37µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:127] at line 74 of Types/Standard.pm, avg 2µs/call # 10 times (16µs+0s) by Type::Tiny::Class::new at line 46 of Type/Tiny/Class.pm, avg 2µs/call # 8 times (22µs+0s) by Types::Standard::HashRef::__constraint_generator at line 34 of Types/Standard/HashRef.pm, avg 3µs/call # 4 times (7µs+0s) by Types::Standard::ArrayRef::__constraint_generator at line 38 of Types/Standard/ArrayRef.pm, avg 2µs/call # once (1µs+0s) by Type::Tiny::Duck::new at line 47 of Type/Tiny/Duck.pm
? sub () { $INC{'Mouse/Util.pm'} and Mouse::Util::MOUSE_XS() }
5612µs : sub () { !!0 };
57
5810s my $strict_mode = 0;
5912µs $ENV{$_} && ++$strict_mode for qw(
60 EXTENDED_TESTING
61 AUTHOR_TESTING
62 RELEASE_TESTING
63 PERL_STRICT
64 );
6517µs *_STRICT_MODE = $strict_mode ? sub () { !!1 } : sub () { !!0 };
66137µs1154µs} #/ BEGIN
# spent 154µs making 1 call to Type::Tiny::BEGIN@29
67
68{
69
70
# spent 169µs within Type::Tiny::_install_overloads which was called 8 times, avg 21µs/call: # once (44µs+0s) by Type::Library::BEGIN@16 at line 168 # once (28µs+0s) by Type::Tiny::_build_coercion at line 29 of Type/Coercion.pm # once (25µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 161 of Types/Standard.pm # once (23µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:126] at line 23 of Type/Tiny/Union.pm # once (21µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1059] at line 22 of Type/Tiny/Enum.pm # once (10µs+0s) by Type::Tiny::_build_coercion at line 34 of Type/Coercion.pm # once (10µs+0s) by Type::Library::BEGIN@16 at line 172 # once (8µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 191 of Types/Standard.pm
sub _install_overloads {
71247µs224µs
# spent 16µs (8+8) within Type::Tiny::BEGIN@71 which was called: # once (8µs+8µs) by Type::Library::BEGIN@16 at line 71
no strict 'refs';
# spent 16µs making 1 call to Type::Tiny::BEGIN@71 # spent 8µs making 1 call to strict::unimport
7227.73ms268µs
# spent 37µs (6+31) within Type::Tiny::BEGIN@72 which was called: # once (6µs+31µs) by Type::Library::BEGIN@16 at line 72
no warnings 'redefine', 'once';
# spent 37µs making 1 call to Type::Tiny::BEGIN@72 # spent 31µs making 1 call to warnings::unimport
73
74 # Coverage is checked on Perl 5.26
7587µs if ( $] < 5.010 ) { # uncoverable statement
76 require overload; # uncoverable statement
77 push @_, fallback => 1; # uncoverable statement
78 goto \&overload::OVERLOAD; # uncoverable statement
79 }
80
8185µs my $class = shift;
82840µs *{ $class . '::((' } = sub { };
83821µs *{ $class . '::()' } = sub { };
842419µs *{ $class . '::()' } = do { my $x = 1; \$x };
85844µs while ( @_ ) {
86258µs my $f = shift;
872548µs *{ $class . '::(' . $f } = ref $_[0] ? shift : do {
8820s my $m = shift;
89183606µs18318.3ms
# spent 19.1ms (737µs+18.3) within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:89] which was called 183 times, avg 104µs/call: # 72 times (273µs+1.69ms) by JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:135] or Sub::Defer::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Defer.pm:178] at line 120 of JSON/Schema/Modern/Document.pm, avg 27µs/call # 48 times (151µs+2.09ms) by JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:646] or Sub::Defer::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Defer.pm:178] at line 620 of JSON/Schema/Modern.pm, avg 47µs/call # 47 times (272µs+14.0ms) by Method::Generate::Accessor::_validate_codulatable at line 686 of Method/Generate/Accessor.pm, avg 304µs/call # 10 times (22µs+9µs) by JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:124] or Sub::Defer::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Defer.pm:178] at line 124 of JSON/Schema/Modern.pm, avg 3µs/call # 2 times (4µs+257µs) by JSON::Schema::Modern::add_vocabulary or Sub::Defer::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Defer.pm:178] at line 681 of JSON/Schema/Modern.pm, avg 130µs/call # 2 times (7µs+240µs) by JSON::Schema::Modern::add_vocabulary or Sub::Defer::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Defer.pm:178] at line 676 of JSON/Schema/Modern.pm, avg 124µs/call # 2 times (8µs+2µs) by JSON::Schema::Modern::add_vocabulary or Sub::Defer::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Defer.pm:178] at line 682 of JSON/Schema/Modern.pm, avg 5µs/call
sub { shift->$m( @_ ) }
# spent 18.3ms making 183 calls to Type::Tiny::_overload_coderef, avg 100µs/call
9021µs };
91 }
92 } #/ sub _install_overloads
93}
94
9511µs__PACKAGE__->_install_overloads(
96
# spent 2.73ms (1.75+983µs) within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:100] which was called 372 times, avg 7µs/call: # 73 times (455µs+164µs) by Type::Tiny::inline_assert at line 935, avg 8µs/call # 64 times (353µs+304µs) by Type::Tiny::inline_assert at line 947, avg 10µs/call # 48 times (306µs+294µs) by Type::Tiny::_build_compiled_check at line 537, avg 12µs/call # 39 times (142µs+54µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] at line 823 of Types/Standard.pm, avg 5µs/call # 37 times (134µs+43µs) by Type::Tiny::_overload_coderef at line 215, avg 5µs/call # 37 times (98µs+41µs) by Type::Tiny::_build_coercion at line 502, avg 4µs/call # 33 times (136µs+61µs) by Type::Tiny::CORE:subst at line 522, avg 6µs/call # 33 times (93µs+21µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:524] at line 523, avg 3µs/call # 6 times (24µs+10µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:786] at line 785 of Types/Standard.pm, avg 6µs/call # 2 times (9µs+-9µs) by Type::Tiny::Union::_build_display_name at line 97 of Type/Tiny/Union.pm, avg 0s/call
q("") => sub {
973721.93ms744993µs caller =~ m{^(Moo::HandleMoose|Sub::Quote)}
# spent 689µs making 372 calls to Type::Tiny::display_name, avg 2µs/call, recursion: max depth 1, sum of overlapping time 2µs # spent 306µs making 372 calls to Type::Tiny::CORE:match, avg 823ns/call
98 ? $_[0]->_stringify_no_magic
99 : $_[0]->display_name;
100 },
101245611µs
# spent 269µs within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:101] which was called 245 times, avg 1µs/call: # 79 times (53µs+0s) by Type::Tiny::Class::parent at line 149 of Type/Tiny/Class.pm, avg 671ns/call # 58 times (45µs+0s) by Type::Coercion::_preserve_type_constraint at line 111 of Type/Coercion.pm, avg 776ns/call # 46 times (64µs+0s) by Method::Generate::Accessor::_generate_populate_set at line 567 of Method/Generate/Accessor.pm, avg 1µs/call # 17 times (32µs+0s) by Method::Generate::Accessor::_generate_use_default at line 367 of Method/Generate/Accessor.pm, avg 2µs/call # 10 times (34µs+0s) by Method::Generate::Accessor::_generate_set at line 410 of Method/Generate/Accessor.pm, avg 3µs/call # 10 times (21µs+0s) by Method::Generate::Accessor::is_simple_set at line 297 of Method/Generate/Accessor.pm, avg 2µs/call # 6 times (1µs+0s) by Type::Coercion::type_constraint at line 89 of Type/Coercion.pm, avg 167ns/call # 4 times (5µs+0s) by Types::Standard::Slurpy::my_unslurpy at line 751 of Types/Standard.pm, avg 1µs/call # 3 times (5µs+0s) by Types::Standard::Dict::__inline_generator at line 103 of Types/Standard/Dict.pm, avg 2µs/call # 3 times (2µs+0s) by Types::Standard::Dict::__inline_generator at line 96 of Types/Standard/Dict.pm, avg 667ns/call # 3 times (2µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] at line 823 of Types/Standard.pm, avg 667ns/call # 3 times (1µs+0s) by Types::Standard::Dict::__inline_generator at line 100 of Types/Standard/Dict.pm, avg 333ns/call # 2 times (4µs+0s) by Type::Tiny::find_parent at line 743, avg 2µs/call # once (0s+0s) by Type::Tiny::type_default at line 573
q(bool) => sub { 1 },
102 q(&{}) => "_overload_coderef",
103
# spent 3.48ms (3.08+396µs) within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:126] which was called: # once (3.08ms+396µs) by JSON::Schema::Modern::BEGIN@33 at line 42 of JSON/Schema/Modern/Error.pm
q(|) => sub {
10412µs13µs my @tc = _swap @_;
# spent 3µs making 1 call to Type::Tiny::_swap
105 if ( !_FIXED_PRECEDENCE && $_[2] ) {
106 if ( blessed $tc[0] ) {
107 if ( blessed $tc[0] eq "Type::Tiny::_HalfOp" ) {
108 my $type = $tc[0]->{type};
109 my $param = $tc[0]->{param};
110 my $op = $tc[0]->{op};
111 require Type::Tiny::Union;
112 return "Type::Tiny::_HalfOp"->new(
113 $op,
114 $param,
115 "Type::Tiny::Union"->new_by_overload( type_constraints => [ $type, $tc[1] ] ),
116 );
117 } #/ if ( blessed $tc[0] eq...)
118 } #/ if ( blessed $tc[0] )
119 elsif ( ref $tc[0] eq 'ARRAY' ) {
120 require Type::Tiny::_HalfOp;
121 return "Type::Tiny::_HalfOp"->new( '|', @tc );
122 }
123 } #/ if ( !_FIXED_PRECEDENCE...)
1241867µs require Type::Tiny::Union;
12517µs1210µs return "Type::Tiny::Union"->new_by_overload( type_constraints => \@tc );
# spent 210µs making 1 call to Type::Tiny::Union::new_by_overload
126 },
127 q(&) => sub {
128 my @tc = _swap @_;
129 if ( !_FIXED_PRECEDENCE && $_[2] ) {
130 if ( blessed $tc[0] ) {
131 if ( blessed $tc[0] eq "Type::Tiny::_HalfOp" ) {
132 my $type = $tc[0]->{type};
133 my $param = $tc[0]->{param};
134 my $op = $tc[0]->{op};
135 require Type::Tiny::Intersection;
136 return "Type::Tiny::_HalfOp"->new(
137 $op,
138 $param,
139 "Type::Tiny::Intersection"->new_by_overload( type_constraints => [ $type, $tc[1] ] ),
140 );
141 } #/ if ( blessed $tc[0] eq...)
142 } #/ if ( blessed $tc[0] )
143 elsif ( ref $tc[0] eq 'ARRAY' ) {
144 require Type::Tiny::_HalfOp;
145 return "Type::Tiny::_HalfOp"->new( '&', @tc );
146 }
147 } #/ if ( !_FIXED_PRECEDENCE...)
148 require Type::Tiny::Intersection;
149 "Type::Tiny::Intersection"->new_by_overload( type_constraints => \@tc );
150 },
151 q(~) => sub { shift->complementary_type },
152 q(==) => sub { $_[0]->equals( $_[1] ) },
153 q(!=) => sub { not $_[0]->equals( $_[1] ) },
154 q(<) => sub { my $m = $_[0]->can( 'is_subtype_of' ); $m->( _swap @_ ) },
155 q(>) => sub {
156 my $m = $_[0]->can( 'is_subtype_of' );
157 $m->( reverse _swap @_ );
158 },
159 q(<=) => sub { my $m = $_[0]->can( 'is_a_type_of' ); $m->( _swap @_ ) },
160 q(>=) => sub {
161 my $m = $_[0]->can( 'is_a_type_of' );
162 $m->( reverse _swap @_ );
163 },
164 q(eq) => sub { "$_[0]" eq "$_[1]" },
165 q(cmp) => sub { $_[2] ? ( "$_[1]" cmp "$_[0]" ) : ( "$_[0]" cmp "$_[1]" ) },
166 q(0+) => sub { $_[0]{uniq} },
167 q(/) => sub { ( _STRICT_MODE xor $_[2] ) ? $_[0] : $_[1] },
168127µs144µs);
# spent 44µs making 1 call to Type::Tiny::_install_overloads
169
170__PACKAGE__->_install_overloads(
171 q(~~) => sub { $_[0]->check( $_[1] ) },
17212µs110µs) if Type::Tiny::SUPPORT_SMARTMATCH;
# spent 10µs making 1 call to Type::Tiny::_install_overloads
173
174# Would be easy to just return sub { $self->assert_return(@_) }
175# but try to build a more efficient coderef whenever possible.
176#
177
# spent 35.7ms (1.50+34.2) within Type::Tiny::_overload_coderef which was called 220 times, avg 162µs/call: # 183 times (757µs+17.6ms) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:89] at line 89, avg 100µs/call # 37 times (745µs+16.7ms) by Type::Tiny::exportables at line 1209, avg 471µs/call
sub _overload_coderef {
17822042µs my $self = shift;
179
180 # Bypass generating a coderef if we've already got the best possible one.
181 #
182220431µs return $self->{_overload_coderef} if $self->{_overload_coderef_no_rebuild};
183
184 # Subclasses of Type::Tiny might override assert_return to do some kind
185 # of interesting thing. In that case, we can't rely on it having identical
186 # behaviour to Type::Tiny::inline_assert.
187 #
188 $self->{_overrides_assert_return} =
189 ( $self->can( 'assert_return' ) != \&assert_return )
19064212µs61462µs unless exists $self->{_overrides_assert_return};
# spent 462µs making 61 calls to Type::Tiny::can, avg 8µs/call
191
19264108µs if ( $self->{_overrides_assert_return} ) {
193 $self->{_overload_coderef} ||= do {
194 Scalar::Util::weaken( my $weak = $self );
195 sub { $weak->assert_return( @_ ) };
196 };
197 ++$self->{_overload_coderef_no_rebuild};
198 }
199 elsif ( exists( &Sub::Quote::quote_sub ) ) {
200
201 # Use `=` instead of `||=` because we want to overwrite non-Sub::Quote
202 # coderef if possible.
20327186µs8117.4ms $self->{_overload_coderef} = $self->can_be_inlined
# spent 15.7ms making 27 calls to Type::Tiny::inline_assert, avg 580µs/call # spent 1.35ms making 27 calls to Sub::Quote::quote_sub, avg 50µs/call # spent 350µs making 23 calls to Type::Tiny::can_be_inlined, avg 15µs/call # spent 43µs making 1 call to Type::Tiny::Union::can_be_inlined # spent 1µs making 3 calls to Type::Tiny::Enum::can_be_inlined, avg 333ns/call
204 ? Sub::Quote::quote_sub(
205 $self->inline_assert( '$_[0]' ),
206 )
207 : Sub::Quote::quote_sub(
208 $self->inline_assert( '$_[0]', '$type' ),
209 { '$type' => \$self },
210 );
2112719µs ++$self->{_overload_coderef_no_rebuild};
212 } #/ elsif ( exists( &Sub::Quote::quote_sub...))
213 else {
2143719µs require Eval::TypeTiny;
21537266µs14816.4ms $self->{_overload_coderef} ||= $self->can_be_inlined
# spent 8.18ms making 37 calls to Type::Tiny::inline_assert, avg 221µs/call # spent 7.23ms making 37 calls to Eval::TypeTiny::eval_closure, avg 195µs/call # spent 767µs making 37 calls to Type::Tiny::can_be_inlined, avg 21µs/call # spent 177µs making 37 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 5µs/call
216 ? Eval::TypeTiny::eval_closure(
217 source => sprintf(
218 'sub { %s }', $self->inline_assert( '$_[0]', undef, no_wrapper => 1 )
219 ),
220 description => sprintf( "compiled assertion 'assert_%s'", $self ),
221 )
222 : Eval::TypeTiny::eval_closure(
223 source => sprintf(
224 'sub { %s }', $self->inline_assert( '$_[0]', '$type', no_wrapper => 1 )
225 ),
226 description => sprintf( "compiled assertion 'assert_%s'", $self ),
227 environment => { '$type' => \$self },
228 );
229 } #/ else [ if ( $self->{_overrides_assert_return...})]
230
23164183µs $self->{_overload_coderef};
232} #/ sub _overload_coderef
233
234our %ALL_TYPES;
235
23610smy $QFS;
23711µsmy $uniq = 1;
238
239
# spent 5.24ms (3.05+2.19) within Type::Tiny::new which was called 82 times, avg 64µs/call: # 37 times (1.45ms+894µs) by Type::Library::add_type at line 222 of Type/Library.pm, avg 63µs/call # 27 times (977µs+1.03ms) by Type::Tiny::create_child_type at line 1096, avg 74µs/call # 11 times (373µs+170µs) by Type::Tiny::ConstrainedObject::new at line 36 of Type/Tiny/ConstrainedObject.pm, avg 49µs/call # 4 times (141µs+51µs) by Type::Tiny::Enum::new at line 84 of Type/Tiny/Enum.pm, avg 48µs/call # once (58µs+15µs) by Type::Tiny::Union::new at line 85 of Type/Tiny/Union.pm # once (36µs+19µs) by Types::TypeTiny::TypeTiny at line 421 of Types/TypeTiny.pm # once (15µs+11µs) by Types::TypeTiny::StringLike at line 195 of Types/TypeTiny.pm
sub new {
2408228µs my $class = shift;
24182173µs my %params = ( @_ == 1 ) ? %{ $_[0] } : @_;
242
2438258µs for ( qw/ name display_name library / ) {
244246181µs $params{$_} = $params{$_} . '' if defined $params{$_};
245 }
246
2478262µs if ( exists $params{parent} ) {
248 $params{parent} =
249 ref( $params{parent} ) =~ /^Type::Tiny\b/
250 ? $params{parent}
25163254µs6390µs : Types::TypeTiny::to_TypeTiny( $params{parent} );
# spent 90µs making 63 calls to Type::Tiny::CORE:match, avg 1µs/call
252
253 _croak "Parent must be an instance of %s", __PACKAGE__
254 unless blessed( $params{parent} )
25563243µs126326µs && $params{parent}->isa( __PACKAGE__ );
# spent 272µs making 63 calls to Type::Tiny::isa, avg 4µs/call # spent 54µs making 63 calls to Scalar::Util::blessed, avg 857ns/call
256
2576391µs6375µs if ( $params{parent}->deprecated and not exists $params{deprecated} ) {
# spent 75µs making 63 calls to Type::Tiny::deprecated, avg 1µs/call
258 $params{deprecated} = 1;
259 }
260 } #/ if ( exists $params{parent...})
261
2628244µs if ( exists $params{constraint}
263 and defined $params{constraint}
264 and not ref $params{constraint} )
265 {
26654µs require Eval::TypeTiny;
26751µs my $code = $params{constraint};
268512µs5491µs $params{constraint} = Eval::TypeTiny::eval_closure(
# spent 491µs making 5 calls to Eval::TypeTiny::eval_closure, avg 98µs/call
269 source => sprintf( 'sub ($) { %s }', $code ),
270 description => "anonymous check",
271 );
272
# spent 167µs (155+12) within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:276] which was called 30 times, avg 6µs/call: # 30 times (155µs+12µs) by Type::Tiny::inline_check at line 895, avg 6µs/call
$params{inlined} ||= sub {
2733010µs my ( $type ) = @_;
2743038µs my $inlined = $_ eq '$_' ? "do { $code }" : "do { local \$_ = $_; $code }";
2753074µs3012µs $type->has_parent ? ( undef, $inlined ) : $inlined;
# spent 12µs making 30 calls to Type::Tiny::has_parent, avg 400ns/call
276 }
277518µs567µs if ( !exists $params{parent} or $params{parent}->can_be_inlined );
# spent 67µs making 5 calls to Type::Tiny::can_be_inlined, avg 13µs/call
278 } #/ if ( exists $params{constraint...})
279
280 # canonicalize to a boolean
2818298µs $params{deprecated} = !!$params{deprecated};
282
2838272µs $params{name} = "__ANON__" unless exists $params{name};
28482110µs $params{uniq} = $uniq++;
285
2868245µs if ( $params{name} ne "__ANON__" ) {
287
288 # First try a fast ASCII-only expression, but fall back to Unicode
289 $params{name} =~ /^_{0,2}[A-Z][A-Za-z0-9_]+$/sm
290 or eval q( use 5.008; $params{name} =~ /^_{0,2}\p{Lu}[\p{L}0-9_]+$/sm )
29139199µs39124µs or _croak '"%s" is not a valid type name', $params{name};
# spent 124µs making 39 calls to Type::Tiny::CORE:match, avg 3µs/call
292 }
293
2948220µs if ( exists $params{coercion} and !ref $params{coercion} and $params{coercion} )
295 {
296 $params{parent}->has_coercion
297 or _croak
298 "coercion => 1 requires type to have a direct parent with a coercion";
299
300 $params{coercion} = $params{parent}->coercion->type_coercion_map;
301 }
302
3038243µs if ( !exists $params{inlined}
304 and exists $params{constraint}
305 and ( !exists $params{parent} or $params{parent}->can_be_inlined )
306 and $QFS ||= "Sub::Quote"->can( "quoted_from_sub" ) )
307 {
308 my ( undef, $perlstring, $captures ) = @{ $QFS->( $params{constraint} ) || [] };
309
310 $params{inlined} = sub {
311 my ( $self, $var ) = @_;
312 my $code = Sub::Quote::inlinify(
313 $perlstring,
314 $var,
315 $var eq q($_) ? '' : "local \$_ = $var;",
316 1,
317 );
318 $code = sprintf( '%s and %s', $self->parent->inline_check( $var ), $code )
319 if $self->has_parent;
320 return $code;
321 }
322 if $perlstring && !$captures;
323 } #/ if ( !exists $params{inlined...})
324
3258262µs my $self = bless \%params, $class;
326
3278260µs unless ( $params{tmp} ) {
32882224µs my $uniq = $self->{uniq};
329
3308294µs $ALL_TYPES{$uniq} = $self;
33182228µs8267µs Scalar::Util::weaken( $ALL_TYPES{$uniq} );
# spent 67µs making 82 calls to Scalar::Util::weaken, avg 817ns/call
332
3338219µs my $tmp = $self;
33482162µs8258µs Scalar::Util::weaken( $tmp );
# spent 58µs making 82 calls to Scalar::Util::weaken, avg 707ns/call
33582336µs82860µs $Moo::HandleMoose::TYPE_MAP{ $self->_stringify_no_magic } = sub { $tmp };
# spent 860µs making 82 calls to Type::Tiny::_stringify_no_magic, avg 10µs/call
336 } #/ unless ( $params{tmp} )
337
3388289µs if ( ref( $params{coercion} ) eq q(CODE) ) {
339 require Types::Standard;
340 my $code = delete( $params{coercion} );
341 $self->{coercion} = $self->_build_coercion;
342 $self->coercion->add_type_coercions( Types::Standard::Any(), $code );
343 }
344 elsif ( ref( $params{coercion} ) eq q(ARRAY) ) {
345 my $arr = delete( $params{coercion} );
346 $self->{coercion} = $self->_build_coercion;
347 $self->coercion->add_type_coercions( @$arr );
348 }
349
350 # Documenting this here because it's too weird to be in the pod.
351 # There's a secret attribute called "_build_coercion" which takes a
352 # coderef. If present, then when $type->coercion is lazy built,
353 # the blank Type::Coercion object gets passed to the coderef,
354 # allowing the coderef to manipulate it a little. This is used by
355 # Types::TypeTiny to allow it to build a coercion for the TypeTiny
356 # type constraint without needing to load Type::Coercion yet.
357
3588217µs if ( $params{my_methods} ) {
35942µs require Eval::TypeTiny;
360 Scalar::Util::reftype( $params{my_methods}{$_} ) eq 'CODE'
361 and Eval::TypeTiny::set_subname(
362 sprintf( "%s::my_%s", $self->qualified_name, $_ ),
363 $params{my_methods}{$_},
364433µs1330µs ) for keys %{ $params{my_methods} };
# spent 20µs making 2 calls to Eval::TypeTiny::set_subname, avg 10µs/call # spent 7µs making 2 calls to Type::Tiny::qualified_name, avg 4µs/call # spent 3µs making 9 calls to Scalar::Util::reftype, avg 333ns/call
365 } #/ if ( $params{my_methods...})
366
36782176µs return $self;
368} #/ sub new
369
370
# spent 20µs (15+5) within Type::Tiny::DESTROY which was called: # once (15µs+5µs) by JSON::Schema::Modern::add_vocabulary at line 682 of JSON/Schema/Modern.pm
sub DESTROY {
37110s my $self = shift;
372111µs delete( $ALL_TYPES{ $self->{uniq} } );
37311µs15µs delete( $Moo::HandleMoose::TYPE_MAP{ $self->_stringify_no_magic } );
# spent 5µs making 1 call to Type::Tiny::_stringify_no_magic
374150µs return;
375}
376
377sub _clone {
378 my $self = shift;
379 my %opts;
380 $opts{$_} = $self->{$_} for qw< name display_name message >;
381 $self->create_child_type( %opts );
382}
383
384
# spent 865µs (715+150) within Type::Tiny::_stringify_no_magic which was called 83 times, avg 10µs/call: # 82 times (711µs+149µs) by Type::Tiny::new at line 335, avg 10µs/call # once (4µs+1µs) by Type::Tiny::DESTROY at line 373
sub _stringify_no_magic {
38583937µs249150µs sprintf(
# spent 61µs making 83 calls to Scalar::Util::blessed, avg 735ns/call # spent 55µs making 83 calls to Scalar::Util::reftype, avg 663ns/call # spent 34µs making 83 calls to Scalar::Util::refaddr, avg 410ns/call
386 '%s=%s(0x%08x)', blessed( $_[0] ), Scalar::Util::reftype( $_[0] ),
387 Scalar::Util::refaddr( $_[0] )
388 );
389}
390
391our $DD;
392
393sub _dd {
394 @_ = $_ unless @_;
395 my ( $value ) = @_;
396
397 goto $DD if ref( $DD ) eq q(CODE);
398
399 require B;
400
401 !defined $value ? 'Undef'
402 : !ref $value ? sprintf( 'Value %s', B::perlstring( $value ) )
403 : do {
404 my $N = 0+ ( defined( $DD ) ? $DD : 72 );
405 require Data::Dumper;
406 local $Data::Dumper::Indent = 0;
407 local $Data::Dumper::Useqq = 1;
408 local $Data::Dumper::Terse = 1;
409 local $Data::Dumper::Sortkeys = 1;
410 local $Data::Dumper::Maxdepth = 2;
411 my $str;
412 eval {
413 $str = Data::Dumper::Dumper( $value );
414 $str = substr( $str, 0, $N - 12 ) . '...' . substr( $str, -1, 1 )
415 if length( $str ) >= $N;
416 1;
417 } or do { $str = 'which cannot be dumped' };
418 "Reference $str";
419 } #/ do
420} #/ sub _dd
421
422
# spent 14.4ms (6.27+8.14) within Type::Tiny::_loose_to_TypeTiny which was called 1691 times, avg 9µs/call: # 794 times (2.95ms+3.85ms) by Type::Tiny::strictly_equals at line 686, avg 9µs/call # 703 times (2.52ms+3.23ms) by Type::Tiny::is_strictly_subtype_of at line 693, avg 8µs/call # 191 times (783µs+1.03ms) by Type::Tiny::is_strictly_a_type_of at line 711, avg 10µs/call # 3 times (12µs+19µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:602] at line 589, avg 10µs/call
sub _loose_to_TypeTiny {
4231691358µs my $caller = caller( 1 ); # assumption
424 map +(
425 ref( $_ )
426 ? Types::TypeTiny::to_TypeTiny( $_ )
42716914.56ms33828.14ms : do { require Type::Utils; Type::Utils::dwim_type( $_, for => $caller ) }
# spent 8.14ms making 3382 calls to Types::TypeTiny::to_TypeTiny, avg 2µs/call
428 ), @_;
429}
430
431295551µs
# spent 236µs within Type::Tiny::name which was called 295 times, avg 800ns/call: # 129 times (92µs+0s) by Type::Tiny::is_anon at line 727, avg 713ns/call # 46 times (24µs+0s) by Type::Tiny::qualified_name at line 722, avg 522ns/call # 44 times (44µs+0s) by Type::Tiny::_build_display_name at line 487, avg 1µs/call # 38 times (52µs+0s) by Type::Library::_exporter_expand_sub at line 72 of Type/Library.pm, avg 1µs/call # 38 times (24µs+0s) by Type::Tiny::exportables at line 1187, avg 632ns/call
sub name { $_[0]{name} }
432372785µs45197µs
# spent 687µs (492+195) within Type::Tiny::display_name which was called 372 times, avg 2µs/call: # 372 times (492µs+195µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:100] at line 97, avg 2µs/call
sub display_name { $_[0]{display_name} ||= $_[0]->_build_display_name }
# spent 172µs making 44 calls to Type::Tiny::_build_display_name, avg 4µs/call # spent 25µs making 1 call to Type::Tiny::Union::_build_display_name
43311391.70ms
# spent 686µs within Type::Tiny::parent which was called 1139 times, avg 602ns/call: # 981 times (582µs+0s) by Type::Tiny::is_strictly_subtype_of at line 698, avg 593ns/call # 60 times (43µs+0s) by Type::Tiny::can_be_inlined at line 877, avg 717ns/call # 32 times (23µs+0s) by Type::Tiny::inline_check at line 899, avg 719ns/call # 20 times (11µs+0s) by Type::Tiny::inline_check at line 889, avg 550ns/call # 14 times (13µs+0s) by Type::Tiny::_build_compiled_check at line 532, avg 929ns/call # 12 times (6µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 629, avg 500ns/call # 6 times (2µs+0s) by Types::Standard::Dict::__inline_generator at line 103 of Types/Standard/Dict.pm, avg 333ns/call # 6 times (2µs+0s) by Type::Tiny::_lookup_my_method at line 1369, avg 333ns/call # 3 times (1µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 645, avg 333ns/call # 2 times (3µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:750] at line 750 of Types/Standard.pm, avg 2µs/call # 2 times (0s+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] at line 940 of Types/Standard.pm, avg 0s/call # once (0s+0s) by Type::Tiny::type_default at line 573
sub parent { $_[0]{parent} }
43415512.33ms1572µs
# spent 1.02ms (946µs+72µs) within Type::Tiny::constraint which was called 1551 times, avg 656ns/call: # 1551 times (946µs+72µs) by Type::Tiny::_is_null_constraint at line 495, avg 656ns/call
sub constraint { $_[0]{constraint} ||= $_[0]->_build_constraint }
# spent 72µs making 15 calls to Type::Tiny::_build_constraint, avg 5µs/call
435
436
# spent 23.0ms (356µs+22.6) within Type::Tiny::compiled_check which was called 169 times, avg 136µs/call: # 58 times (86µs+7.34ms) by Type::Coercion::_preserve_type_constraint at line 111 of Type/Coercion.pm, avg 128µs/call # 37 times (156µs+5.69ms) by Type::Tiny::exportables at line 1203, avg 158µs/call # 24 times (19µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 632, avg 792ns/call # 14 times (14µs+-14µs) by Type::Tiny::_build_compiled_check at line 532, avg 0s/call # 8 times (50µs+9.14ms) by Types::Standard::HashRef::__constraint_generator at line 32 of Types/Standard/HashRef.pm, avg 1.15ms/call # 8 times (6µs+0s) by Types::Standard::HashRef::__inline_generator at line 58 of Types/Standard/HashRef.pm, avg 750ns/call # 6 times (5µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 609, avg 833ns/call # 6 times (3µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 617, avg 500ns/call # 4 times (14µs+491µs) by Types::Standard::ArrayRef::__constraint_generator at line 36 of Types/Standard/ArrayRef.pm, avg 126µs/call # 4 times (3µs+0s) by Types::Standard::ArrayRef::__inline_generator at line 93 of Types/Standard/ArrayRef.pm, avg 750ns/call
sub compiled_check {
437169460µs6022.7ms $_[0]{compiled_type_constraint} ||= $_[0]->_build_compiled_check;
# spent 20.4ms making 56 calls to Type::Tiny::_build_compiled_check, avg 364µs/call # spent 2.30ms making 4 calls to Type::Tiny::Enum::_build_compiled_check, avg 576µs/call
438}
43958177µs5813.8ms
# spent 13.9ms (174µs+13.8) within Type::Tiny::coercion which was called 58 times, avg 240µs/call: # 37 times (81µs+855µs) by Type::Library::make_immutable at line 318 of Type/Library.pm, avg 25µs/call # 14 times (70µs+8.96ms) by Type::Tiny::parameterize at line 1082, avg 645µs/call # 3 times (13µs+-13µs) by Type::Tiny::has_coercion at line 471, avg 0s/call # 2 times (2µs+2µs) by Type::Tiny::exportables at line 1220, avg 2µs/call # once (7µs+3.96ms) by JSON::Schema::Modern::BEGIN@31 at line 234 of Types/Standard.pm # once (1µs+0s) by Type::Library::make_immutable at line 319 of Type/Library.pm
sub coercion { $_[0]{coercion} ||= $_[0]->_build_coercion }
# spent 16.7ms making 54 calls to Type::Tiny::_build_coercion, avg 309µs/call, recursion: max depth 2, sum of overlapping time 2.90ms # spent 2µs making 4 calls to Type::Coercion::__ANON__[Type/Coercion.pm:28], avg 500ns/call
440sub message { $_[0]{message} }
441sub library { $_[0]{library} }
442529839µs
# spent 351µs within Type::Tiny::inlined which was called 529 times, avg 664ns/call: # 529 times (351µs+0s) by Type::Tiny::inline_check at line 895, avg 664ns/call
sub inlined { $_[0]{inlined} }
443101236µs
# spent 112µs within Type::Tiny::deprecated which was called 101 times, avg 1µs/call: # 63 times (75µs+0s) by Type::Tiny::new at line 257, avg 1µs/call # 38 times (37µs+0s) by Type::Library::_exporter_install_sub at line 133 of Type/Library.pm, avg 974ns/call
sub deprecated { $_[0]{deprecated} }
4443472µs
# spent 40µs within Type::Tiny::constraint_generator which was called 34 times, avg 1µs/call: # 34 times (40µs+0s) by Type::Tiny::parameterize at line 1044, avg 1µs/call
sub constraint_generator { $_[0]{constraint_generator} }
4452037µs
# spent 22µs within Type::Tiny::inline_generator which was called 20 times, avg 1µs/call: # 20 times (22µs+0s) by Type::Tiny::parameterize at line 1057, avg 1µs/call
sub inline_generator { $_[0]{inline_generator} }
4462264µs516µs
# spent 51µs (35+16) within Type::Tiny::name_generator which was called 22 times, avg 2µs/call: # 20 times (32µs+15µs) by Type::Tiny::parameterize at line 1050, avg 2µs/call # 2 times (3µs+1000ns) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] at line 735 of Types/Standard.pm, avg 2µs/call
sub name_generator { $_[0]{name_generator} ||= $_[0]->_build_name_generator }
# spent 16µs making 5 calls to Type::Tiny::_build_name_generator, avg 3µs/call
44737µs
# spent 4µs within Type::Tiny::coercion_generator which was called 3 times, avg 1µs/call: # 3 times (4µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:1073] at line 1070, avg 1µs/call
sub coercion_generator { $_[0]{coercion_generator} }
448512µs
# spent 6µs within Type::Tiny::parameters which was called 5 times, avg 1µs/call: # 3 times (2µs+0s) by Types::Standard::Dict::__inline_generator at line 103 of Types/Standard/Dict.pm, avg 667ns/call # 2 times (4µs+0s) by Type::Tiny::type_parameter at line 1581, avg 2µs/call
sub parameters { $_[0]{parameters} }
449sub moose_type { $_[0]{moose_type} ||= $_[0]->_build_moose_type }
450sub mouse_type { $_[0]{mouse_type} ||= $_[0]->_build_mouse_type }
451sub deep_explanation { $_[0]{deep_explanation} }
4521884µs23µs
# spent 75µs (72+3) within Type::Tiny::my_methods which was called 18 times, avg 4µs/call: # 18 times (72µs+3µs) by Type::Tiny::_lookup_my_method at line 1365, avg 4µs/call
sub my_methods { $_[0]{my_methods} ||= $_[0]->_build_my_methods }
# spent 3µs making 2 calls to Type::Tiny::_build_my_methods, avg 2µs/call
453sub sorter { $_[0]{sorter} }
454
45536485.32ms
# spent 2.28ms within Type::Tiny::has_parent which was called 3648 times, avg 626ns/call: # 919 times (716µs+0s) by Type::Tiny::can_be_inlined at line 877, avg 779ns/call # 859 times (475µs+0s) by Type::Tiny::can_be_inlined at line 879, avg 553ns/call # 639 times (440µs+0s) by Type::Tiny::is_strictly_subtype_of at line 697, avg 689ns/call # 575 times (288µs+0s) by Type::Tiny::inline_check at line 889, avg 501ns/call # 555 times (291µs+0s) by Type::Tiny::inline_check at line 891, avg 524ns/call # 32 times (15µs+0s) by Type::Tiny::inline_check at line 897, avg 469ns/call # 30 times (12µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:276] at line 275, avg 400ns/call # 15 times (19µs+0s) by Type::Tiny::_build_compiled_check at line 532, avg 1µs/call # 12 times (11µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 635, avg 917ns/call # 6 times (10µs+0s) by Type::Tiny::_lookup_my_method at line 1369, avg 2µs/call # 3 times (3µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 628, avg 1µs/call # 3 times (3µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 644, avg 1µs/call
sub has_parent { exists $_[0]{parent} }
456sub has_library { exists $_[0]{library} }
4578041.18ms
# spent 530µs within Type::Tiny::has_inlined which was called 804 times, avg 659ns/call: # 804 times (530µs+0s) by Type::Tiny::can_be_inlined at line 881, avg 659ns/call
sub has_inlined { exists $_[0]{inlined} }
458106293µs
# spent 145µs within Type::Tiny::has_constraint_generator which was called 106 times, avg 1µs/call: # 106 times (145µs+0s) by Type::Tiny::is_parameterizable at line 998, avg 1µs/call
sub has_constraint_generator { exists $_[0]{constraint_generator} }
4592053µs
# spent 30µs within Type::Tiny::has_inline_generator which was called 20 times, avg 2µs/call: # 20 times (30µs+0s) by Type::Tiny::parameterize at line 1057, avg 2µs/call
sub has_inline_generator { exists $_[0]{inline_generator} }
46054117µs
# spent 54µs within Type::Tiny::has_coercion_generator which was called 54 times, avg 1µs/call: # 34 times (35µs+0s) by Type::Tiny::parameterize at line 1082, avg 1µs/call # 20 times (19µs+0s) by Type::Tiny::parameterize at line 1066, avg 950ns/call
sub has_coercion_generator { exists $_[0]{coercion_generator} }
46138µs
# spent 4µs within Type::Tiny::has_parameters which was called 3 times, avg 1µs/call: # 3 times (4µs+0s) by Type::Tiny::is_parameterized at line 1002, avg 1µs/call
sub has_parameters { exists $_[0]{parameters} }
462sub has_message { defined $_[0]{message} }
463sub has_deep_explanation { exists $_[0]{deep_explanation} }
464sub has_sorter { exists $_[0]{sorter} }
465
466sub _default_message {
467 $_[0]{_default_message} ||= $_[0]->_build_default_message;
468}
469
470
# spent 2.56ms (247µs+2.32) within Type::Tiny::has_coercion which was called 85 times, avg 30µs/call: # 38 times (70µs+1µs) by Type::Tiny::exportables at line 1220, avg 2µs/call # 37 times (119µs+26µs) by Type::Library::make_immutable at line 319 of Type/Library.pm, avg 4µs/call # 2 times (16µs+2.32ms) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:732] at line 729 of Types/Standard.pm, avg 1.17ms/call # 2 times (12µs+4µs) by Type::Tiny::Union::new at line 86 of Type/Tiny/Union.pm, avg 8µs/call # 2 times (14µs+-14µs) by Types::Standard::HashRef::__coercion_generator at line 103 of Types/Standard/HashRef.pm, avg 0s/call # 2 times (9µs+-9µs) by Types::Standard::Dict::__coercion_generator at line 257 of Types/Standard/Dict.pm, avg 0s/call # 2 times (7µs+-7µs) by Types::Standard::Dict::__coercion_generator at line 258 of Types/Standard/Dict.pm, avg 0s/call
sub has_coercion {
4718524µs30s $_[0]->coercion if $_[0]{_build_coercion}; # trigger auto build thing
# spent 2.92ms making 3 calls to Type::Tiny::coercion, avg 972µs/call, recursion: max depth 2, sum of overlapping time 2.92ms
47285254µs9651µs $_[0]{coercion} and !!@{ $_[0]{coercion}->type_coercion_map };
# spent 27µs making 48 calls to Type::Coercion::type_coercion_map, avg 562ns/call # spent 24µs making 48 calls to Type::Coercion::__ANON__[Type/Coercion.pm:28], avg 500ns/call
473}
474
475sub _assert_coercion {
476 my $self = shift;
477 return $self->coercion if $self->{_build_coercion}; # trigger auto build thing
478 _croak "No coercion for this type constraint"
479 unless $self->has_coercion
480 && @{ $self->coercion->type_coercion_map };
481 $self->coercion;
482}
483
48411µsmy $null_constraint = sub { !!1 };
485
486
# spent 172µs (128+44) within Type::Tiny::_build_display_name which was called 44 times, avg 4µs/call: # 44 times (128µs+44µs) by Type::Tiny::display_name at line 432, avg 4µs/call
sub _build_display_name {
48744121µs4444µs shift->name;
# spent 44µs making 44 calls to Type::Tiny::name, avg 1µs/call
488}
489
490
# spent 72µs within Type::Tiny::_build_constraint which was called 15 times, avg 5µs/call: # 15 times (72µs+0s) by Type::Tiny::constraint at line 434, avg 5µs/call
sub _build_constraint {
4911535µs return $null_constraint;
492}
493
494
# spent 4.23ms (3.21+1.02) within Type::Tiny::_is_null_constraint which was called 1551 times, avg 3µs/call: # 860 times (1.86ms+578µs) by Type::Tiny::can_be_inlined at line 877, avg 3µs/call # 547 times (1.03ms+238µs) by Type::Tiny::inline_check at line 889, avg 2µs/call # 59 times (113µs+28µs) by Type::Tiny::can_be_inlined at line 879, avg 2µs/call # 50 times (149µs+157µs) by Type::Tiny::_build_compiled_check at line 532, avg 6µs/call # 28 times (51µs+11µs) by Type::Tiny::inline_check at line 891, avg 2µs/call # 6 times (15µs+5µs) by Type::Tiny::find_constraining_type at line 558, avg 3µs/call # once (2µs+1µs) by Type::Tiny::type_default at line 573
sub _is_null_constraint {
49515513.18ms15511.02ms shift->constraint == $null_constraint;
# spent 1.02ms making 1551 calls to Type::Tiny::constraint, avg 656ns/call
496}
497
498
# spent 13.8ms (4.14+9.64) within Type::Tiny::_build_coercion which was called 54 times, avg 255µs/call: # 54 times (4.14ms+9.64ms) by Type::Tiny::coercion at line 439, avg 255µs/call
sub _build_coercion {
49954493µs require Type::Coercion;
5005413µs my $self = shift;
5015427µs my %opts = ( type_constraint => $self );
50254116µs91316µs $opts{display_name} = "to_$self" unless $self->is_anon;
# spent 177µs making 54 calls to Type::Tiny::is_anon, avg 3µs/call # spent 139µs making 37 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 4µs/call
5035494µs548.51ms my $coercion = "Type::Coercion"->new( %opts );
# spent 8.51ms making 54 calls to Type::Coercion::new, avg 158µs/call
5045431µs53.56ms $self->{_build_coercion}->( $coercion ) if ref $self->{_build_coercion};
# spent 2.35ms making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:732], avg 1.17ms/call # spent 1.21ms making 3 calls to Type::Tiny::__ANON__[Type/Tiny.pm:1073], avg 402µs/call
5055488µs $coercion;
506}
507
508sub _build_default_message {
509 my $self = shift;
510 $self->{is_using_default_message} = 1;
511 return sub { sprintf '%s did not pass type constraint', _dd( $_[0] ) }
512 if "$self" eq "__ANON__";
513 my $name = "$self";
514 return sub {
515 sprintf '%s did not pass type constraint "%s"', _dd( $_[0] ), $name;
516 };
517} #/ sub _build_default_message
518
519
# spent 16µs within Type::Tiny::_build_name_generator which was called 5 times, avg 3µs/call: # 5 times (16µs+0s) by Type::Tiny::name_generator at line 446, avg 3µs/call
sub _build_name_generator {
52050s my $self = shift;
521
# spent 662µs (266+396) within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:524] which was called 16 times, avg 41µs/call: # 14 times (241µs+361µs) by Type::Tiny::parameterize at line 1050, avg 43µs/call # 2 times (25µs+35µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] at line 735 of Types/Standard.pm, avg 30µs/call
return sub {
52216157µs66479µs defined && s/[\x00-\x1F]//smg for ( my ( $s, @a ) = @_ );
# spent 282µs making 33 calls to Type::Tiny::CORE:subst, avg 9µs/call # spent 197µs making 33 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 6µs/call
52316132µs33114µs sprintf( '%s[%s]', $s, join q[,], map !defined() ? 'undef' : !ref() && /\W/ ? B::perlstring($_) : $_, @a );
# spent 114µs making 33 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 3µs/call
524519µs };
525}
526
527
# spent 21.8ms (930µs+20.9) within Type::Tiny::_build_compiled_check which was called 62 times, avg 351µs/call: # 56 times (825µs+19.5ms) by Type::Tiny::compiled_check at line 437, avg 364µs/call # 4 times (73µs+957µs) by Type::Tiny::Enum::_build_compiled_check at line 198 of Type/Tiny/Enum.pm, avg 258µs/call # 2 times (32µs+361µs) by Type::Tiny::check at line 758, avg 196µs/call
sub _build_compiled_check {
5286220µs my $self = shift;
529
5306235µs local our $AvoidCallbacks = 0;
531
53262155µs105351µs if ( $self->_is_null_constraint and $self->has_parent ) {
# spent 306µs making 50 calls to Type::Tiny::_is_null_constraint, avg 6µs/call # spent 19µs making 15 calls to Type::Tiny::has_parent, avg 1µs/call # spent 13µs making 14 calls to Type::Tiny::parent, avg 929ns/call # spent 8µs making 4 calls to Type::Tiny::Enum::_is_null_constraint, avg 2µs/call # spent 3µs making 7 calls to Type::Tiny::Class::_is_null_constraint, avg 429ns/call # spent 2µs making 1 call to Type::Tiny::Duck::_is_null_constraint # spent 14µs making 14 calls to Type::Tiny::compiled_check, avg 1µs/call, recursion: max depth 1, sum of overlapping time 14µs
533 return $self->parent->compiled_check;
534 }
535
5364827µs require Eval::TypeTiny;
53748565µs19220.5ms return Eval::TypeTiny::eval_closure(
# spent 11.1ms making 44 calls to Type::Tiny::inline_check, avg 252µs/call # spent 8.17ms making 48 calls to Eval::TypeTiny::eval_closure, avg 170µs/call # spent 600µs making 48 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 12µs/call # spent 545µs making 44 calls to Type::Tiny::can_be_inlined, avg 12µs/call # spent 66µs making 4 calls to Type::Tiny::Enum::inline_check, avg 16µs/call # spent 5µs making 4 calls to Type::Tiny::Enum::can_be_inlined, avg 1µs/call
538 source => sprintf( 'sub ($) { %s }', $self->inline_check( '$_[0]' ) ),
539 description => sprintf( "compiled check '%s'", $self ),
540 ) if $self->can_be_inlined;
541
542 my @constraints;
543 push @constraints, $self->parent->compiled_check if $self->has_parent;
544 push @constraints, $self->constraint if !$self->_is_null_constraint;
545 return $null_constraint unless @constraints;
546
547 return sub ($) {
548 local $_ = $_[0];
549 for my $c ( @constraints ) {
550 return unless $c->( @_ );
551 }
552 return !!1;
553 };
554} #/ sub _build_compiled_check
555
556
# spent 40µs (20+20) within Type::Tiny::find_constraining_type which was called 6 times, avg 7µs/call: # 3 times (13µs+11µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 613, avg 8µs/call # 3 times (7µs+9µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 614, avg 5µs/call
sub find_constraining_type {
55761µs my $self = shift;
55867µs620µs if ( $self->_is_null_constraint and $self->has_parent ) {
# spent 20µs making 6 calls to Type::Tiny::_is_null_constraint, avg 3µs/call
559 return $self->parent->find_constraining_type;
560 }
561612µs $self;
562}
563
564
# spent 68µs (65+3) within Type::Tiny::type_default which was called 17 times, avg 4µs/call: # 8 times (26µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:532] at line 530 of Types/Standard.pm, avg 3µs/call # 4 times (13µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:510] at line 508 of Types/Standard.pm, avg 3µs/call # 2 times (2µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] at line 735 of Types/Standard.pm, avg 1µs/call # once (18µs+6µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:661] at line 660 of Types/Standard.pm # once (3µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:704] at line 703 of Types/Standard.pm # once (3µs+-3µs) by Type::Tiny::type_default at line 573
sub type_default {
565176µs my ( $self, @args ) = @_;
566177µs if ( exists $self->{type_default} ) {
567165µs if ( @args ) {
568 my $td = $self->{type_default};
569 return sub { local $_ = \@args; &$td; };
570 }
5711649µs return $self->{type_default};
572 }
57318µs43µs if ( my $parent = $self->parent ) {
# spent 3µs making 1 call to Type::Tiny::_is_null_constraint # spent 0s making 1 call to Type::Tiny::__ANON__[Type/Tiny.pm:101] # spent 0s making 1 call to Type::Tiny::parent # spent 3µs making 1 call to Type::Tiny::type_default, recursion: max depth 1, sum of overlapping time 3µs
574 return $parent->type_default( @args ) if $self->_is_null_constraint;
575 }
576 return undef;
577}
578
579our @CMP;
580
581sub CMP_SUPERTYPE () { -1 }
582sub CMP_EQUAL () { 0 }
583sub CMP_EQUIVALENT () { '0E0' }
584sub CMP_SUBTYPE () { 1 }
585sub CMP_UNKNOWN () { ''; }
586
587# avoid getting mixed up with cmp operator at compile time
588
# spent 7.44ms (68µs+7.38) within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:602] which was called 3 times, avg 2.48ms/call: # 3 times (68µs+7.38ms) by Type::Tiny::is_a_type_of at line 680, avg 2.48ms/call
*cmp = sub {
58932µs331µs my ( $A, $B ) = _loose_to_TypeTiny( $_[0], $_[1] );
# spent 31µs making 3 calls to Type::Tiny::_loose_to_TypeTiny, avg 10µs/call
590313µs612µs return unless blessed( $A ) && $A->isa( "Type::Tiny" );
# spent 10µs making 3 calls to Type::Tiny::isa, avg 3µs/call # spent 2µs making 3 calls to Scalar::Util::blessed, avg 667ns/call
59139µs610µs return unless blessed( $B ) && $B->isa( "Type::Tiny" );
# spent 8µs making 3 calls to Type::Tiny::isa, avg 3µs/call # spent 2µs making 3 calls to Scalar::Util::blessed, avg 667ns/call
59235µs for my $comparator ( @CMP ) {
59335µs37.32ms my $result = $comparator->( $A, $B );
# spent 7.32ms making 3 calls to Type::Tiny::__ANON__[Type/Tiny.pm:659], avg 2.44ms/call
59433µs next if $result eq CMP_UNKNOWN;
59532µs if ( $result eq CMP_EQUIVALENT ) {
596 my $prefer = @_ == 3 ? $_[2] : CMP_EQUAL;
597 return $prefer;
598 }
599311µs return $result;
600 }
601 return CMP_UNKNOWN;
60212µs};
603
604
# spent 7.32ms (485µs+6.84) within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] which was called 3 times, avg 2.44ms/call: # 3 times (485µs+6.84ms) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:602] at line 593, avg 2.44ms/call
push @CMP, sub {
60530s my ( $A, $B ) = @_;
606317µs63µs return CMP_EQUAL
# spent 3µs making 6 calls to Scalar::Util::refaddr, avg 500ns/call
607 if Scalar::Util::refaddr( $A ) == Scalar::Util::refaddr( $B );
608
609323µs128µs return CMP_EQUIVALENT
# spent 5µs making 6 calls to Type::Tiny::compiled_check, avg 833ns/call # spent 3µs making 6 calls to Scalar::Util::refaddr, avg 500ns/call
610 if Scalar::Util::refaddr( $A->compiled_check ) ==
611 Scalar::Util::refaddr( $B->compiled_check );
612
61337µs324µs my $A_stem = $A->find_constraining_type;
# spent 24µs making 3 calls to Type::Tiny::find_constraining_type, avg 8µs/call
61434µs316µs my $B_stem = $B->find_constraining_type;
# spent 16µs making 3 calls to Type::Tiny::find_constraining_type, avg 5µs/call
615313µs64µs return CMP_EQUIVALENT
# spent 4µs making 6 calls to Scalar::Util::refaddr, avg 667ns/call
616 if Scalar::Util::refaddr( $A_stem ) == Scalar::Util::refaddr( $B_stem );
617315µs125µs return CMP_EQUIVALENT
# spent 3µs making 6 calls to Type::Tiny::compiled_check, avg 500ns/call # spent 2µs making 6 calls to Scalar::Util::refaddr, avg 333ns/call
618 if Scalar::Util::refaddr( $A_stem->compiled_check ) ==
619 Scalar::Util::refaddr( $B_stem->compiled_check );
620
621311µs121.39ms if ( $A_stem->can_be_inlined and $B_stem->can_be_inlined ) {
# spent 1.32ms making 6 calls to Type::Tiny::inline_check, avg 220µs/call # spent 68µs making 6 calls to Type::Tiny::can_be_inlined, avg 11µs/call
622 return CMP_EQUIVALENT
623 if $A_stem->inline_check( '$WOLFIE' ) eq $B_stem->inline_check( '$WOLFIE' );
624 }
625
626 A_IS_SUBTYPE: {
62762µs my $A_prime = $A_stem;
62834µs33µs while ( $A_prime->has_parent ) {
# spent 3µs making 3 calls to Type::Tiny::has_parent, avg 1µs/call
6291211µs126µs $A_prime = $A_prime->parent;
# spent 6µs making 12 calls to Type::Tiny::parent, avg 500ns/call
6301248µs247µs return CMP_SUBTYPE
# spent 7µs making 24 calls to Scalar::Util::refaddr, avg 292ns/call
631 if Scalar::Util::refaddr( $A_prime ) == Scalar::Util::refaddr( $B_stem );
6321255µs4827µs return CMP_SUBTYPE
# spent 19µs making 24 calls to Type::Tiny::compiled_check, avg 792ns/call # spent 8µs making 24 calls to Scalar::Util::refaddr, avg 333ns/call
633 if Scalar::Util::refaddr( $A_prime->compiled_check ) ==
634 Scalar::Util::refaddr( $B_stem->compiled_check );
63512114µs605.34ms if ( $A_prime->can_be_inlined and $B_stem->can_be_inlined ) {
# spent 4.98ms making 24 calls to Type::Tiny::inline_check, avg 208µs/call # spent 341µs making 24 calls to Type::Tiny::can_be_inlined, avg 14µs/call # spent 11µs making 12 calls to Type::Tiny::has_parent, avg 917ns/call
636 return CMP_SUBTYPE
637 if $A_prime->inline_check( '$WOLFIE' ) eq $B_stem->inline_check( '$WOLFIE' );
638 }
639 } #/ while ( $A_prime->has_parent)
640 } #/ A_IS_SUBTYPE:
641
642 B_IS_SUBTYPE: {
64362µs my $B_prime = $B_stem;
64434µs33µs while ( $B_prime->has_parent ) {
# spent 3µs making 3 calls to Type::Tiny::has_parent, avg 1µs/call
64534µs31µs $B_prime = $B_prime->parent;
# spent 1µs making 3 calls to Type::Tiny::parent, avg 333ns/call
646329µs62µs return CMP_SUPERTYPE
# spent 2µs making 6 calls to Scalar::Util::refaddr, avg 333ns/call
647 if Scalar::Util::refaddr( $B_prime ) == Scalar::Util::refaddr( $A_stem );
648 return CMP_SUPERTYPE
649 if Scalar::Util::refaddr( $B_prime->compiled_check ) ==
650 Scalar::Util::refaddr( $A_stem->compiled_check );
651 if ( $A_stem->can_be_inlined and $B_prime->can_be_inlined ) {
652 return CMP_SUPERTYPE
653 if $B_prime->inline_check( '$WOLFIE' ) eq $A_stem->inline_check( '$WOLFIE' );
654 }
655 } #/ while ( $B_prime->has_parent)
656 } #/ B_IS_SUBTYPE:
657
658 return CMP_UNKNOWN;
65913µs};
660
661sub equals {
662 my $result = Type::Tiny::cmp( $_[0], $_[1] );
663 return unless defined $result;
664 $result eq CMP_EQUAL;
665}
666
667sub is_subtype_of {
668 my $result = Type::Tiny::cmp( $_[0], $_[1], CMP_SUBTYPE );
669 return unless defined $result;
670 $result eq CMP_SUBTYPE;
671}
672
673sub is_supertype_of {
674 my $result = Type::Tiny::cmp( $_[0], $_[1], CMP_SUBTYPE );
675 return unless defined $result;
676 $result eq CMP_SUPERTYPE;
677}
678
679
# spent 7.46ms (20µs+7.44) within Type::Tiny::is_a_type_of which was called 3 times, avg 2.49ms/call: # 3 times (20µs+7.44ms) by Types::Standard::Dict::__inline_generator at line 100 of Types/Standard/Dict.pm, avg 2.49ms/call
sub is_a_type_of {
68038µs37.44ms my $result = Type::Tiny::cmp( $_[0], $_[1] );
# spent 7.44ms making 3 calls to Type::Tiny::__ANON__[Type/Tiny.pm:602], avg 2.48ms/call
68133µs return unless defined $result;
682311µs $result eq CMP_SUBTYPE or $result eq CMP_EQUAL or $result eq CMP_EQUIVALENT;
683}
684
685
# spent 18.6ms (7.20+11.4) within Type::Tiny::strictly_equals which was called 794 times, avg 23µs/call: # 597 times (5.40ms+8.64ms) by Type::Tiny::is_strictly_subtype_of at line 698, avg 24µs/call # 191 times (1.72ms+2.60ms) by Type::Tiny::is_strictly_a_type_of at line 715, avg 23µs/call # 6 times (81µs+112µs) by Types::Standard::Dict::__inline_generator at line 103 of Types/Standard/Dict.pm, avg 32µs/call
sub strictly_equals {
686794626µs7946.80ms my ( $self, $other ) = _loose_to_TypeTiny( @_ );
# spent 6.80ms making 794 calls to Type::Tiny::_loose_to_TypeTiny, avg 9µs/call
6877942.13ms15882.34ms return unless blessed( $self ) && $self->isa( "Type::Tiny" );
# spent 1.97ms making 794 calls to Type::Tiny::isa, avg 2µs/call # spent 361µs making 794 calls to Scalar::Util::blessed, avg 455ns/call
6887941.95ms15882.22ms return unless blessed( $other ) && $other->isa( "Type::Tiny" );
# spent 1.87ms making 794 calls to Type::Tiny::isa, avg 2µs/call # spent 356µs making 794 calls to Scalar::Util::blessed, avg 448ns/call
6897941.58ms $self->{uniq} == $other->{uniq};
690}
691
692
# spent 36.0ms (10.3+25.7) within Type::Tiny::is_strictly_subtype_of which was called 703 times, avg 51µs/call: # 512 times (7.47ms+-7.47ms) by Type::Tiny::is_strictly_subtype_of at line 698, avg 0s/call # 191 times (2.81ms+33.2ms) by Type::Tiny::is_strictly_a_type_of at line 715, avg 188µs/call
sub is_strictly_subtype_of {
693703599µs7035.76ms my ( $self, $other ) = _loose_to_TypeTiny( @_ );
# spent 5.76ms making 703 calls to Type::Tiny::_loose_to_TypeTiny, avg 8µs/call
6947031.88ms14062.13ms return unless blessed( $self ) && $self->isa( "Type::Tiny" );
# spent 1.79ms making 703 calls to Type::Tiny::isa, avg 3µs/call # spent 338µs making 703 calls to Scalar::Util::blessed, avg 481ns/call
6957031.72ms14061.99ms return unless blessed( $other ) && $other->isa( "Type::Tiny" );
# spent 1.69ms making 703 calls to Type::Tiny::isa, avg 2µs/call # spent 306µs making 703 calls to Scalar::Util::blessed, avg 435ns/call
696
697703691µs703494µs return unless $self->has_parent;
# spent 440µs making 639 calls to Type::Tiny::has_parent, avg 689ns/call # spent 28µs making 42 calls to Type::Tiny::ConstrainedObject::has_parent, avg 667ns/call # spent 26µs making 22 calls to Type::Tiny::Enum::has_parent, avg 1µs/call
6985972.39ms221815.3ms $self->parent->strictly_equals( $other )
# spent 14.0ms making 597 calls to Type::Tiny::strictly_equals, avg 24µs/call # spent 582µs making 981 calls to Type::Tiny::parent, avg 593ns/call # spent 505µs making 84 calls to Type::Tiny::Class::parent, avg 6µs/call # spent 181µs making 44 calls to Type::Tiny::Enum::parent, avg 4µs/call # spent 69.0ms making 512 calls to Type::Tiny::is_strictly_subtype_of, avg 135µs/call, recursion: max depth 7, sum of overlapping time 69.0ms
699 or $self->parent->is_strictly_subtype_of( $other );
700}
701
702sub is_strictly_supertype_of {
703 my ( $self, $other ) = _loose_to_TypeTiny( @_ );
704 return unless blessed( $self ) && $self->isa( "Type::Tiny" );
705 return unless blessed( $other ) && $other->isa( "Type::Tiny" );
706
707 $other->is_strictly_subtype_of( $self );
708}
709
710
# spent 45.5ms (2.26+43.3) within Type::Tiny::is_strictly_a_type_of which was called 191 times, avg 238µs/call: # 134 times (1.48ms+29.9ms) by Types::Standard::Dict::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Dict.pm:161] at line 156 of Types/Standard/Dict.pm, avg 234µs/call # 32 times (435µs+7.20ms) by Types::Standard::Dict::__constraint_generator at line 64 of Types/Standard/Dict.pm, avg 239µs/call # 4 times (41µs+1.29ms) by Types::Standard::Tuple::__inline_generator at line 133 of Types/Standard/Tuple.pm, avg 333µs/call # 4 times (46µs+1.17ms) by Types::Standard::Tuple::__constraint_generator at line 59 of Types/Standard/Tuple.pm, avg 304µs/call # 4 times (60µs+820µs) by Types::Standard::Dict::__inline_generator at line 90 of Types/Standard/Dict.pm, avg 220µs/call # 4 times (73µs+640µs) by Types::Standard::Dict::__constraint_generator at line 44 of Types/Standard/Dict.pm, avg 178µs/call # 4 times (50µs+622µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] at line 815 of Types/Standard.pm, avg 168µs/call # 2 times (29µs+689µs) by Types::Standard::Tuple::__constraint_generator at line 28 of Types/Standard/Tuple.pm, avg 359µs/call # 2 times (27µs+603µs) by Types::Standard::Tuple::__inline_generator at line 95 of Types/Standard/Tuple.pm, avg 315µs/call # once (12µs+358µs) by Types::Standard::Dict::__coercion_generator at line 244 of Types/Standard/Dict.pm
sub is_strictly_a_type_of {
711191182µs1911.82ms my ( $self, $other ) = _loose_to_TypeTiny( @_ );
# spent 1.82ms making 191 calls to Type::Tiny::_loose_to_TypeTiny, avg 10µs/call
712191578µs382656µs return unless blessed( $self ) && $self->isa( "Type::Tiny" );
# spent 540µs making 191 calls to Type::Tiny::isa, avg 3µs/call # spent 116µs making 191 calls to Scalar::Util::blessed, avg 607ns/call
713191459µs382509µs return unless blessed( $other ) && $other->isa( "Type::Tiny" );
# spent 421µs making 191 calls to Type::Tiny::isa, avg 2µs/call # spent 88µs making 191 calls to Scalar::Util::blessed, avg 461ns/call
714
715191664µs38240.3ms $self->strictly_equals( $other ) or $self->is_strictly_subtype_of( $other );
# spent 36.0ms making 191 calls to Type::Tiny::is_strictly_subtype_of, avg 188µs/call # spent 4.32ms making 191 calls to Type::Tiny::strictly_equals, avg 23µs/call
716}
717
718
# spent 212µs (188+24) within Type::Tiny::qualified_name which was called 46 times, avg 5µs/call: # 37 times (156µs+17µs) by Eval::TypeTiny::type_to_coderef at line 169 of Eval/TypeTiny.pm, avg 5µs/call # 7 times (25µs+7µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] at line 186 of Types/Standard.pm, avg 5µs/call # 2 times (7µs+0s) by Type::Tiny::new at line 364, avg 4µs/call
sub qualified_name {
719469µs my $self = shift;
720 ( exists $self->{library} and $self->name ne "__ANON__" )
721 ? "$self->{library}::$self->{name}"
72246206µs4624µs : $self->{name};
# spent 24µs making 46 calls to Type::Tiny::name, avg 522ns/call
723}
724
725
# spent 424µs (332+92) within Type::Tiny::is_anon which was called 129 times, avg 3µs/call: # 54 times (133µs+44µs) by Type::Tiny::_build_coercion at line 502, avg 3µs/call # 38 times (83µs+21µs) by Type::Tiny::exportables at line 1187, avg 3µs/call # 37 times (116µs+27µs) by Type::Library::add_type at line 228 of Type/Library.pm, avg 4µs/call
sub is_anon {
72612928µs my $self = shift;
727129309µs12992µs $self->name eq "__ANON__";
# spent 92µs making 129 calls to Type::Tiny::name, avg 713ns/call
728}
729
730sub parents {
731 my $self = shift;
732 return unless $self->has_parent;
733 return ( $self->parent, $self->parent->parents );
734}
735
736
# spent 41µs (29+12) within Type::Tiny::find_parent which was called 2 times, avg 20µs/call: # 2 times (29µs+12µs) by Types::Standard::Slurpy::my_unslurpy at line 751 of Types/Standard.pm, avg 20µs/call
sub find_parent {
73720s my $self = shift;
73821µs my ( $test ) = @_;
739
74025µs local ( $_, $. );
74121µs my $type = $self;
74222µs my $count = 0;
74327µs24µs while ( $type ) {
# spent 4µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 2µs/call
744212µs28µs if ( $test->( $_ = $type, $. = $count ) ) {
# spent 8µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:750], avg 4µs/call
745 return wantarray ? ( $type, $count ) : $type;
746 }
747 else {
748 $type = $type->parent;
749 $count++;
750 }
751 }
752
753 return;
754} #/ sub find_parent
755
756
# spent 4.10ms (1.08+3.02) within Type::Tiny::check which was called 379 times, avg 11µs/call: # 341 times (928µs+2.72ms) by Types::TypeTiny::is_TypeTiny at line 2 of (eval 40)[Types/TypeTiny.pm:58], avg 11µs/call # 38 times (156µs+298µs) by Types::TypeTiny::is_StringLike at line 2 of (eval 39)[Types/TypeTiny.pm:58], avg 12µs/call
sub check {
75737958µs my $self = shift;
758379978µs3813.02ms ( $self->{compiled_type_constraint} ||= $self->_build_compiled_check )->( @_ );
# spent 2.51ms making 341 calls to Eval::TypeTiny::Sandbox::__ANON__[(eval 57)[Eval/TypeTiny.pm:8]:3], avg 7µs/call # spent 393µs making 2 calls to Type::Tiny::_build_compiled_check, avg 196µs/call # spent 116µs making 38 calls to Eval::TypeTiny::Sandbox::__ANON__[(eval 58)[Eval/TypeTiny.pm:8]:3], avg 3µs/call
759}
760
761sub _strict_check {
762 my $self = shift;
763 local $_ = $_[0];
764
765 my @constraints =
766 reverse
767 map { $_->constraint }
768 grep { not $_->_is_null_constraint } ( $self, $self->parents );
769
770 for my $c ( @constraints ) {
771 return unless $c->( @_ );
772 }
773
774 return !!1;
775} #/ sub _strict_check
776
777sub get_message {
778 my $self = shift;
779 local $_ = $_[0];
780 $self->has_message
781 ? $self->message->( @_ )
782 : $self->_default_message->( @_ );
783}
784
785sub validate {
786 my $self = shift;
787
788 return undef
789 if ( $self->{compiled_type_constraint} ||= $self->_build_compiled_check )
790 ->( @_ );
791
792 local $_ = $_[0];
793 return $self->get_message( @_ );
794} #/ sub validate
795
796sub validate_explain {
797 my $self = shift;
798 my ( $value, $varname ) = @_;
799 $varname = '$_' unless defined $varname;
800
801 return undef if $self->check( $value );
802
803 if ( $self->has_parent ) {
804 my $parent = $self->parent->validate_explain( $value, $varname );
805 return [
806 sprintf( '"%s" is a subtype of "%s"', $self, $self->parent ),
807 @$parent
808 ]
809 if $parent;
810 }
811
812 my $message = sprintf(
813 '%s%s',
814 $self->get_message( $value ),
815 $varname eq q{$_} ? '' : sprintf( ' (in %s)', $varname ),
816 );
817
818 if ( $self->is_parameterized and $self->parent->has_deep_explanation ) {
819 my $deep = $self->parent->deep_explanation->( $self, $value, $varname );
820 return [ $message, @$deep ] if $deep;
821 }
822
823 local $SIG{__WARN__} = sub {};
824 return [
825 $message,
826 sprintf( '"%s" is defined as: %s', $self, $self->_perlcode )
827 ];
828} #/ sub validate_explain
829
83010smy $b;
831
832sub _perlcode {
833 my $self = shift;
834
835 local our $AvoidCallbacks = 1;
836 return $self->inline_check( '$_' )
837 if $self->can_be_inlined;
838
839 $b ||= do {
840 local $@;
841 require B::Deparse;
842 my $tmp = "B::Deparse"->new;
843 $tmp->ambient_pragmas( strict => "all", warnings => "all" )
844 if $tmp->can( 'ambient_pragmas' );
845 $tmp;
846 };
847
848 my $code = $b->coderef2text( $self->constraint );
849 $code =~ s/\s+/ /g;
850 return "sub $code";
851} #/ sub _perlcode
852
853sub assert_valid {
854 my $self = shift;
855
856 return !!1
857 if ( $self->{compiled_type_constraint} ||= $self->_build_compiled_check )
858 ->( @_ );
859
860 local $_ = $_[0];
861 $self->_failed_check( "$self", $_ );
862} #/ sub assert_valid
863
864sub assert_return {
865 my $self = shift;
866
867 return $_[0]
868 if ( $self->{compiled_type_constraint} ||= $self->_build_compiled_check )
869 ->( @_ );
870
871 local $_ = $_[0];
872 $self->_failed_check( "$self", $_ );
873} #/ sub assert_return
874
875
# spent 11.7ms (7.11+4.61) within Type::Tiny::can_be_inlined which was called 1026 times, avg 11µs/call: # 638 times (3.97ms+2.76ms) by Type::Tiny::inline_check at line 886, avg 11µs/call # 126 times (1.05ms+1.01ms) by Type::Tiny::inline_assert at line 915, avg 16µs/call # 60 times (389µs+-389µs) by Type::Tiny::can_be_inlined at line 877, avg 0s/call # 44 times (358µs+187µs) by Type::Tiny::_build_compiled_check at line 537, avg 12µs/call # 37 times (393µs+374µs) by Type::Tiny::_overload_coderef at line 215, avg 21µs/call # 30 times (225µs+141µs) by Types::Standard::Dict::__inline_generator at line 117 of Types/Standard/Dict.pm, avg 12µs/call # 24 times (190µs+151µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 635, avg 14µs/call # 23 times (211µs+139µs) by Type::Tiny::_overload_coderef at line 203, avg 15µs/call # 8 times (56µs+44µs) by Types::Standard::HashRef::__inline_generator at line 65 of Types/Standard/HashRef.pm, avg 12µs/call # 6 times (40µs+30µs) by Type::Tiny::Union::can_be_inlined at line 117 of Type/Tiny/Union.pm, avg 12µs/call # 6 times (40µs+28µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 621, avg 11µs/call # 5 times (41µs+26µs) by Type::Tiny::new at line 277, avg 13µs/call # 4 times (31µs+15µs) by Types::Standard::ArrayRef::__inline_generator at line 100 of Types/Standard/ArrayRef.pm, avg 12µs/call # 3 times (31µs+26µs) by Types::Standard::Dict::__inline_generator at line 96 of Types/Standard/Dict.pm, avg 19µs/call # 2 times (17µs+13µs) by Types::Standard::Map::__inline_generator at line 61 of Types/Standard/Map.pm, avg 15µs/call # 2 times (18µs+11µs) by Types::Standard::Tuple::__inline_generator at line 103 of Types/Standard/Tuple.pm, avg 14µs/call # 2 times (18µs+8µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] at line 735 of Types/Standard.pm, avg 13µs/call # 2 times (11µs+11µs) by Type::Coercion::can_be_inlined at line 318 of Type/Coercion.pm, avg 11µs/call # 2 times (5µs+4µs) by Type::Coercion::can_be_inlined at line 324 of Type/Coercion.pm, avg 4µs/call # once (11µs+9µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:686] at line 681 of Types/Standard.pm # once (7µs+8µs) by Types::Standard::Dict::__coercion_generator at line 256 of Types/Standard/Dict.pm
sub can_be_inlined {
8761026151µs my $self = shift;
87710261.62ms21133.36ms return $self->parent->can_be_inlined
# spent 2.43ms making 860 calls to Type::Tiny::_is_null_constraint, avg 3µs/call # spent 716µs making 919 calls to Type::Tiny::has_parent, avg 779ns/call # spent 91µs making 107 calls to Type::Tiny::ConstrainedObject::has_parent, avg 850ns/call # spent 69µs making 98 calls to Type::Tiny::Class::_is_null_constraint, avg 704ns/call # spent 43µs making 60 calls to Type::Tiny::parent, avg 717ns/call # spent 4µs making 9 calls to Type::Tiny::Duck::_is_null_constraint, avg 444ns/call # spent 723µs making 60 calls to Type::Tiny::can_be_inlined, avg 12µs/call, recursion: max depth 2, sum of overlapping time 723µs
878 if $self->has_parent && $self->_is_null_constraint;
879966799µs1025662µs return !!1
# spent 475µs making 859 calls to Type::Tiny::has_parent, avg 553ns/call # spent 141µs making 59 calls to Type::Tiny::_is_null_constraint, avg 2µs/call # spent 46µs making 107 calls to Type::Tiny::ConstrainedObject::has_parent, avg 430ns/call
880 if !$self->has_parent && $self->_is_null_constraint;
8819111.99ms911591µs return $self->has_inlined;
# spent 530µs making 804 calls to Type::Tiny::has_inlined, avg 659ns/call # spent 58µs making 98 calls to Type::Tiny::Class::has_inlined, avg 592ns/call # spent 3µs making 9 calls to Type::Tiny::Duck::has_inlined, avg 333ns/call
882}
883
884
# spent 56.7ms (10.2+46.5) within Type::Tiny::inline_check which was called 638 times, avg 89µs/call: # 126 times (2.18ms+37.0ms) by Type::Tiny::inline_assert at line 915, avg 311µs/call # 118 times (1.91ms+-1.91ms) by Types::Standard::Dict::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Dict.pm:161] at line 156 of Types/Standard/Dict.pm, avg 0s/call # 57 times (721µs+-721µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:685] at line 684 of Types/Standard.pm, avg 0s/call # 50 times (583µs+-583µs) by Types::Standard::Dict::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Dict.pm:161] at line 148 of Types/Standard/Dict.pm, avg 0s/call # 44 times (944µs+10.2ms) by Type::Tiny::_build_compiled_check at line 537, avg 252µs/call # 37 times (552µs+-552µs) by Types::Standard::HashRef::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/HashRef.pm:76] at line 70 of Types/Standard/HashRef.pm, avg 0s/call # 37 times (550µs+-550µs) by Types::Standard::HashRef::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/HashRef.pm:76] at line 69 of Types/Standard/HashRef.pm, avg 0s/call # 32 times (469µs+-469µs) by Type::Tiny::inline_check at line 899, avg 0s/call # 24 times (349µs+4.64ms) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 635, avg 208µs/call # 24 times (418µs+-418µs) by Types::Standard::ArrayRef::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/ArrayRef.pm:121] at line 105 of Types/Standard/ArrayRef.pm, avg 0s/call # 24 times (478µs+-478µs) by Types::Standard::ArrayRef::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/ArrayRef.pm:121] at line 114 of Types/Standard/ArrayRef.pm, avg 0s/call # 20 times (261µs+-261µs) by Type::Tiny::inline_check at line 889, avg 0s/call # 16 times (258µs+-258µs) by Types::Standard::Tuple::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Tuple.pm:164] at line 157 of Types/Standard/Tuple.pm, avg 0s/call # 6 times (112µs+1.21ms) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:659] at line 621, avg 220µs/call # 4 times (50µs+61µs) by Type::Tiny::Union::inline_check at line 140 of Type/Tiny/Union.pm, avg 28µs/call # 3 times (112µs+-112µs) by Types::Standard::Map::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Map.pm:87] at line 79 of Types/Standard/Map.pm, avg 0s/call # 3 times (40µs+-40µs) by Types::Standard::Map::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Map.pm:87] at line 80 of Types/Standard/Map.pm, avg 0s/call # 3 times (52µs+-52µs) by Types::Standard::Map::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard/Map.pm:87] at line 78 of Types/Standard/Map.pm, avg 0s/call # 2 times (17µs+19µs) by Type::Coercion::inline_coercion at line 368 of Type/Coercion.pm, avg 18µs/call # 2 times (29µs+-29µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:328] at line 318 of Types/Standard.pm, avg 0s/call # 2 times (30µs+-30µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] at line 940 of Types/Standard.pm, avg 0s/call # 2 times (73µs+-73µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:921] at line 910 of Types/Standard.pm, avg 0s/call # 2 times (30µs+-30µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:734] at line 734 of Types/Standard.pm, avg 0s/call
sub inline_check {
88563895µs my $self = shift;
886638447µs6386.73ms _croak 'Cannot inline type constraint check for "%s"', $self
# spent 6.73ms making 638 calls to Type::Tiny::can_be_inlined, avg 11µs/call
887 unless $self->can_be_inlined;
888
889638932µs12881.63ms return $self->parent->inline_check( @_ )
# spent 1.26ms making 547 calls to Type::Tiny::_is_null_constraint, avg 2µs/call # spent 288µs making 575 calls to Type::Tiny::has_parent, avg 501ns/call # spent 50µs making 63 calls to Type::Tiny::ConstrainedObject::has_parent, avg 794ns/call # spent 19µs making 59 calls to Type::Tiny::Class::_is_null_constraint, avg 322ns/call # spent 11µs making 20 calls to Type::Tiny::parent, avg 550ns/call # spent 1µs making 4 calls to Type::Tiny::Duck::_is_null_constraint, avg 250ns/call # spent 703µs making 20 calls to Type::Tiny::inline_check, avg 35µs/call, recursion: max depth 2, sum of overlapping time 703µs
890 if $self->has_parent && $self->_is_null_constraint;
891618480µs646371µs return '(!!1)'
# spent 291µs making 555 calls to Type::Tiny::has_parent, avg 524ns/call # spent 62µs making 28 calls to Type::Tiny::_is_null_constraint, avg 2µs/call # spent 18µs making 63 calls to Type::Tiny::ConstrainedObject::has_parent, avg 286ns/call
892 if !$self->has_parent && $self->_is_null_constraint;
893
894592140µs local $_ = $_[0];
8955921.48ms118478.7ms my @r = $self->inlined->( $self, @_ );
# spent 43.6ms making 24 calls to Types::Standard::Dict::__ANON__[Types/Standard/Dict.pm:161], avg 1.82ms/call # spent 25.1ms making 37 calls to Types::Standard::HashRef::__ANON__[Types/Standard/HashRef.pm:76], avg 677µs/call # spent 3.14ms making 24 calls to Types::Standard::ArrayRef::__ANON__[Types/Standard/ArrayRef.pm:121], avg 131µs/call # spent 1.56ms making 57 calls to Types::Standard::__ANON__[Types/Standard.pm:685], avg 27µs/call # spent 1.42ms making 8 calls to Types::Standard::Tuple::__ANON__[Types/Standard/Tuple.pm:164], avg 178µs/call # spent 1.13ms making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:734], avg 566µs/call # spent 599µs making 3 calls to Types::Standard::Map::__ANON__[Types/Standard/Map.pm:87], avg 200µs/call # spent 351µs making 529 calls to Type::Tiny::inlined, avg 664ns/call # spent 285µs making 59 calls to Type::Tiny::Class::inlined, avg 5µs/call # spent 228µs making 59 calls to Type::Tiny::Class::__ANON__[Type/Tiny/Class.pm:89], avg 4µs/call # spent 167µs making 30 calls to Type::Tiny::__ANON__[Type/Tiny.pm:276], avg 6µs/call # spent 152µs making 81 calls to Types::Standard::__ANON__[Types/Standard.pm:523], avg 2µs/call # spent 148µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:921], avg 74µs/call # spent 119µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:328], avg 60µs/call # spent 101µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:945], avg 50µs/call # spent 93µs making 38 calls to Types::Standard::__ANON__[Types/Standard.pm:501], avg 2µs/call # spent 89µs making 38 calls to Types::Standard::__ANON__[Types/Standard.pm:277], avg 2µs/call # spent 76µs making 76 calls to Types::Standard::__ANON__[Types/Standard.pm:438], avg 1µs/call # spent 71µs making 3 calls to Types::Standard::__ANON__[Types/Standard.pm:295], avg 24µs/call # spent 49µs making 23 calls to Types::Standard::__ANON__[Types/Standard.pm:362], avg 2µs/call # spent 45µs making 14 calls to Types::Standard::__ANON__[Types/Standard.pm:229], avg 3µs/call # spent 34µs making 4 calls to Type::Tiny::Duck::__ANON__[Type/Tiny/Duck.pm:104], avg 8µs/call # spent 29µs making 26 calls to Types::Standard::__ANON__[Types/Standard.pm:241], avg 1µs/call # spent 20µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:456], avg 10µs/call # spent 19µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:488], avg 10µs/call # spent 15µs making 7 calls to Types::Standard::__ANON__[Types/Standard.pm:384], avg 2µs/call # spent 14µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:851], avg 7µs/call # spent 13µs making 5 calls to Types::Standard::__ANON__[Types/Standard.pm:566], avg 3µs/call # spent 12µs making 4 calls to Type::Tiny::Duck::inlined, avg 3µs/call # spent 10µs making 5 calls to Types::Standard::__ANON__[Types/Standard.pm:251], avg 2µs/call # spent 10µs making 4 calls to Types::Standard::__ANON__[Types/Standard.pm:264], avg 2µs/call # spent 10µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:545], avg 5µs/call # spent 9µs making 1 call to Types::TypeTiny::__ANON__[Types/TypeTiny.pm:174] # spent 7µs making 4 calls to Types::Standard::__ANON__[Types/Standard.pm:348], avg 2µs/call # spent 5µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:375], avg 2µs/call # spent 4µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:470], avg 2µs/call # spent 2µs making 1 call to Types::TypeTiny::__ANON__[Types/TypeTiny.pm:413]
896592175µs if ( @r and not defined $r[0] ) {
8973222µs3215µs _croak 'Inlining type constraint check for "%s" returned undef!', $self
# spent 15µs making 32 calls to Type::Tiny::has_parent, avg 469ns/call
898 unless $self->has_parent;
8993280µs6423µs $r[0] = $self->parent->inline_check( @_ );
# spent 23µs making 32 calls to Type::Tiny::parent, avg 719ns/call # spent 1.05ms making 32 calls to Type::Tiny::inline_check, avg 33µs/call, recursion: max depth 4, sum of overlapping time 1.05ms
900 }
901 my $r = join " && " => map {
90212163.31ms1012696µs /[;{}]/ && !/\Ado \{.+\}\z/
# spent 696µs making 1012 calls to Type::Tiny::CORE:match, avg 688ns/call
903 ? "do { $SafePackage $_ }"
904 : "($_)"
905 } @r;
9065921.37ms return @r == 1 ? $r : "($r)";
907} #/ sub inline_check
908
909
# spent 51.7ms (6.16+45.6) within Type::Tiny::inline_assert which was called 137 times, avg 378µs/call: # 73 times (2.54ms+25.4ms) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 23 of MooX/TypeTiny/Role/GenerateAccessor.pm, avg 382µs/call # 37 times (3.03ms+5.15ms) by Type::Tiny::_overload_coderef at line 215, avg 221µs/call # 27 times (586µs+15.1ms) by Type::Tiny::_overload_coderef at line 203, avg 580µs/call
sub inline_assert {
910137817µs require B;
91113742µs my $self = shift;
912137240µs my ( $varname, $typevarname, %extras ) = @_;
913
91413724µs my $inline_check;
915137506µs27441.6ms if ( $self->can_be_inlined ) {
# spent 39.2ms making 126 calls to Type::Tiny::inline_check, avg 311µs/call # spent 2.06ms making 126 calls to Type::Tiny::can_be_inlined, avg 16µs/call # spent 184µs making 9 calls to Type::Tiny::Enum::inline_check, avg 20µs/call # spent 129µs making 2 calls to Type::Tiny::Union::inline_check, avg 64µs/call # spent 49µs making 2 calls to Type::Tiny::Union::can_be_inlined, avg 24µs/call # spent 41µs making 9 calls to Type::Tiny::Enum::can_be_inlined, avg 5µs/call
916 $inline_check = sprintf( '(%s)', $self->inline_check( $varname ) );
917 }
918 elsif ( $typevarname ) {
919 $inline_check = sprintf( '%s->check(%s)', $typevarname, $varname );
920 }
921 else {
922 _croak 'Cannot inline type constraint check for "%s"', $self;
923 }
924
92513797µs my $do_wrapper = !delete $extras{no_wrapper};
926
92713719µs my $inline_throw;
928137173µs if ( $typevarname ) {
929 $inline_throw = sprintf(
930 'Type::Tiny::_failed_check(%s, %s, %s, %s)',
931 $typevarname,
932 B::perlstring( "$self" ),
933 $varname,
934 join(
935732.07ms8031.32ms ',', map +( B::perlstring( $_ ) => B::perlstring( $extras{$_} ) ),
# spent 619µs making 73 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 8µs/call # spent 596µs making 657 calls to B::perlstring, avg 907ns/call # spent 106µs making 73 calls to Type::Tiny::CORE:sort, avg 1µs/call
936 sort keys %extras
937 ),
938 );
939 } #/ if ( $typevarname )
940 else {
941 $inline_throw = sprintf(
942 'Type::Tiny::_failed_check(%s, %s, %s, %s)',
943 $self->{uniq},
944 B::perlstring( "$self" ),
945 $varname,
946 join(
94764737µs192877µs ',', map +( B::perlstring( $_ ) => B::perlstring( $extras{$_} ) ),
# spent 657µs making 64 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 10µs/call # spent 190µs making 64 calls to B::perlstring, avg 3µs/call # spent 30µs making 64 calls to Type::Tiny::CORE:sort, avg 469ns/call
948 sort keys %extras
949 ),
950 );
951 } #/ else [ if ( $typevarname ) ]
952
953137667µs $do_wrapper
954 ? qq[do { no warnings "void"; $SafePackage $inline_check or $inline_throw; $varname };]
955 : qq[ no warnings "void"; $SafePackage $inline_check or $inline_throw; $varname ];
956} #/ sub inline_assert
957
958sub _failed_check {
959 require Error::TypeTiny::Assertion;
960
961 my ( $self, $name, $value, %attrs ) = @_;
962 $self = $ALL_TYPES{$self} if defined $self && !ref $self;
963
964 my $exception_class =
965 delete( $attrs{exception_class} ) || "Error::TypeTiny::Assertion";
966 my $callback = delete( $attrs{on_die} );
967
968 if ( $self ) {
969 return $exception_class->throw_cb(
970 $callback,
971 message => $self->get_message( $value ),
972 type => $self,
973 value => $value,
974 %attrs,
975 );
976 }
977 else {
978 return $exception_class->throw_cb(
979 $callback,
980 message => sprintf( '%s did not pass type constraint "%s"', _dd( $value ), $name ),
981 value => $value,
982 %attrs,
983 );
984 }
985} #/ sub _failed_check
986
987sub coerce {
988 my $self = shift;
989 $self->_assert_coercion->coerce( @_ );
990}
991
992sub assert_coerce {
993 my $self = shift;
994 $self->_assert_coercion->assert_coerce( @_ );
995}
996
997
# spent 488µs (343+145) within Type::Tiny::is_parameterizable which was called 106 times, avg 5µs/call: # 69 times (238µs+110µs) by Type::Tiny::parameterize at line 1026, avg 5µs/call # 37 times (105µs+35µs) by Eval::TypeTiny::type_to_coderef at line 149 of Eval/TypeTiny.pm, avg 4µs/call
sub is_parameterizable {
998106324µs106145µs shift->has_constraint_generator;
# spent 145µs making 106 calls to Type::Tiny::has_constraint_generator, avg 1µs/call
999}
1000
1001
# spent 15µs (11+4) within Type::Tiny::is_parameterized which was called 3 times, avg 5µs/call: # 3 times (11µs+4µs) by Types::Standard::Dict::__inline_generator at line 103 of Types/Standard/Dict.pm, avg 5µs/call
sub is_parameterized {
1002310µs34µs shift->has_parameters;
# spent 4µs making 3 calls to Type::Tiny::has_parameters, avg 1µs/call
1003}
1004
1005{
100610s my %seen;
1007
1008
# spent 4.58ms (1.20+3.38) within Type::Tiny::____make_key which was called 69 times, avg 66µs/call: # 69 times (1.20ms+3.38ms) by Type::Tiny::parameterize at line 1036, avg 66µs/call
sub ____make_key {
1009 #<<<
1010 join ',', map {
101169308µs Types::TypeTiny::is_TypeTiny( $_ ) ? sprintf( '$Type::Tiny::ALL_TYPES{%s}', defined( $_->{uniq} ) ? $_->{uniq} : '____CANNOT_KEY____' ) :
1012 ref() eq 'ARRAY' ? do { $seen{$_}++ ? '____CANNOT_KEY____' : sprintf( '[%s]', ____make_key( @$_ ) ) } :
1013 ref() eq 'HASH' ? do { $seen{$_}++ ? '____CANNOT_KEY____' : sprintf( '{%s}', ____make_key( do { my %h = %$_; map +( $_, $h{$_} ), sort keys %h; } ) ) } :
1014 ref() eq 'SCALAR' || ref() eq 'REF' ? do { $seen{$_}++ ? '____CANNOT_KEY____' : sprintf( '\\(%s)', ____make_key( $$_ ) ) } :
1015 !defined() ? 'undef' :
1016382769µs3043.38ms !ref() ? do { require B; B::perlstring( $_ ) } :
# spent 3.29ms making 226 calls to Types::TypeTiny::is_TypeTiny, avg 15µs/call # spent 89µs making 78 calls to B::perlstring, avg 1µs/call
1017 '____CANNOT_KEY____';
1018 } @_;
1019 #>>>
1020 } #/ sub ____make_key
102111µs my %param_cache;
1022
1023
# spent 76.5ms (2.37+74.1) within Type::Tiny::parameterize which was called 69 times, avg 1.11ms/call: # 66 times (2.31ms+69.5ms) by Types::Standard::ArrayRef or Types::Standard::Dict or Types::Standard::Enum or Types::Standard::HasMethods or Types::Standard::HashRef or Types::Standard::InstanceOf or Types::Standard::Map or Types::Standard::Optional or Types::Standard::Tuple at line 11 of (eval 88)[Eval/TypeTiny.pm:8], avg 1.09ms/call # 3 times (60µs+4.62ms) by Type::Tiny::of at line 1566, avg 1.56ms/call
sub parameterize {
10246910µs my $self = shift;
1025
102669112µs69348µs $self->is_parameterizable
# spent 348µs making 69 calls to Type::Tiny::is_parameterizable, avg 5µs/call
1027 or @_
1028 ? _croak( "Type '%s' does not accept parameters", "$self" )
1029 : return ( $self );
1030
103169206µs157513µs @_ = map Types::TypeTiny::to_TypeTiny( $_ ), @_;
# spent 513µs making 157 calls to Types::TypeTiny::to_TypeTiny, avg 3µs/call
1032
1033 # Generate a key for caching parameterized type constraints,
1034 # but only if all the parameters are strings or type constraints.
10356924µs %seen = ();
103669113µs694.58ms my $key = $self->____make_key( @_ );
# spent 4.58ms making 69 calls to Type::Tiny::____make_key, avg 66µs/call
103769205µs6952µs undef( $key ) if $key =~ /____CANNOT_KEY____/;
# spent 52µs making 69 calls to Type::Tiny::CORE:match, avg 754ns/call
103869143µs return $param_cache{$key} if defined $key && defined $param_cache{$key};
1039
1040347µs local $Type::Tiny::parameterize_type = $self;
1041347µs local $_ = $_[0];
1042346µs my $P;
1043
104434188µs7854.3ms my ( $constraint, $compiled ) = $self->constraint_generator->( @_ );
# spent 13.3ms making 4 calls to Types::Standard::Dict::__constraint_generator, avg 3.33ms/call # spent 10.8ms making 10 calls to Types::Standard::__ANON__[Types/Standard.pm:190], avg 1.08ms/call # spent 10.8ms making 8 calls to Types::Standard::HashRef::__constraint_generator, avg 1.35ms/call # spent 4.32ms making 7 calls to Types::Standard::__ANON__[Types/Standard.pm:987], avg 617µs/call # spent 4.32ms making 2 calls to Types::Standard::Tuple::__constraint_generator, avg 2.16ms/call # spent 3.78ms making 4 calls to Types::Standard::__ANON__[Types/Standard.pm:1059], avg 945µs/call # spent 2.57ms making 4 calls to Types::Standard::ArrayRef::__constraint_generator, avg 644µs/call # spent 2.18ms making 1 call to Types::Standard::Map::__constraint_generator # spent 1.89ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:1033] # spent 248µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:737], avg 124µs/call # spent 40µs making 34 calls to Type::Tiny::constraint_generator, avg 1µs/call # spent 32µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:678]
1045
10463446µs34470µs if ( Types::TypeTiny::is_TypeTiny( $constraint ) ) {
# spent 470µs making 34 calls to Types::TypeTiny::is_TypeTiny, avg 14µs/call
1047 $P = $constraint;
1048 }
1049 else {
105020133µs402.02ms my %options = (
# spent 1.31ms making 4 calls to Types::Standard::__ANON__[Types/Standard.pm:826], avg 328µs/call # spent 602µs making 14 calls to Type::Tiny::__ANON__[Type/Tiny.pm:524], avg 43µs/call # spent 60µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:786], avg 30µs/call # spent 47µs making 20 calls to Type::Tiny::name_generator, avg 2µs/call
1051 constraint => $constraint,
1052 display_name => $self->name_generator->( $self, @_ ),
1053 parameters => [@_],
1054 );
1055207µs $options{compiled_type_constraint} = $compiled
1056 if $compiled;
10572099µs6012.1ms $options{inlined} = $self->inline_generator->( @_ )
# spent 9.67ms making 4 calls to Types::Standard::Dict::__inline_generator, avg 2.42ms/call # spent 2.08ms making 2 calls to Types::Standard::Tuple::__inline_generator, avg 1.04ms/call # spent 176µs making 8 calls to Types::Standard::HashRef::__inline_generator, avg 22µs/call # spent 91µs making 4 calls to Types::Standard::ArrayRef::__inline_generator, avg 23µs/call # spent 36µs making 1 call to Types::Standard::Map::__inline_generator # spent 30µs making 20 calls to Type::Tiny::has_inline_generator, avg 2µs/call # spent 28µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:686] # spent 22µs making 20 calls to Type::Tiny::inline_generator, avg 1µs/call
1058 if $self->has_inline_generator;
1059 $options{type_default} = $self->{type_default_generator}->( @_ )
10602044µs14132µs if exists $self->{type_default_generator}; # undocumented
# spent 65µs making 8 calls to Types::Standard::__ANON__[Types/Standard.pm:532], avg 8µs/call # spent 32µs making 4 calls to Types::Standard::__ANON__[Types/Standard.pm:510], avg 8µs/call # spent 27µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:661] # spent 8µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:704]
1061 exists $options{$_} && !defined $options{$_} && delete $options{$_}
10622075µs for keys %options;
1063
10642062µs201.24ms $P = $self->create_child_type( %options );
# spent 1.24ms making 20 calls to Type::Tiny::create_child_type, avg 62µs/call
1065
10662044µs2019µs if ( $self->has_coercion_generator ) {
# spent 19µs making 20 calls to Type::Tiny::has_coercion_generator, avg 950ns/call
10672016µs my @args = @_;
1068
# spent 1.21ms (38µs+1.17) within Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:1073] which was called 3 times, avg 402µs/call: # 3 times (38µs+1.17ms) by Type::Tiny::_build_coercion at line 504, avg 402µs/call
$P->{_build_coercion} = sub {
106931µs my $coercion = shift;
107037µs61.16ms my $built = $self->coercion_generator->( $self, $P, @args );
# spent 629µs making 2 calls to Types::Standard::HashRef::__coercion_generator, avg 314µs/call # spent 531µs making 1 call to Types::Standard::Dict::__coercion_generator # spent 4µs making 3 calls to Type::Tiny::coercion_generator, avg 1µs/call
107130s $coercion->add_type_coercions( @{ $built->type_coercion_map } ) if $built;
1072310µs35µs $coercion->freeze;
# spent 5µs making 3 calls to Type::Coercion::freeze, avg 2µs/call
10732053µs };
1074 }
1075 } #/ else [ if ( Types::TypeTiny::is_TypeTiny...)]
1076
10773430µs if ( defined $key ) {
10783441µs $param_cache{$key} = $P;
10793473µs3413µs Scalar::Util::weaken( $param_cache{$key} );
# spent 13µs making 34 calls to Scalar::Util::weaken, avg 382ns/call
1080 }
1081
108234107µs629.10ms $P->coercion->freeze unless $self->has_coercion_generator;
# spent 9.03ms making 14 calls to Type::Tiny::coercion, avg 645µs/call # spent 37µs making 14 calls to Type::Coercion::freeze, avg 3µs/call # spent 35µs making 34 calls to Type::Tiny::has_coercion_generator, avg 1µs/call
1083
108434121µs return $P;
1085 } #/ sub parameterize
1086}
1087
108811µs
# spent 30µs within Type::Tiny::child_type_class which was called 27 times, avg 1µs/call: # 27 times (30µs+0s) by Type::Tiny::create_child_type at line 1096, avg 1µs/call
sub child_type_class {
10892750µs __PACKAGE__;
1090}
1091
1092
# spent 2.26ms (222µs+2.03) within Type::Tiny::create_child_type which was called 27 times, avg 84µs/call: # 20 times (156µs+1.08ms) by Type::Tiny::parameterize at line 1064, avg 62µs/call # 5 times (56µs+879µs) by Type::Tiny::where at line 1567, avg 187µs/call # 2 times (10µs+73µs) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] at line 735 of Types/Standard.pm, avg 42µs/call
sub create_child_type {
1093276µs my $self = shift;
1094274µs my %moreopts;
10952729µs $moreopts{is_object} = 1 if $self->{is_object};
109627144µs542.03ms return $self->child_type_class->new( parent => $self, %moreopts, @_ );
# spent 2.00ms making 27 calls to Type::Tiny::new, avg 74µs/call # spent 30µs making 27 calls to Type::Tiny::child_type_class, avg 1µs/call
1097}
1098
1099sub complementary_type {
1100 my $self = shift;
1101 my $r = ( $self->{complementary_type} ||= $self->_build_complementary_type );
1102 Scalar::Util::weaken( $self->{complementary_type} )
1103 unless Scalar::Util::isweak( $self->{complementary_type} );
1104 return $r;
1105}
1106
1107sub _build_complementary_type {
1108 my $self = shift;
1109 my %opts = (
1110 constraint => sub { not $self->check( $_ ) },
1111 display_name => sprintf( "~%s", $self ),
1112 );
1113 $opts{display_name} =~ s/^\~{2}//;
1114 $opts{inlined} = sub { shift; "not(" . $self->inline_check( @_ ) . ")" }
1115 if $self->can_be_inlined;
1116 $opts{display_name} = $opts{name} = $self->{complement_name}
1117 if $self->{complement_name};
1118 return "Type::Tiny"->new( %opts );
1119} #/ sub _build_complementary_type
1120
1121sub _instantiate_moose_type {
1122 my $self = shift;
1123 my %opts = @_;
1124 require Moose::Meta::TypeConstraint;
1125 return "Moose::Meta::TypeConstraint"->new( %opts );
1126}
1127
1128sub _build_moose_type {
1129 my $self = shift;
1130
1131 my $r;
1132 if ( $self->{_is_core} ) {
1133 require Moose::Util::TypeConstraints;
1134 $r = Moose::Util::TypeConstraints::find_type_constraint( $self->name );
1135 $r->{"Types::TypeTiny::to_TypeTiny"} = $self;
1136 Scalar::Util::weaken( $r->{"Types::TypeTiny::to_TypeTiny"} );
1137 }
1138 else {
1139 # Type::Tiny is more flexible than Moose, allowing
1140 # inlined to return a list. So we need to wrap the
1141 # inlined coderef to make sure Moose gets a single
1142 # string.
1143 #
1144 my $wrapped_inlined = sub {
1145 shift;
1146 $self->inline_check( @_ );
1147 };
1148
1149 my %opts;
1150 $opts{name} = $self->qualified_name if $self->has_library && !$self->is_anon;
1151 $opts{parent} = $self->parent->moose_type if $self->has_parent;
1152 $opts{constraint} = $self->constraint unless $self->_is_null_constraint;
1153 $opts{message} = $self->message if $self->has_message;
1154 $opts{inlined} = $wrapped_inlined if $self->has_inlined;
1155
1156 $r = $self->_instantiate_moose_type( %opts );
1157 $r->{"Types::TypeTiny::to_TypeTiny"} = $self;
1158 $self->{moose_type} = $r; # prevent recursion
1159 $r->coercion( $self->coercion->moose_coercion ) if $self->has_coercion;
1160 } #/ else [ if ( $self->{_is_core})]
1161
1162 return $r;
1163} #/ sub _build_moose_type
1164
1165sub _build_mouse_type {
1166 my $self = shift;
1167
1168 my %options;
1169 $options{name} = $self->qualified_name if $self->has_library && !$self->is_anon;
1170 $options{parent} = $self->parent->mouse_type if $self->has_parent;
1171 $options{constraint} = $self->constraint unless $self->_is_null_constraint;
1172 $options{message} = $self->message if $self->has_message;
1173
1174 require Mouse::Meta::TypeConstraint;
1175 my $r = "Mouse::Meta::TypeConstraint"->new( %options );
1176
1177 $self->{mouse_type} = $r; # prevent recursion
1178 $r->_add_type_coercions(
1179 $self->coercion->freeze->_codelike_type_coercion_map( 'mouse_type' ) )
1180 if $self->has_coercion;
1181
1182 return $r;
1183} #/ sub _build_mouse_type
1184
1185
# spent 31.7ms (1.07+30.6) within Type::Tiny::exportables which was called 38 times, avg 835µs/call: # 37 times (1.06ms+30.3ms) by Type::Library::add_type at line 235 of Type/Library.pm, avg 847µs/call # once (16µs+346µs) by Type::Tiny::exportables_by_tag at line 1231
sub exportables {
11863831µs my ( $self, $base_name, $tag ) = ( shift, @_ ); # $tag is undocumented
11873866µs76128µs if ( not $self->is_anon ) {
# spent 104µs making 38 calls to Type::Tiny::is_anon, avg 3µs/call # spent 24µs making 38 calls to Type::Tiny::name, avg 632ns/call
1188 $base_name ||= $self->name;
1189 }
11903818µs $tag ||= 0;
1191
1192384µs my @exportables;
11933811µs return \@exportables if ! $base_name;
1194
1195388µs require Eval::TypeTiny;
1196
119738129µs376.84ms push @exportables, {
# spent 6.84ms making 37 calls to Eval::TypeTiny::type_to_coderef, avg 185µs/call
1198 name => $base_name,
1199 code => Eval::TypeTiny::type_to_coderef( $self ),
1200 tags => [ 'types' ],
1201 } if $tag eq 'types' || !$tag;
1202
120338127µs375.85ms push @exportables, {
# spent 5.85ms making 37 calls to Type::Tiny::compiled_check, avg 158µs/call
1204 name => sprintf( 'is_%s', $base_name ),
1205 code => $self->compiled_check,
1206 tags => [ 'is' ],
1207 } if $tag eq 'is' || !$tag;
1208
120938133µs3717.4ms push @exportables, {
# spent 17.4ms making 37 calls to Type::Tiny::_overload_coderef, avg 471µs/call
1210 name => sprintf( 'assert_%s', $base_name ),
1211 code => $self->_overload_coderef,
1212 tags => [ 'assert' ],
1213 } if $tag eq 'assert' || !$tag;
1214
1215 push @exportables, {
1216 name => sprintf( 'to_%s', $base_name ),
1217 code => $self->has_coercion && $self->coercion->frozen
1218 ? $self->coercion->compiled_coercion
1219 : sub ($) { $self->coerce( $_[0] ) },
122038232µs42414µs tags => [ 'to' ],
# spent 339µs making 1 call to Type::Coercion::compiled_coercion # spent 71µs making 38 calls to Type::Tiny::has_coercion, avg 2µs/call # spent 4µs making 2 calls to Type::Tiny::coercion, avg 2µs/call # spent 0s making 1 call to Type::Coercion::frozen
1221 } if $tag eq 'to' || !$tag;
1222
122338105µs return \@exportables;
1224}
1225
1226
# spent 372µs (10+362) within Type::Tiny::exportables_by_tag which was called: # once (10µs+362µs) by Type::Library::make_immutable at line 320 of Type/Library.pm
sub exportables_by_tag {
122711µs my ( $self, $tag, $base_name ) = ( shift, @_ );
1228 my @matched = grep {
122910s my $e = $_;
123011µs grep $_ eq $tag, @{ $e->{tags} || [] };
123114µs1362µs } @{ $self->exportables( $base_name, $tag ) };
# spent 362µs making 1 call to Type::Tiny::exportables
123212µs return @matched if wantarray;
1233 _croak( 'Expected to find one exportable tagged "%s", found %d', $tag, scalar @matched )
1234 unless @matched == 1;
1235 return $matched[0];
1236}
1237
1238sub _process_coercion_list {
1239 my $self = shift;
1240
1241 my @pairs;
1242 while ( @_ ) {
1243 my $next = shift;
1244 if ( blessed( $next )
1245 and $next->isa( 'Type::Coercion' )
1246 and $next->is_parameterized )
1247 {
1248 push @pairs => ( @{ $next->_reparameterize( $self )->type_coercion_map } );
1249 }
1250 elsif ( blessed( $next ) and $next->can( 'type_coercion_map' ) ) {
1251 push @pairs => (
1252 @{ $next->type_coercion_map },
1253 );
1254 }
1255 elsif ( ref( $next ) eq q(ARRAY) ) {
1256 unshift @_, @$next;
1257 }
1258 else {
1259 push @pairs => (
1260 Types::TypeTiny::to_TypeTiny( $next ),
1261 shift,
1262 );
1263 }
1264 } #/ while ( @_ )
1265
1266 return @pairs;
1267} #/ sub _process_coercion_list
1268
1269sub plus_coercions {
1270 my $self = shift;
1271 my $new = $self->_clone;
1272 $new->coercion->add_type_coercions(
1273 $self->_process_coercion_list( @_ ),
1274 @{ $self->coercion->type_coercion_map },
1275 );
1276 $new->coercion->freeze;
1277 return $new;
1278} #/ sub plus_coercions
1279
1280sub plus_fallback_coercions {
1281 my $self = shift;
1282
1283 my $new = $self->_clone;
1284 $new->coercion->add_type_coercions(
1285 @{ $self->coercion->type_coercion_map },
1286 $self->_process_coercion_list( @_ ),
1287 );
1288 $new->coercion->freeze;
1289 return $new;
1290} #/ sub plus_fallback_coercions
1291
1292sub minus_coercions {
1293 my $self = shift;
1294
1295 my $new = $self->_clone;
1296 my @not = grep Types::TypeTiny::is_TypeTiny( $_ ),
1297 $self->_process_coercion_list( $new, @_ );
1298
1299 my @keep;
1300 my $c = $self->coercion->type_coercion_map;
1301 for ( my $i = 0 ; $i <= $#$c ; $i += 2 ) {
1302 my $keep_this = 1;
1303 NOT: for my $n ( @not ) {
1304 if ( $c->[$i] == $n ) {
1305 $keep_this = 0;
1306 last NOT;
1307 }
1308 }
1309
1310 push @keep, $c->[$i], $c->[ $i + 1 ] if $keep_this;
1311 } #/ for ( my $i = 0 ; $i <=...)
1312
1313 $new->coercion->add_type_coercions( @keep );
1314 $new->coercion->freeze;
1315 return $new;
1316} #/ sub minus_coercions
1317
1318sub no_coercions {
1319 my $new = shift->_clone;
1320 $new->coercion->freeze;
1321 $new;
1322}
1323
1324sub coercibles {
1325 my $self = shift;
1326 $self->has_coercion ? $self->coercion->_source_type_union : $self;
1327}
1328
1329
# spent 9.93ms (8.34+1.59) within Type::Tiny::isa which was called 3756 times, avg 3µs/call: # 794 times (1.67ms+309µs) by Type::Tiny::strictly_equals at line 687, avg 2µs/call # 794 times (1.60ms+266µs) by Type::Tiny::strictly_equals at line 688, avg 2µs/call # 703 times (1.51ms+287µs) by Type::Tiny::is_strictly_subtype_of at line 694, avg 3µs/call # 703 times (1.43ms+254µs) by Type::Tiny::is_strictly_subtype_of at line 695, avg 2µs/call # 236 times (654µs+157µs) by Eval::TypeTiny::Sandbox::__ANON__[(eval 57)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Eval/TypeTiny.pm:8]:3] at line 3 of (eval 57)[Eval/TypeTiny.pm:8], avg 3µs/call # 191 times (448µs+92µs) by Type::Tiny::is_strictly_a_type_of at line 712, avg 3µs/call # 191 times (347µs+74µs) by Type::Tiny::is_strictly_a_type_of at line 713, avg 2µs/call # 73 times (441µs+96µs) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 13 of MooX/TypeTiny/Role/GenerateAccessor.pm, avg 7µs/call # 63 times (220µs+52µs) by Type::Tiny::new at line 255, avg 4µs/call # 3 times (9µs+1µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:602] at line 590, avg 3µs/call # 3 times (6µs+2µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:602] at line 591, avg 3µs/call # 2 times (7µs+2µs) by Type::Tiny::Union::new at line 60 of Type/Tiny/Union.pm, avg 4µs/call
sub isa {
13303756479µs my $self = shift;
1331
13323756578µs if ( $INC{"Moose.pm"}
1333 and ref( $self )
1334 and $_[0] =~ /^(?:Class::MOP|MooseX?::Meta)::(.+)$/ )
1335 {
1336 my $meta = $1;
1337
1338 return !!1 if $meta eq 'TypeConstraint';
1339 return $self->is_parameterized if $meta eq 'TypeConstraint::Parameterized';
1340 return $self->is_parameterizable if $meta eq 'TypeConstraint::Parameterizable';
1341 return $self->isa( 'Type::Tiny::Union' ) if $meta eq 'TypeConstraint::Union';
1342
1343 my $inflate = $self->moose_type;
1344 return $inflate->isa( @_ );
1345 } #/ if ( $INC{"Moose.pm"} ...)
1346
13473756323µs if ( $INC{"Mouse.pm"}
1348 and ref( $self )
1349 and $_[0] eq 'Mouse::Meta::TypeConstraint' )
1350 {
1351 return !!1;
1352 }
1353
1354375612.0ms37561.59ms $self->SUPER::isa( @_ );
# spent 1.59ms making 3756 calls to UNIVERSAL::isa, avg 424ns/call
1355} #/ sub isa
1356
1357
# spent 3µs within Type::Tiny::_build_my_methods which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by Type::Tiny::my_methods at line 452, avg 2µs/call
sub _build_my_methods {
135824µs return {};
1359}
1360
1361
# spent 236µs (149+87) within Type::Tiny::_lookup_my_method which was called 12 times, avg 20µs/call: # 6 times (112µs+124µs) by Type::Tiny::AUTOLOAD at line 1429, avg 39µs/call # 6 times (37µs+-37µs) by Type::Tiny::_lookup_my_method at line 1369, avg 0s/call
sub _lookup_my_method {
1362122µs my $self = shift;
13631221µs my ( $name ) = @_;
1364
13651268µs1875µs if ( $self->my_methods->{$name} ) {
# spent 75µs making 18 calls to Type::Tiny::my_methods, avg 4µs/call
1366 return $self->my_methods->{$name};
1367 }
1368
1369636µs1812µs if ( $self->has_parent ) {
# spent 10µs making 6 calls to Type::Tiny::has_parent, avg 2µs/call # spent 2µs making 6 calls to Type::Tiny::parent, avg 333ns/call # spent 45µs making 6 calls to Type::Tiny::_lookup_my_method, avg 7µs/call, recursion: max depth 1, sum of overlapping time 45µs
1370 return $self->parent->_lookup_my_method( @_ );
1371 }
1372
1373 return;
1374} #/ sub _lookup_my_method
1375
137614µsmy %object_methods = (
1377 with_attribute_values => 1, stringifies_to => 1,
1378 numifies_to => 1
1379);
1380
1381
# spent 527µs (431+96) within Type::Tiny::can which was called 67 times, avg 8µs/call: # 61 times (380µs+82µs) by Type::Tiny::_overload_coderef at line 190, avg 8µs/call # 4 times (27µs+7µs) by Type::Coercion::add_type_coercions at line 240 of Type/Coercion.pm, avg 8µs/call # 2 times (24µs+7µs) by Type::Tiny::Union::new_by_overload at line 30 of Type/Tiny/Union.pm, avg 16µs/call
sub can {
13826715µs my $self = shift;
1383
13846735µs return !!0
1385 if $_[0] eq 'type_parameter'
1386 && blessed( $_[0] )
1387 && $_[0]->has_parameters;
1388
138967342µs6791µs my $can = $self->SUPER::can( @_ );
# spent 91µs making 67 calls to UNIVERSAL::can, avg 1µs/call
139067126µs return $can if $can;
1391
139263µs if ( ref( $self ) ) {
139361µs if ( $INC{"Moose.pm"} ) {
1394 my $method = $self->moose_type->can( @_ );
1395 return sub { shift->moose_type->$method( @_ ) }
1396 if $method;
1397 }
1398614µs65µs if ( $_[0] =~ /\Amy_(.+)\z/ ) {
# spent 5µs making 6 calls to Type::Tiny::CORE:match, avg 833ns/call
1399 my $method = $self->_lookup_my_method( $1 );
1400 return $method if $method;
1401 }
140263µs if ( $self->{is_object} && $object_methods{ $_[0] } ) {
1403 require Type::Tiny::ConstrainedObject;
1404 return Type::Tiny::ConstrainedObject->can( $_[0] );
1405 }
140663µs for my $util ( qw/ grep map sort rsort first any all assert_any assert_all / ) {
14075411µs if ( $_[0] eq $util ) {
1408 $self->{'_util'}{$util} ||= eval { $self->_build_util( $util ) };
1409 return unless $self->{'_util'}{$util};
1410 return sub { my $s = shift; $s->{'_util'}{$util}( @_ ) };
1411 }
1412 }
1413 } #/ if ( ref( $self ) )
1414
1415610µs return;
1416} #/ sub can
1417
1418
# spent 460µs (83+377) within Type::Tiny::AUTOLOAD which was called 6 times, avg 77µs/call: # 3 times (41µs+287µs) by Types::Standard::Dict::__constraint_generator at line 44 of Types/Standard/Dict.pm, avg 109µs/call # 3 times (42µs+90µs) by Types::Standard::Dict::__inline_generator at line 90 of Types/Standard/Dict.pm, avg 44µs/call
sub AUTOLOAD {
141962µs my $self = shift;
1420643µs629µs my ( $m ) = ( our $AUTOLOAD =~ /::(\w+)$/ );
# spent 29µs making 6 calls to Type::Tiny::CORE:match, avg 5µs/call
142166µs return if $m eq 'DESTROY';
1422
142364µs if ( ref( $self ) ) {
142460s if ( $INC{"Moose.pm"} ) {
1425 my $method = $self->moose_type->can( $m );
1426 return $self->moose_type->$method( @_ ) if $method;
1427 }
1428618µs67µs if ( $m =~ /\Amy_(.+)\z/ ) {
# spent 7µs making 6 calls to Type::Tiny::CORE:match, avg 1µs/call
1429616µs6236µs my $method = $self->_lookup_my_method( $1 );
# spent 236µs making 6 calls to Type::Tiny::_lookup_my_method, avg 39µs/call
1430630µs6105µs return &$method( $self, @_ ) if $method;
# spent 105µs making 6 calls to Types::Standard::Slurpy::my_unslurpy, avg 18µs/call
1431 }
1432 if ( $self->{is_object} && $object_methods{$m} ) {
1433 require Type::Tiny::ConstrainedObject;
1434 unshift @_, $self;
143521.16ms250µs
# spent 36µs (22+14) within Type::Tiny::BEGIN@1435 which was called: # once (22µs+14µs) by Type::Library::BEGIN@16 at line 1435
no strict 'refs';
# spent 36µs making 1 call to Type::Tiny::BEGIN@1435 # spent 14µs making 1 call to strict::unimport
1436 goto \&{"Type::Tiny::ConstrainedObject::$m"};
1437 }
1438 for my $util ( qw/ grep map sort rsort first any all assert_any assert_all / ) {
1439 if ( $m eq $util ) {
1440 return ( $self->{'_util'}{$util} ||= $self->_build_util( $util ) )->( @_ );
1441 }
1442 }
1443 } #/ if ( ref( $self ) )
1444
1445 _croak q[Can't locate object method "%s" via package "%s"], $m,
1446 ref( $self ) || $self;
1447} #/ sub AUTOLOAD
1448
1449sub DOES {
1450 my $self = shift;
1451
1452 return !!1
1453 if ref( $self )
1454 && $_[0] =~ m{^ Type::API::Constraint (?: ::Coercible | ::Inlinable )? $}x;
1455 return !!1 if !ref( $self ) && $_[0] eq 'Type::API::Constraint::Constructor';
1456
1457 "UNIVERSAL"->can( "DOES" ) ? $self->SUPER::DOES( @_ ) : $self->isa( @_ );
1458} #/ sub DOES
1459
1460sub _has_xsub {
1461 require B;
1462 !!B::svref_2object( shift->compiled_check )->XSUB;
1463}
1464
1465sub _build_util {
1466 my ( $self, $func ) = @_;
1467 Scalar::Util::weaken( my $type = $self );
1468
1469 if ( $func eq 'grep'
1470 || $func eq 'first'
1471 || $func eq 'any'
1472 || $func eq 'all'
1473 || $func eq 'assert_any'
1474 || $func eq 'assert_all' )
1475 {
1476 my ( $inline, $compiled );
1477
1478 if ( $self->can_be_inlined ) {
1479 $inline = $self->inline_check( '$_' );
1480 }
1481 else {
1482 $compiled = $self->compiled_check;
1483 $inline = '$compiled->($_)';
1484 }
1485
1486 if ( $func eq 'grep' ) {
1487 return eval "sub { grep { $inline } \@_ }";
1488 }
1489 elsif ( $func eq 'first' ) {
1490 return eval "sub { for (\@_) { return \$_ if ($inline) }; undef; }";
1491 }
1492 elsif ( $func eq 'any' ) {
1493 return eval "sub { for (\@_) { return !!1 if ($inline) }; !!0; }";
1494 }
1495 elsif ( $func eq 'assert_any' ) {
1496 my $qname = B::perlstring( $self->name );
1497 return
1498 eval
1499 "sub { for (\@_) { return \@_ if ($inline) }; Type::Tiny::_failed_check(\$type, $qname, \@_ ? \$_[-1] : undef); }";
1500 }
1501 elsif ( $func eq 'all' ) {
1502 return eval "sub { for (\@_) { return !!0 unless ($inline) }; !!1; }";
1503 }
1504 elsif ( $func eq 'assert_all' ) {
1505 my $qname = B::perlstring( $self->name );
1506 return
1507 eval
1508 "sub { my \$idx = 0; for (\@_) { Type::Tiny::_failed_check(\$type, $qname, \$_, varname => sprintf('\$_[%d]', \$idx)) unless ($inline); ++\$idx }; \@_; }";
1509 }
1510 } #/ if ( $func eq 'grep' ||...)
1511
1512 if ( $func eq 'map' ) {
1513 my ( $inline, $compiled );
1514 my $c = $self->_assert_coercion;
1515
1516 if ( $c->can_be_inlined ) {
1517 $inline = $c->inline_coercion( '$_' );
1518 }
1519 else {
1520 $compiled = $c->compiled_coercion;
1521 $inline = '$compiled->($_)';
1522 }
1523
1524 return eval "sub { map { $inline } \@_ }";
1525 } #/ if ( $func eq 'map' )
1526
1527 if ( $func eq 'sort' || $func eq 'rsort' ) {
1528 my ( $inline, $compiled );
1529
1530 my $ptype = $self->find_parent( sub { $_->has_sorter } );
1531 _croak "No sorter for this type constraint" unless $ptype;
1532
1533 my $sorter = $ptype->sorter;
1534
1535 # Schwarzian transformation
1536 if ( ref( $sorter ) eq 'ARRAY' ) {
1537 my $sort_key;
1538 ( $sorter, $sort_key ) = @$sorter;
1539
1540 if ( $func eq 'sort' ) {
1541 return
1542 eval
1543 "our (\$a, \$b); sub { map \$_->[0], sort { \$sorter->(\$a->[1],\$b->[1]) } map [\$_,\$sort_key->(\$_)], \@_ }";
1544 }
1545 elsif ( $func eq 'rsort' ) {
1546 return
1547 eval
1548 "our (\$a, \$b); sub { map \$_->[0], sort { \$sorter->(\$b->[1],\$a->[1]) } map [\$_,\$sort_key->(\$_)], \@_ }";
1549 }
1550 } #/ if ( ref( $sorter ) eq...)
1551
1552 # Simple sort
1553 else {
1554 if ( $func eq 'sort' ) {
1555 return eval "our (\$a, \$b); sub { sort { \$sorter->(\$a,\$b) } \@_ }";
1556 }
1557 elsif ( $func eq 'rsort' ) {
1558 return eval "our (\$a, \$b); sub { sort { \$sorter->(\$b,\$a) } \@_ }";
1559 }
1560 }
1561 } #/ if ( $func eq 'sort' ||...)
1562
1563 die "Unknown function: $func";
1564} #/ sub _build_util
1565
1566315µs34.68ms
# spent 4.69ms (13µs+4.68) within Type::Tiny::of which was called 3 times, avg 1.56ms/call: # 3 times (13µs+4.68ms) by Types::Standard::slurpy at line 774 of Types/Standard.pm, avg 1.56ms/call
sub of { shift->parameterize( @_ ) }
# spent 4.68ms making 3 calls to Type::Tiny::parameterize, avg 1.56ms/call
1567551µs5935µs
# spent 955µs (20+935) within Type::Tiny::where which was called 5 times, avg 191µs/call: # once (4µs+267µs) by JSON::Schema::Modern::add_vocabulary at line 681 of JSON/Schema/Modern.pm # once (4µs+192µs) by OpenAPI::Modern::BEGIN@26 at line 897 of JSON/Schema/Modern.pm # once (5µs+176µs) by OpenAPI::Modern::BEGIN@26 at line 611 of JSON/Schema/Modern.pm # once (4µs+156µs) by JSON::Schema::Modern::BEGIN@35 at line 40 of JSON/Schema/Modern/Document.pm # once (3µs+144µs) by JSON::Schema::Modern::BEGIN@35 at line 79 of JSON/Schema/Modern/Document.pm
sub where { shift->create_child_type( constraint => @_ ) }
# spent 935µs making 5 calls to Type::Tiny::create_child_type, avg 187µs/call
1568
1569# fill out Moose-compatible API
1570sub inline_environment { +{} }
1571sub _inline_check { shift->inline_check( @_ ) }
1572sub _compiled_type_constraint { shift->compiled_check( @_ ) }
1573sub meta { _croak( "Not really a Moose::Meta::TypeConstraint. Sorry!" ) }
1574sub compile_type_constraint { shift->compiled_check }
1575sub _actually_compile_type_constraint { shift->_build_compiled_check }
1576sub hand_optimized_type_constraint { shift->{hand_optimized_type_constraint} }
1577
1578sub has_hand_optimized_type_constraint {
1579 exists( shift->{hand_optimized_type_constraint} );
1580}
158128µs24µs
# spent 15µs (11+4) within Type::Tiny::type_parameter which was called 2 times, avg 8µs/call: # 2 times (11µs+4µs) by Types::Standard::Slurpy::my_unslurpy at line 751 of Types/Standard.pm, avg 8µs/call
sub type_parameter { ( shift->parameters || [] )->[0] }
# spent 4µs making 2 calls to Type::Tiny::parameters, avg 2µs/call
1582
1583sub parameterized_from {
1584 $_[0]->is_parameterized ? shift->parent : _croak( "Not a parameterized type" );
1585}
1586sub has_parameterized_from { $_[0]->is_parameterized }
1587
1588# some stuff for Mouse-compatible API
1589sub __is_parameterized { shift->is_parameterized( @_ ) }
1590sub _add_type_coercions { shift->coercion->add_type_coercions( @_ ) }
1591sub _as_string { shift->qualified_name( @_ ) }
1592sub _compiled_type_coercion { shift->coercion->compiled_coercion( @_ ) }
1593sub _identity { Scalar::Util::refaddr( shift ) }
1594
1595sub _unite {
1596 require Type::Tiny::Union;
1597 "Type::Tiny::Union"->new( type_constraints => \@_ );
1598}
1599
1600# Hooks for Type::Tie
1601sub TIESCALAR {
1602 require Type::Tie;
1603 unshift @_, 'Type::Tie::SCALAR';
1604 goto \&Type::Tie::SCALAR::TIESCALAR;
1605}
1606
1607sub TIEARRAY {
1608 require Type::Tie;
1609 unshift @_, 'Type::Tie::ARRAY';
1610 goto \&Type::Tie::ARRAY::TIEARRAY;
1611}
1612
1613sub TIEHASH {
1614 require Type::Tie;
1615 unshift @_, 'Type::Tie::HASH';
1616 goto \&Type::Tie::HASH::TIEHASH;
1617}
1618
1619116µs1;
1620
1621__END__
 
# spent 1.65ms within Type::Tiny::CORE:match which was called 2032 times, avg 813ns/call: # 1012 times (696µs+0s) by Type::Tiny::inline_check at line 902, avg 688ns/call # 372 times (306µs+0s) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:100] at line 97, avg 823ns/call # 180 times (127µs+0s) by Type::Tiny::__ANON__[(eval 428)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 428)[Sub/Quote.pm:3], avg 706ns/call # 168 times (121µs+0s) by Type::Tiny::__ANON__[(eval 430)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 430)[Sub/Quote.pm:3], avg 720ns/call # 70 times (47µs+0s) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 24 of (eval 299)[Sub/Quote.pm:3], avg 671ns/call # 69 times (52µs+0s) by Type::Tiny::parameterize at line 1037, avg 754ns/call # 63 times (90µs+0s) by Type::Tiny::new at line 251, avg 1µs/call # 39 times (124µs+0s) by Type::Tiny::new at line 291, avg 3µs/call # 20 times (10µs+0s) by Type::Tiny::__ANON__[(eval 423)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 423)[Sub/Quote.pm:3], avg 500ns/call # 14 times (19µs+0s) by JSON::Schema::Modern::_assert__vocabulary_classes at line 24 of (eval 355)[Sub/Quote.pm:3], avg 1µs/call # 6 times (29µs+0s) by Type::Tiny::AUTOLOAD at line 1420, avg 5µs/call # 6 times (7µs+0s) by Type::Tiny::AUTOLOAD at line 1428, avg 1µs/call # 6 times (5µs+0s) by Type::Tiny::can at line 1398, avg 833ns/call # 3 times (4µs+0s) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 24 of (eval 360)[Sub/Quote.pm:3], avg 1µs/call # once (8µs+0s) by JSON::Schema::Modern::new at line 98 of (eval 416)[Sub/Quote.pm:3] # once (2µs+0s) by Type::Tiny::__ANON__[(eval 422)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:3]:16] at line 16 of (eval 422)[Sub/Quote.pm:3] # once (2µs+0s) by JSON::Schema::Modern::Result::new at line 99 of (eval 433)[Sub/Quote.pm:3] # once (2µs+0s) by JSON::Schema::Modern::new at line 106 of (eval 416)[Sub/Quote.pm:3]
sub Type::Tiny::CORE:match; # opcode
# spent 136µs within Type::Tiny::CORE:sort which was called 137 times, avg 993ns/call: # 73 times (106µs+0s) by Type::Tiny::inline_assert at line 935, avg 1µs/call # 64 times (30µs+0s) by Type::Tiny::inline_assert at line 947, avg 469ns/call
sub Type::Tiny::CORE:sort; # opcode
# spent 282µs (85+197) within Type::Tiny::CORE:subst which was called 33 times, avg 9µs/call: # 33 times (85µs+197µs) by Type::Tiny::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Type/Tiny.pm:524] at line 522, avg 9µs/call
sub Type::Tiny::CORE:subst; # opcode