← 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/Types/Standard.pm
StatementsExecuted 1309 statements in 14.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10119.98ms10.8msTypes::Standard::::__ANON__[:190] Types::Standard::__ANON__[:190]
1113.47ms26.0msTypes::Standard::::BEGIN@19 Types::Standard::BEGIN@19
4113.28ms3.78msTypes::Standard::::__ANON__[:1059] Types::Standard::__ANON__[:1059]
1112.38ms4.24msTypes::Standard::::BEGIN@7 Types::Standard::BEGIN@7
7112.15ms4.32msTypes::Standard::::__ANON__[:987] Types::Standard::__ANON__[:987]
1111.64ms1.89msTypes::Standard::::__ANON__[:1033] Types::Standard::__ANON__[:1033]
411348µs1.31msTypes::Standard::::__ANON__[:826] Types::Standard::__ANON__[:826]
111238µs312µsTypes::Standard::::BEGIN@30 Types::Standard::BEGIN@30
20201221µs22.4msTypes::Standard::::__ANON__[:127] Types::Standard::__ANON__[:127]
8111152µs152µsTypes::Standard::::__ANON__[:523] Types::Standard::__ANON__[:523]
5711114µs1.56msTypes::Standard::::__ANON__[:685] Types::Standard::__ANON__[:685]
381193µs93µsTypes::Standard::::__ANON__[:501] Types::Standard::__ANON__[:501]
381189µs89µsTypes::Standard::::__ANON__[:277] Types::Standard::__ANON__[:277]
761176µs76µsTypes::Standard::::__ANON__[:438] Types::Standard::__ANON__[:438]
231149µs49µsTypes::Standard::::__ANON__[:362] Types::Standard::__ANON__[:362]
399147µs47µsTypes::Standard::::LazyLoad Types::Standard::LazyLoad
21146µs248µsTypes::Standard::::__ANON__[:737] Types::Standard::__ANON__[:737]
141145µs45µsTypes::Standard::::__ANON__[:229] Types::Standard::__ANON__[:229]
61144µs105µsTypes::Standard::Slurpy::::my_unslurpyTypes::Standard::Slurpy::my_unslurpy
11143µs43µsTypes::Standard::::BEGIN@3 Types::Standard::BEGIN@3
81139µs65µsTypes::Standard::::__ANON__[:532] Types::Standard::__ANON__[:532]
31138µs71µsTypes::Standard::::__ANON__[:295] Types::Standard::__ANON__[:295]
115131µs31µsTypes::Standard::::__ANON__[:140] Types::Standard::__ANON__[:140]
261129µs29µsTypes::Standard::::__ANON__[:241] Types::Standard::__ANON__[:241]
21128µs148µsTypes::Standard::::__ANON__[:921] Types::Standard::__ANON__[:921]
21126µs60µsTypes::Standard::::__ANON__[:786] Types::Standard::__ANON__[:786]
33226µs4.71msTypes::Standard::::slurpy Types::Standard::slurpy
21124µs101µsTypes::Standard::::__ANON__[:945] Types::Standard::__ANON__[:945]
41119µs32µsTypes::Standard::::__ANON__[:510] Types::Standard::__ANON__[:510]
21116µs119µsTypes::Standard::::__ANON__[:328] Types::Standard::__ANON__[:328]
21116µs20µsTypes::Standard::::__ANON__[:456] Types::Standard::__ANON__[:456]
11116µs32µsTypes::Standard::::__ANON__[:678] Types::Standard::__ANON__[:678]
71115µs15µsTypes::Standard::::__ANON__[:384] Types::Standard::__ANON__[:384]
11114µs60µsTypes::Standard::::BEGIN@5 Types::Standard::BEGIN@5
41114µs14µsTypes::Standard::::CORE:sort Types::Standard::CORE:sort (opcode)
21114µs19µsTypes::Standard::::__ANON__[:488] Types::Standard::__ANON__[:488]
21114µs2.35msTypes::Standard::::__ANON__[:732] Types::Standard::__ANON__[:732]
51113µs13µsTypes::Standard::::__ANON__[:566] Types::Standard::__ANON__[:566]
11111µs38µsTypes::Standard::::BEGIN@194 Types::Standard::BEGIN@194
11110µs244µsTypes::Standard::::BEGIN@23 Types::Standard::BEGIN@23
51110µs10µsTypes::Standard::::__ANON__[:251] Types::Standard::__ANON__[:251]
41110µs10µsTypes::Standard::::__ANON__[:264] Types::Standard::__ANON__[:264]
21110µs10µsTypes::Standard::::__ANON__[:545] Types::Standard::__ANON__[:545]
21110µs14µsTypes::Standard::::__ANON__[:851] Types::Standard::__ANON__[:851]
1119µs9µsTypes::Standard::::BEGIN@12 Types::Standard::BEGIN@12
1118µs42µsTypes::Standard::::BEGIN@24 Types::Standard::BEGIN@24
1118µs13µsTypes::Standard::::BEGIN@4 Types::Standard::BEGIN@4
1118µs28µsTypes::Standard::::__ANON__[:686] Types::Standard::__ANON__[:686]
4117µs7µsTypes::Standard::::__ANON__[:348] Types::Standard::__ANON__[:348]
2116µs1.13msTypes::Standard::::__ANON__[:734] Types::Standard::__ANON__[:734]
2115µs5µsTypes::Standard::::__ANON__[:375] Types::Standard::__ANON__[:375]
1115µs8µsTypes::Standard::::__ANON__[:704] Types::Standard::__ANON__[:704]
2115µs8µsTypes::Standard::::__ANON__[:750] Types::Standard::__ANON__[:750]
1114µs4µsTypes::Standard::::BEGIN@196 Types::Standard::BEGIN@196
2114µs4µsTypes::Standard::::__ANON__[:470] Types::Standard::__ANON__[:470]
1113µs3µsTypes::Standard::::BEGIN@25 Types::Standard::BEGIN@25
1113µs3µsTypes::Standard::::BEGIN@26 Types::Standard::BEGIN@26
1113µs27µsTypes::Standard::::__ANON__[:661] Types::Standard::__ANON__[:661]
0000s0sTypes::Standard::Slurpy::::my_slurp_intoTypes::Standard::Slurpy::my_slurp_into
0000s0sTypes::Standard::::Stringable Types::Standard::Stringable
0000s0sTypes::Standard::::__ANON__[:1016] Types::Standard::__ANON__[:1016]
0000s0sTypes::Standard::::__ANON__[:1087] Types::Standard::__ANON__[:1087]
0000s0sTypes::Standard::::__ANON__[:1103] Types::Standard::__ANON__[:1103]
0000s0sTypes::Standard::::__ANON__[:123] Types::Standard::__ANON__[:123]
0000s0sTypes::Standard::::__ANON__[:161] Types::Standard::__ANON__[:161]
0000s0sTypes::Standard::::__ANON__[:206] Types::Standard::__ANON__[:206]
0000s0sTypes::Standard::::__ANON__[:208] Types::Standard::__ANON__[:208]
0000s0sTypes::Standard::::__ANON__[:215] Types::Standard::__ANON__[:215]
0000s0sTypes::Standard::::__ANON__[:226] Types::Standard::__ANON__[:226]
0000s0sTypes::Standard::::__ANON__[:230] Types::Standard::__ANON__[:230]
0000s0sTypes::Standard::::__ANON__[:240] Types::Standard::__ANON__[:240]
0000s0sTypes::Standard::::__ANON__[:242] Types::Standard::__ANON__[:242]
0000s0sTypes::Standard::::__ANON__[:250] Types::Standard::__ANON__[:250]
0000s0sTypes::Standard::::__ANON__[:263] Types::Standard::__ANON__[:263]
0000s0sTypes::Standard::::__ANON__[:274] Types::Standard::__ANON__[:274]
0000s0sTypes::Standard::::__ANON__[:278] Types::Standard::__ANON__[:278]
0000s0sTypes::Standard::::__ANON__[:279] Types::Standard::__ANON__[:279]
0000s0sTypes::Standard::::__ANON__[:287] Types::Standard::__ANON__[:287]
0000s0sTypes::Standard::::__ANON__[:296] Types::Standard::__ANON__[:296]
0000s0sTypes::Standard::::__ANON__[:297] Types::Standard::__ANON__[:297]
0000s0sTypes::Standard::::__ANON__[:316] Types::Standard::__ANON__[:316]
0000s0sTypes::Standard::::__ANON__[:329] Types::Standard::__ANON__[:329]
0000s0sTypes::Standard::::__ANON__[:330] Types::Standard::__ANON__[:330]
0000s0sTypes::Standard::::__ANON__[:345] Types::Standard::__ANON__[:345]
0000s0sTypes::Standard::::__ANON__[:349] Types::Standard::__ANON__[:349]
0000s0sTypes::Standard::::__ANON__[:370] Types::Standard::__ANON__[:370]
0000s0sTypes::Standard::::__ANON__[:383] Types::Standard::__ANON__[:383]
0000s0sTypes::Standard::::__ANON__[:397] Types::Standard::__ANON__[:397]
0000s0sTypes::Standard::::__ANON__[:398] Types::Standard::__ANON__[:398]
0000s0sTypes::Standard::::__ANON__[:407] Types::Standard::__ANON__[:407]
0000s0sTypes::Standard::::__ANON__[:408] Types::Standard::__ANON__[:408]
0000s0sTypes::Standard::::__ANON__[:425] Types::Standard::__ANON__[:425]
0000s0sTypes::Standard::::__ANON__[:433] Types::Standard::__ANON__[:433]
0000s0sTypes::Standard::::__ANON__[:439] Types::Standard::__ANON__[:439]
0000s0sTypes::Standard::::__ANON__[:449] Types::Standard::__ANON__[:449]
0000s0sTypes::Standard::::__ANON__[:457] Types::Standard::__ANON__[:457]
0000s0sTypes::Standard::::__ANON__[:465] Types::Standard::__ANON__[:465]
0000s0sTypes::Standard::::__ANON__[:481] Types::Standard::__ANON__[:481]
0000s0sTypes::Standard::::__ANON__[:496] Types::Standard::__ANON__[:496]
0000s0sTypes::Standard::::__ANON__[:506] Types::Standard::__ANON__[:506]
0000s0sTypes::Standard::::__ANON__[:518] Types::Standard::__ANON__[:518]
0000s0sTypes::Standard::::__ANON__[:528] Types::Standard::__ANON__[:528]
0000s0sTypes::Standard::::__ANON__[:544] Types::Standard::__ANON__[:544]
0000s0sTypes::Standard::::__ANON__[:550] Types::Standard::__ANON__[:550]
0000s0sTypes::Standard::::__ANON__[:558] Types::Standard::__ANON__[:558]
0000s0sTypes::Standard::::__ANON__[:601] Types::Standard::__ANON__[:601]
0000s0sTypes::Standard::::__ANON__[:604] Types::Standard::__ANON__[:604]
0000s0sTypes::Standard::::__ANON__[:621] Types::Standard::__ANON__[:621]
0000s0sTypes::Standard::::__ANON__[:622] Types::Standard::__ANON__[:622]
0000s0sTypes::Standard::::__ANON__[:634] Types::Standard::__ANON__[:634]
0000s0sTypes::Standard::::__ANON__[:639] Types::Standard::__ANON__[:639]
0000s0sTypes::Standard::::__ANON__[:640] Types::Standard::__ANON__[:640]
0000s0sTypes::Standard::::__ANON__[:643] Types::Standard::__ANON__[:643]
0000s0sTypes::Standard::::__ANON__[:677] Types::Standard::__ANON__[:677]
0000s0sTypes::Standard::::__ANON__[:696] Types::Standard::__ANON__[:696]
0000s0sTypes::Standard::::__ANON__[:701] Types::Standard::__ANON__[:701]
0000s0sTypes::Standard::::__ANON__[:725] Types::Standard::__ANON__[:725]
0000s0sTypes::Standard::::__ANON__[:745] Types::Standard::__ANON__[:745]
0000s0sTypes::Standard::::__ANON__[:752] Types::Standard::__ANON__[:752]
0000s0sTypes::Standard::::__ANON__[:756] Types::Standard::__ANON__[:756]
0000s0sTypes::Standard::::__ANON__[:767] Types::Standard::__ANON__[:767]
0000s0sTypes::Standard::::__ANON__[:801] Types::Standard::__ANON__[:801]
0000s0sTypes::Standard::::__ANON__[:843] Types::Standard::__ANON__[:843]
0000s0sTypes::Standard::::__ANON__[:868] Types::Standard::__ANON__[:868]
0000s0sTypes::Standard::::__ANON__[:869] Types::Standard::__ANON__[:869]
0000s0sTypes::Standard::::__ANON__[:881] Types::Standard::__ANON__[:881]
0000s0sTypes::Standard::::__ANON__[:882] Types::Standard::__ANON__[:882]
0000s0sTypes::Standard::::__ANON__[:907] Types::Standard::__ANON__[:907]
0000s0sTypes::Standard::::__ANON__[:922] Types::Standard::__ANON__[:922]
0000s0sTypes::Standard::::__ANON__[:937] Types::Standard::__ANON__[:937]
0000s0sTypes::Standard::::__ANON__[:956] Types::Standard::__ANON__[:956]
0000s0sTypes::Standard::::_croak Types::Standard::_croak
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Types::Standard;
2
32140µs143µs
# spent 43µs within Types::Standard::BEGIN@3 which was called: # once (43µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 3
use 5.008001;
# spent 43µs making 1 call to Types::Standard::BEGIN@3
4261µs218µs
# spent 13µs (8+5) within Types::Standard::BEGIN@4 which was called: # once (8µs+5µs) by JSON::Schema::Modern::BEGIN@31 at line 4
use strict;
# spent 13µs making 1 call to Types::Standard::BEGIN@4 # spent 5µs making 1 call to strict::import
5295µs2106µs
# spent 60µs (14+46) within Types::Standard::BEGIN@5 which was called: # once (14µs+46µs) by JSON::Schema::Modern::BEGIN@31 at line 5
use warnings;
# spent 60µs making 1 call to Types::Standard::BEGIN@5 # spent 46µs making 1 call to warnings::import
6
7
# spent 4.24ms (2.38+1.86) within Types::Standard::BEGIN@7 which was called: # once (2.38ms+1.86ms) by JSON::Schema::Modern::BEGIN@31 at line 10
BEGIN {
82436µs eval { require re };
917µs if ( $] < 5.010 ) { require Devel::TypeTiny::Perl58Compat }
10179µs14.24ms}
# spent 4.24ms making 1 call to Types::Standard::BEGIN@7
11
12
# spent 9µs within Types::Standard::BEGIN@12 which was called: # once (9µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 15
BEGIN {
1310s $Types::Standard::AUTHORITY = 'cpan:TOBYINK';
1413µs $Types::Standard::VERSION = '2.000001';
15158µs19µs}
# spent 9µs making 1 call to Types::Standard::BEGIN@12
16
1712µs$Types::Standard::VERSION =~ tr/_//d;
18
192932µs226.1ms
# spent 26.0ms (3.47+22.5) within Types::Standard::BEGIN@19 which was called: # once (3.47ms+22.5ms) by JSON::Schema::Modern::BEGIN@31 at line 19
use Type::Library -base;
# spent 26.0ms making 1 call to Types::Standard::BEGIN@19 # spent 143µs making 1 call to Exporter::Tiny::import
20
2112µsour @EXPORT_OK = qw( slurpy );
22
23236µs2478µs
# spent 244µs (10+234) within Types::Standard::BEGIN@23 which was called: # once (10µs+234µs) by JSON::Schema::Modern::BEGIN@31 at line 23
use Eval::TypeTiny qw( set_subname );
# spent 244µs making 1 call to Types::Standard::BEGIN@23 # spent 234µs making 1 call to Exporter::Tiny::import
24223µs276µs
# spent 42µs (8+34) within Types::Standard::BEGIN@24 which was called: # once (8µs+34µs) by JSON::Schema::Modern::BEGIN@31 at line 24
use Scalar::Util qw( blessed looks_like_number );
# spent 42µs making 1 call to Types::Standard::BEGIN@24 # spent 34µs making 1 call to Exporter::import
25216µs13µs
# spent 3µs within Types::Standard::BEGIN@25 which was called: # once (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 25
use Type::Tiny ();
# spent 3µs making 1 call to Types::Standard::BEGIN@25
262124µs13µs
# spent 3µs within Types::Standard::BEGIN@26 which was called: # once (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 26
use Types::TypeTiny ();
# spent 3µs making 1 call to Types::Standard::BEGIN@26
27
2810smy $is_class_loaded;
29
30
# spent 312µs (238+74) within Types::Standard::BEGIN@30 which was called: # once (238µs+74µs) by JSON::Schema::Modern::BEGIN@31 at line 60
BEGIN {
3110s $is_class_loaded = q{sub {
32 no strict 'refs';
33 return !!0 if ref $_[0];
34 return !!0 if not $_[0];
35 return !!0 if ref(do { my $tmpstr = $_[0]; \$tmpstr }) ne 'SCALAR';
36 my $stash = \%{"$_[0]\::"};
37 return !!1 if exists($stash->{'ISA'}) && *{$stash->{'ISA'}}{ARRAY} && @{$_[0].'::ISA'};
38 return !!1 if exists($stash->{'VERSION'});
39 foreach my $globref (values %$stash) {
40 return !!1
41 if ref \$globref eq 'GLOB'
42 ? *{$globref}{CODE}
43 : ref $globref; # const or sub ref
44 }
45 return !!0;
46 }};
47
48145µs *_is_class_loaded =
# spent 2.76ms executing statements in string eval
# includes 2.21ms spent executing 557 calls to 2 subs defined therein.
49 Type::Tiny::_USE_XS
50 ? \&Type::Tiny::XS::Util::is_class_loaded
51 : eval $is_class_loaded;
52
53 *_HAS_REFUTILXS = eval {
5410s require Ref::Util::XS;
55129µs117µs Ref::Util::XS::->VERSION( 0.100 );
# spent 17µs making 1 call to UNIVERSAL::VERSION
5610s 1;
57 }
58 ? sub () { !!1 }
5914µs : sub () { !!0 };
601664µs1312µs} #/ BEGIN
# spent 312µs making 1 call to Types::Standard::BEGIN@30
61
62
# spent 22.4ms (221µs+22.2) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:127] which was called 20 times, avg 1.12ms/call: # once (18µs+5.26ms) by JSON::Schema::Modern::BEGIN@31 at line 210 # once (15µs+1.22ms) by JSON::Schema::Modern::BEGIN@31 at line 552 # once (12µs+1.09ms) by JSON::Schema::Modern::BEGIN@31 at line 567 # once (7µs+1.01ms) by JSON::Schema::Modern::BEGIN@31 at line 512 # once (10µs+1.01ms) by JSON::Schema::Modern::BEGIN@31 at line 472 # once (15µs+987µs) by JSON::Schema::Modern::BEGIN@31 at line 533 # once (11µs+960µs) by JSON::Schema::Modern::BEGIN@31 at line 427 # once (10µs+939µs) by JSON::Schema::Modern::BEGIN@31 at line 351 # once (11µs+917µs) by JSON::Schema::Modern::BEGIN@31 at line 232 # once (10µs+890µs) by JSON::Schema::Modern::BEGIN@31 at line 490 # once (12µs+878µs) by JSON::Schema::Modern::BEGIN@31 at line 645 # once (10µs+849µs) by JSON::Schema::Modern::BEGIN@31 at line 266 # once (8µs+835µs) by JSON::Schema::Modern::BEGIN@31 at line 459 # once (9µs+833µs) by JSON::Schema::Modern::BEGIN@31 at line 663 # once (12µs+794µs) by JSON::Schema::Modern::BEGIN@31 at line 244 # once (9µs+783µs) by JSON::Schema::Modern::BEGIN@31 at line 252 # once (8µs+766µs) by JSON::Schema::Modern::BEGIN@31 at line 281 # once (16µs+742µs) by JSON::Schema::Modern::BEGIN@31 at line 216 # once (11µs+746µs) by JSON::Schema::Modern::BEGIN@31 at line 787 # once (7µs+676µs) by JSON::Schema::Modern::BEGIN@31 at line 441
my $add_core_type = sub {
632011µs my $meta = shift;
642015µs my ( $typedef ) = @_;
65
66207µs my $name = $typedef->{name};
67206µs my ( $xsub, $xsubname );
68
69 # We want Map and Tuple to be XSified, even if they're not
70 # really core.
712021µs $typedef->{_is_core} = 1
72 unless $name eq 'Map' || $name eq 'Tuple';
73
742040µs2037µs if ( Type::Tiny::_USE_XS
# spent 37µs making 20 calls to Type::Tiny::__ANON__[Type/Tiny.pm:55], avg 2µs/call
75 and not( $name eq 'RegexpRef' ) )
76 {
77 $xsub = Type::Tiny::XS::get_coderef_for( $name );
78 $xsubname = Type::Tiny::XS::get_subname_for( $name );
79 }
80
81 elsif ( Type::Tiny::_USE_MOUSE
82 and not( $name eq 'RegexpRef' or $name eq 'Int' or $name eq 'Object' ) )
83 {
84 require Mouse::Util::TypeConstraints;
85 $xsub = "Mouse::Util::TypeConstraints"->can( $name );
86 $xsubname = "Mouse::Util::TypeConstraints::$name" if $xsub;
87 }
88
89 if ( Type::Tiny::_USE_XS
90 and Type::Tiny::XS->VERSION < 0.014
91 and $name eq 'Bool' )
92 {
93 # Broken implementation of Bool
94 $xsub = $xsubname = undef;
95 }
96
97 if ( Type::Tiny::_USE_XS
98 and ( Type::Tiny::XS->VERSION < 0.016 or $] < 5.018 )
99 and $name eq 'Int' )
100 {
101 # Broken implementation of Int
102 $xsub = $xsubname = undef;
103 }
104
105203µs $typedef->{compiled_type_constraint} = $xsub if $xsub;
106
107206µs my $orig_inlined = $typedef->{inlined};
108204µs if (
109 defined( $xsubname ) and (
110
111 # These should be faster than their normal inlined
112 # equivalents
113 $name eq 'Str'
114 or $name eq 'Bool'
115 or $name eq 'ClassName'
116 or $name eq 'RegexpRef'
117 or $name eq 'FileHandle'
118 )
119 )
120 {
121 $typedef->{inlined} = sub {
122 $Type::Tiny::AvoidCallbacks ? goto( $orig_inlined ) : "$xsubname\($_[1])";
123 };
124 } #/ if ( defined( $xsubname...))
125
12620106µs2022.1ms $meta->add_type( $typedef );
# spent 22.1ms making 20 calls to Type::Library::add_type, avg 1.11ms/call
12714µs};
128
129
# spent 31µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:140] which was called 11 times, avg 3µs/call: # 3 times (11µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] at line 289, avg 4µs/call # 2 times (7µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] at line 940, avg 4µs/call # 2 times (5µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:488] at line 483, avg 2µs/call # 2 times (4µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:456] at line 452, avg 2µs/call # 2 times (4µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] at line 847, avg 2µs/call
my $maybe_load_modules = sub {
130115µs my $code = pop;
131112µs if ( $Type::Tiny::AvoidCallbacks ) {
132 $code = sprintf(
133 'do { %s %s; %s }',
134 $Type::Tiny::SafePackage,
135 join( '; ', map "use $_ ()", @_ ),
136 $code,
137 );
138 }
1391138µs $code;
14012µs};
141
142sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
143
144110µs137µsmy $meta = __PACKAGE__->meta;
# spent 37µs making 1 call to Type::Library::meta
145
146# Stringable and LazyLoad are optimizations that complicate
147# this module somewhat, but they have led to performance
148# improvements. If Types::Standard wasn't such a key type
149# library, I wouldn't use them. I strongly discourage anybody
150# from using them in their own code. If you're looking for
151# examples of how to write a type library sanely, you're
152# better off looking at the code for Types::Common::Numeric
153# and Types::Common::String.
154
155{
156
15712µs sub Stringable (&) {
158 bless +{ code => $_[0] }, 'Types::Standard::_Stringable';
159 }
160 Types::Standard::_Stringable->Type::Tiny::_install_overloads(
16115µs125µs q[""] => sub { $_[0]{text} ||= $_[0]{code}->() } );
# spent 25µs making 1 call to Type::Tiny::_install_overloads
162
163
# spent 47µs within Types::Standard::LazyLoad which was called 39 times, avg 1µs/call: # 7 times (4µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 827, avg 571ns/call # 6 times (7µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 663, avg 1µs/call # 6 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 533, avg 833ns/call # 4 times (7µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 787, avg 2µs/call # 4 times (6µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 512, avg 2µs/call # 4 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 552, avg 1µs/call # 4 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 802, avg 1µs/call # 2 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 957, avg 2µs/call # 2 times (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 887, avg 2µs/call
sub LazyLoad ($$) {
1643986µs bless \@_, 'Types::Standard::LazyLoad';
165 }
166 'Types::Standard::LazyLoad'->Type::Tiny::_install_overloads(
167
# spent 10.8ms (9.98+825µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] which was called 10 times, avg 1.08ms/call: # 10 times (9.98ms+825µs) by Type::Tiny::parameterize or Types::Standard::ArrayRef::__constraint_generator or Types::Standard::Dict::__constraint_generator or Types::Standard::HashRef::__constraint_generator or Types::Standard::Map::__constraint_generator or Types::Standard::Tuple::__constraint_generator at line 1044 of Type/Tiny.pm, avg 1.08ms/call
q[&{}] => sub {
1681011µs my ( $typename, $function ) = @{ $_[0] };
1691032µs10106µs my $type = $meta->get_type( $typename );
# spent 106µs making 10 calls to Type::Library::get_type, avg 11µs/call
170102µs my $class = "Types::Standard::$typename";
17110328µs eval "require $class; 1" or die( $@ );
# spent 505µs executing statements in 2 string evals (merged) # spent 479µs executing statements in 2 string evals (merged) # spent 435µs executing statements in 2 string evals (merged) # spent 427µs executing statements in 2 string evals (merged) # spent 405µs executing statements in 2 string evals (merged)
172
173 # Majorly break encapsulation for Type::Tiny :-O
1741051µs for my $key ( keys %$type ) {
17517871µs next unless ref( $type->{$key} ) eq 'Types::Standard::LazyLoad';
1762014µs my $f = $type->{$key}[1];
17720109µs2022µs $type->{$key} = $class->can( "__$f" );
# spent 22µs making 20 calls to UNIVERSAL::can, avg 1µs/call
178 }
179108µs my $mm = $type->{my_methods} || {};
180107µs for my $key ( keys %$mm ) {
181148µs next unless ref( $mm->{$key} ) eq 'Types::Standard::LazyLoad';
18272µs my $f = $mm->{$key}[1];
183724µs77µs $mm->{$key} = $class->can( "__$f" );
# spent 7µs making 7 calls to UNIVERSAL::can, avg 1µs/call
184 set_subname(
185 sprintf( "%s::my_%s", $type->qualified_name, $key ),
186724µs1490µs $mm->{$key},
# spent 58µs making 7 calls to Eval::TypeTiny::set_subname, avg 8µs/call # spent 32µs making 7 calls to Type::Tiny::qualified_name, avg 5µs/call
187 );
188 } #/ for my $key ( keys %$mm)
1891063µs108µs return $class->can( "__$function" );
# spent 8µs making 10 calls to UNIVERSAL::can, avg 800ns/call
190 },
19114µs18µs );
# spent 8µs making 1 call to Type::Tiny::_install_overloads
192}
193
194258µs265µs
# spent 38µs (11+27) within Types::Standard::BEGIN@194 which was called: # once (11µs+27µs) by JSON::Schema::Modern::BEGIN@31 at line 194
no warnings;
# spent 38µs making 1 call to Types::Standard::BEGIN@194 # spent 27µs making 1 call to warnings::unimport
195
196
# spent 4µs within Types::Standard::BEGIN@196 which was called: # once (4µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 201
BEGIN {
197 *STRICTNUM =
198 $ENV{PERL_TYPES_STANDARD_STRICTNUM}
199 ? sub() { !!1 }
200 : sub() { !!0 }
20115.98ms14µs}
# spent 4µs making 1 call to Types::Standard::BEGIN@196
202
203my $_any = $meta->$add_core_type(
204 {
205 name => "Any",
206 inlined => sub { "!!1" },
207 complement_name => 'None',
208 type_default => sub { return undef; },
209 }
21018µs15.28ms);
# spent 5.28ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
211
212my $_item = $meta->$add_core_type(
213 {
214 name => "Item",
215 inlined => sub { "!!1" },
21616µs1758µs parent => $_any,
# spent 758µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
217 }
218);
219
220my $_bool = $meta->$add_core_type(
221 {
222 name => "Bool",
223 parent => $_item,
224 constraint => sub {
225 !ref $_ and ( !defined $_ or $_ eq q() or $_ eq '0' or $_ eq '1' );
226 },
227
# spent 45µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:229] which was called 14 times, avg 3µs/call: # 14 times (45µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 3µs/call
inlined => sub {
2281432µs "!ref $_[1] and (!defined $_[1] or $_[1] eq q() or $_[1] eq '0' or $_[1] eq '1')";
229 },
230 type_default => sub { return !!0; },
231 }
23219µs1928µs);
# spent 928µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
233
23414µs24.59ms$_bool->coercion->add_type_coercions( $_any, q{!!$_} );
# spent 3.97ms making 1 call to Type::Tiny::coercion # spent 617µs making 1 call to Type::Coercion::add_type_coercions
235
236my $_undef = $meta->$add_core_type(
237 {
238 name => "Undef",
239 parent => $_item,
240 constraint => sub { !defined $_ },
2412653µs
# spent 29µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:241] which was called 26 times, avg 1µs/call: # 26 times (29µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µs/call
inlined => sub { "!defined($_[1])" },
242 type_default => sub { return undef; },
243 }
24419µs1806µs);
# spent 806µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
245
246my $_def = $meta->$add_core_type(
247 {
248 name => "Defined",
249 parent => $_item,
250 constraint => sub { defined $_ },
251513µs
# spent 10µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:251] which was called 5 times, avg 2µs/call: # 5 times (10µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub { "defined($_[1])" },
25216µs1792µs complementary_type => $_undef,
# spent 792µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
253 }
254);
255
256# hackish, but eh
25716µs11µsScalar::Util::weaken( $_undef->{complementary_type} ||= $_def );
# spent 1µs making 1 call to Scalar::Util::weaken
258
259my $_val = $meta->$add_core_type(
260 {
261 name => "Value",
262 parent => $_def,
263 constraint => sub { not ref $_ },
264411µs
# spent 10µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:264] which was called 4 times, avg 2µs/call: # 4 times (10µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub { "defined($_[1]) and not ref($_[1])" },
265 }
26617µs1859µs);
# spent 859µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
267
268my $_str = $meta->$add_core_type(
269 {
270 name => "Str",
271 parent => $_val,
272 constraint => sub {
273 ref( \$_ ) eq 'SCALAR' or ref( \( my $val = $_ ) ) eq 'SCALAR';
274 },
275
# spent 89µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:277] which was called 38 times, avg 2µs/call: # 38 times (89µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
27638105µs "defined($_[1]) and do { ref(\\$_[1]) eq 'SCALAR' or ref(\\(my \$val = $_[1])) eq 'SCALAR' }";
277 },
278 sorter => sub { $_[0] cmp $_[1] },
279 type_default => sub { return ''; },
280 }
28119µs1774µs);
# spent 774µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
282
283my $_laxnum = $meta->add_type(
284 {
285 name => "LaxNum",
286 parent => $_str,
287 constraint => sub { looks_like_number( $_ ) and ref( \$_ ) ne 'GLOB' },
288
# spent 71µs (38+33) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] which was called 3 times, avg 24µs/call: # 3 times (38µs+33µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 24µs/call
inlined => sub {
289360µs633µs $maybe_load_modules->(
# spent 22µs making 3 calls to UNIVERSAL::VERSION, avg 7µs/call # spent 11µs making 3 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 4µs/call
290 qw/ Scalar::Util /,
291 'Scalar::Util'->VERSION ge '1.18' # RT 132426
292 ? "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1])"
293 : "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1]) && ref(\\($_[1])) ne 'GLOB'"
294 );
295 },
296 sorter => sub { $_[0] <=> $_[1] },
297 type_default => sub { return 0; },
298 }
299111µs1974µs);
# spent 974µs making 1 call to Type::Library::add_type
300
301my $_strictnum = $meta->add_type(
302 {
303 name => "StrictNum",
304 parent => $_str,
305 constraint => sub {
306 my $val = $_;
307 ( $val =~ /\A[+-]?[0-9]+\z/ )
308 || (
309 $val =~ /\A(?:[+-]?) #matches optional +- in the beginning
310 (?=[0-9]|\.[0-9]) #matches previous +- only if there is something like 3 or .3
311 [0-9]* #matches 0-9 zero or more times
312 (?:\.[0-9]+)? #matches optional .89 or nothing
313 (?:[Ee](?:[+-]?[0-9]+))? #matches E1 or e1 or e-1 or e+1 etc
314 \z/x
315 );
316 },
317
# spent 119µs (16+103) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:328] which was called 2 times, avg 60µs/call: # 2 times (16µs+103µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 60µs/call
inlined => sub {
318213µs46µs 'my $val = '
# spent 6µs making 2 calls to Types::Standard::Value, avg 3µs/call # spent 97µs making 2 calls to Type::Tiny::inline_check, avg 48µs/call, recursion: max depth 1, sum of overlapping time 97µs
319 . $_[1] . ';'
320 . Value()->inline_check( '$val' )
321 . ' && ( $val =~ /\A[+-]?[0-9]+\z/ || '
322 . '$val =~ /\A(?:[+-]?) # matches optional +- in the beginning
323 (?=[0-9]|\.[0-9]) # matches previous +- only if there is something like 3 or .3
324 [0-9]* # matches 0-9 zero or more times
325 (?:\.[0-9]+)? # matches optional .89 or nothing
326 (?:[Ee](?:[+-]?[0-9]+))? # matches E1 or e1 or e-1 or e+1 etc
327 \z/x ); '
328 },
329 sorter => sub { $_[0] <=> $_[1] },
330 type_default => sub { return 0; },
331 }
332110µs11.48ms);
# spent 1.48ms making 1 call to Type::Library::add_type
333
33414µs1926µsmy $_num = $meta->add_type(
# spent 926µs making 1 call to Type::Library::add_type
335 {
336 name => "Num",
337 parent => ( STRICTNUM ? $_strictnum : $_laxnum ),
338 }
339);
340
341$meta->$add_core_type(
342 {
343 name => "Int",
344 parent => $_num,
345 constraint => sub { /\A-?[0-9]+\z/ },
346
# spent 7µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:348] which was called 4 times, avg 2µs/call: # 4 times (7µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
347410µs "do { my \$tmp = $_[1]; defined(\$tmp) and !ref(\$tmp) and \$tmp =~ /\\A-?[0-9]+\\z/ }";
348 },
349 type_default => sub { return 0; },
350 }
35119µs1949µs);
# spent 949µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
352
353my $_classn = $meta->add_type(
354 {
355 name => "ClassName",
356 parent => $_str,
357 constraint => \&_is_class_loaded,
358
# spent 49µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:362] which was called 23 times, avg 2µs/call: # 23 times (49µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
3592359µs $Type::Tiny::AvoidCallbacks
360 ? "($is_class_loaded)->(do { my \$tmp = $_[1] })"
361 : "Types::Standard::_is_class_loaded(do { my \$tmp = $_[1] })";
362 },
363 }
364112µs11.43ms);
# spent 1.43ms making 1 call to Type::Library::add_type
365
366$meta->add_type(
367 {
368 name => "RoleName",
369 parent => $_classn,
370 constraint => sub { not $_->can( "new" ) },
371
# spent 5µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:375] which was called 2 times, avg 2µs/call: # 2 times (5µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
37227µs $Type::Tiny::AvoidCallbacks
373 ? "($is_class_loaded)->(do { my \$tmp = $_[1] }) and not $_[1]\->can('new')"
374 : "Types::Standard::_is_class_loaded(do { my \$tmp = $_[1] }) and not $_[1]\->can('new')";
375 },
376 }
37719µs1865µs);
# spent 865µs making 1 call to Type::Library::add_type
378
379my $_ref = $meta->$add_core_type(
380 {
381 name => "Ref",
382 parent => $_def,
383 constraint => sub { ref $_ },
384719µs
# spent 15µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:384] which was called 7 times, avg 2µs/call: # 7 times (15µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub { "!!ref($_[1])" },
385 constraint_generator => sub {
386 return $meta->get_type( 'Ref' ) unless @_;
387
388 my $reftype = shift;
389 $reftype =~
390 /^(SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE|FORMAT|IO|VSTRING|REGEXP|Regexp)$/i
391 or _croak(
392 "Parameter to Ref[`a] expected to be a Perl ref type; got $reftype" );
393
394 $reftype = "$reftype";
395 return sub {
396 ref( $_[0] ) and Scalar::Util::reftype( $_[0] ) eq $reftype;
397 }
398 },
399 inline_generator => sub {
400 my $reftype = shift;
401 return sub {
402 my $v = $_[1];
403 $maybe_load_modules->(
404 qw/ Scalar::Util /,
405 "ref($v) and Scalar::Util::reftype($v) eq q($reftype)"
406 );
407 };
408 },
409 deep_explanation => sub {
410 require B;
411 my ( $type, $value, $varname ) = @_;
412 my $param = $type->parameters->[0];
413 return if $type->check( $value );
414 my $reftype = Scalar::Util::reftype( $value );
415 return [
416 sprintf(
417 '"%s" constrains reftype(%s) to be equal to %s', $type, $varname,
418 B::perlstring( $param )
419 ),
420 sprintf(
421 'reftype(%s) is %s', $varname,
422 defined( $reftype ) ? B::perlstring( $reftype ) : "undef"
423 ),
424 ];
425 },
426 }
427112µs1971µs);
# spent 971µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
428
429$meta->$add_core_type(
430 {
431 name => "CodeRef",
432 parent => $_ref,
433 constraint => sub { ref $_ eq "CODE" },
434
# spent 76µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:438] which was called 76 times, avg 1µs/call: # 76 times (76µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µs/call
inlined => sub {
43576155µs _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks
436 ? "Ref::Util::XS::is_plain_coderef($_[1])"
437 : "ref($_[1]) eq 'CODE'";
438 },
439 type_default => sub { return sub {}; },
440 }
44117µs1683µs);
# spent 683µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
442
443my $_regexp = $meta->$add_core_type(
444 {
445 name => "RegexpRef",
446 parent => $_ref,
447 constraint => sub {
448 ref( $_ ) && !!re::is_regexp( $_ ) or blessed( $_ ) && $_->isa( 'Regexp' );
449 },
450
# spent 20µs (16+4) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:456] which was called 2 times, avg 10µs/call: # 2 times (16µs+4µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 10µs/call
inlined => sub {
45120s my $v = $_[1];
452211µs24µs $maybe_load_modules->(
# spent 4µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µs/call
453 qw/ Scalar::Util re /,
454 "ref($v) && !!re::is_regexp($v) or Scalar::Util::blessed($v) && $v\->isa('Regexp')"
455 );
456 },
457 type_default => sub { return qr//; },
458 }
45919µs1843µs);
# spent 843µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
460
461$meta->$add_core_type(
462 {
463 name => "GlobRef",
464 parent => $_ref,
465 constraint => sub { ref $_ eq "GLOB" },
466
# spent 4µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:470] which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
46725µs _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks
468 ? "Ref::Util::XS::is_plain_globref($_[1])"
469 : "ref($_[1]) eq 'GLOB'";
470 },
471 }
47216µs11.02ms);
# spent 1.02ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
473
474$meta->$add_core_type(
475 {
476 name => "FileHandle",
477 parent => $_ref,
478 constraint => sub {
479 ( ref( $_ ) && Scalar::Util::openhandle( $_ ) )
480 or ( blessed( $_ ) && $_->isa( "IO::Handle" ) );
481 },
482
# spent 19µs (14+5) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:488] which was called 2 times, avg 10µs/call: # 2 times (14µs+5µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 10µs/call
inlined => sub {
483211µs25µs $maybe_load_modules->(
# spent 5µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µs/call
484 qw/ Scalar::Util /,
485 "(ref($_[1]) && Scalar::Util::openhandle($_[1])) "
486 . "or (Scalar::Util::blessed($_[1]) && $_[1]\->isa(\"IO::Handle\"))"
487 );
488 },
489 }
49018µs1900µs);
# spent 900µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
491
492my $_arr = $meta->$add_core_type(
493 {
494 name => "ArrayRef",
495 parent => $_ref,
496 constraint => sub { ref $_ eq "ARRAY" },
497
# spent 93µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:501] which was called 38 times, avg 2µs/call: # 38 times (93µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
49838144µs _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks
499 ? "Ref::Util::XS::is_plain_arrayref($_[1])"
500 : "ref($_[1]) eq 'ARRAY'";
501 },
502 constraint_generator => LazyLoad( ArrayRef => 'constraint_generator' ),
503 inline_generator => LazyLoad( ArrayRef => 'inline_generator' ),
504 deep_explanation => LazyLoad( ArrayRef => 'deep_explanation' ),
505 coercion_generator => LazyLoad( ArrayRef => 'coercion_generator' ),
506 type_default => sub { return []; },
507
# spent 32µs (19+13) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:510] which was called 4 times, avg 8µs/call: # 4 times (19µs+13µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 8µs/call
type_default_generator => sub {
508418µs413µs return $Type::Tiny::parameterize_type->type_default if @_ < 2;
# spent 13µs making 4 calls to Type::Tiny::type_default, avg 3µs/call
509 return undef;
510 },
511 }
512119µs51.02ms);
# spent 1.02ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 6µs making 4 calls to Types::Standard::LazyLoad, avg 2µs/call
513
514my $_hash = $meta->$add_core_type(
515 {
516 name => "HashRef",
517 parent => $_ref,
518 constraint => sub { ref $_ eq "HASH" },
519
# spent 152µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:523] which was called 81 times, avg 2µs/call: # 81 times (152µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
52081196µs _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks
521 ? "Ref::Util::XS::is_plain_hashref($_[1])"
522 : "ref($_[1]) eq 'HASH'";
523 },
524 constraint_generator => LazyLoad( HashRef => 'constraint_generator' ),
525 inline_generator => LazyLoad( HashRef => 'inline_generator' ),
526 deep_explanation => LazyLoad( HashRef => 'deep_explanation' ),
527 coercion_generator => LazyLoad( HashRef => 'coercion_generator' ),
528 type_default => sub { return {}; },
529
# spent 65µs (39+26) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:532] which was called 8 times, avg 8µs/call: # 8 times (39µs+26µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 8µs/call
type_default_generator => sub {
530830µs826µs return $Type::Tiny::parameterize_type->type_default if @_ < 2;
# spent 26µs making 8 calls to Type::Tiny::type_default, avg 3µs/call
531 return undef;
532 },
533123µs71.01ms my_methods => {
# spent 1.00ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 5µs making 6 calls to Types::Standard::LazyLoad, avg 833ns/call
534 hashref_allows_key => LazyLoad( HashRef => 'hashref_allows_key' ),
535 hashref_allows_value => LazyLoad( HashRef => 'hashref_allows_value' ),
536 },
537 }
538);
539
540$meta->$add_core_type(
541 {
542 name => "ScalarRef",
543 parent => $_ref,
544 constraint => sub { ref $_ eq "SCALAR" or ref $_ eq "REF" },
5452107µs
# spent 10µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:545] which was called 2 times, avg 5µs/call: # 2 times (10µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 5µs/call
inlined => sub { "ref($_[1]) eq 'SCALAR' or ref($_[1]) eq 'REF'" },
546 constraint_generator => LazyLoad( ScalarRef => 'constraint_generator' ),
547 inline_generator => LazyLoad( ScalarRef => 'inline_generator' ),
548 deep_explanation => LazyLoad( ScalarRef => 'deep_explanation' ),
549 coercion_generator => LazyLoad( ScalarRef => 'coercion_generator' ),
550 type_default => sub { my $x; return \$x; },
551 }
552115µs51.24ms);
# spent 1.24ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 5µs making 4 calls to Types::Standard::LazyLoad, avg 1µs/call
553
554my $_obj = $meta->$add_core_type(
555 {
556 name => "Object",
557 parent => $_ref,
558 constraint => sub { blessed $_ },
559
# spent 13µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:566] which was called 5 times, avg 3µs/call: # 5 times (13µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 3µs/call
inlined => sub {
560516µs _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks
561 ? "Ref::Util::XS::is_blessed_ref($_[1])"
562 : $maybe_load_modules->(
563 'Scalar::Util',
564 "Scalar::Util::blessed($_[1])"
565 );
566 },
56718µs11.10ms is_object => 1,
# spent 1.10ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
568 }
569);
570
571$meta->$add_core_type(
572 {
573 name => "Maybe",
574 parent => $_item,
575 constraint_generator => sub {
576 return $meta->get_type( 'Maybe' ) unless @_;
577
578 my $param = Types::TypeTiny::to_TypeTiny( shift );
579 Types::TypeTiny::is_TypeTiny( $param )
580 or _croak(
581 "Parameter to Maybe[`a] expected to be a type constraint; got $param" );
582
583 my $param_compiled_check = $param->compiled_check;
584 my @xsub;
585 if ( Type::Tiny::_USE_XS ) {
586 my $paramname = Type::Tiny::XS::is_known( $param_compiled_check );
587 push @xsub, Type::Tiny::XS::get_coderef_for( "Maybe[$paramname]" )
588 if $paramname;
589 }
590 elsif ( Type::Tiny::_USE_MOUSE and $param->_has_xsub ) {
591 require Mouse::Util::TypeConstraints;
592 my $maker = "Mouse::Util::TypeConstraints"->can( "_parameterize_Maybe_for" );
593 push @xsub, $maker->( $param ) if $maker;
594 }
595
596 return (
597 sub {
598 my $value = shift;
599 return !!1 unless defined $value;
600 return $param->check( $value );
601 },
602 @xsub,
603 );
604 },
605 inline_generator => sub {
606 my $param = shift;
607
608 my $param_compiled_check = $param->compiled_check;
609 my $xsubname;
610 if ( Type::Tiny::_USE_XS ) {
611 my $paramname = Type::Tiny::XS::is_known( $param_compiled_check );
612 $xsubname = Type::Tiny::XS::get_subname_for( "Maybe[$paramname]" );
613 }
614
615 return unless $param->can_be_inlined;
616 return sub {
617 my $v = $_[1];
618 return "$xsubname\($v\)" if $xsubname && !$Type::Tiny::AvoidCallbacks;
619 my $param_check = $param->inline_check( $v );
620 "!defined($v) or $param_check";
621 };
622 },
623 deep_explanation => sub {
624 my ( $type, $value, $varname ) = @_;
625 my $param = $type->parameters->[0];
626
627 return [
628 sprintf( '%s is defined', Type::Tiny::_dd( $value ) ),
629 sprintf(
630 '"%s" constrains the value with "%s" if it is defined', $type, $param
631 ),
632 @{ $param->validate_explain( $value, $varname ) },
633 ];
634 },
635 coercion_generator => sub {
636 my ( $parent, $child, $param ) = @_;
637 return unless $param->has_coercion;
638 return $param->coercion;
639 },
640 type_default => sub { return undef; },
641 type_default_generator => sub {
642 $_[0]->type_default || $Type::Tiny::parameterize_type->type_default ;
643 },
644 }
645117µs1890µs);
# spent 890µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
646
647my $_map = $meta->$add_core_type(
648 {
649 name => "Map",
650 parent => $_hash,
651 constraint_generator => LazyLoad( Map => 'constraint_generator' ),
652 inline_generator => LazyLoad( Map => 'inline_generator' ),
653 deep_explanation => LazyLoad( Map => 'deep_explanation' ),
654 coercion_generator => LazyLoad( Map => 'coercion_generator' ),
655 my_methods => {
656 hashref_allows_key => LazyLoad( Map => 'hashref_allows_key' ),
657 hashref_allows_value => LazyLoad( Map => 'hashref_allows_value' ),
658 },
659
# spent 27µs (3+24) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:661] which was called: # once (3µs+24µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm
type_default_generator => sub {
66015µs124µs return $Type::Tiny::parameterize_type->type_default;
# spent 24µs making 1 call to Type::Tiny::type_default
661 },
662 }
663114µs7849µs);
# spent 842µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 7µs making 6 calls to Types::Standard::LazyLoad, avg 1µs/call
664
665my $_Optional = $meta->add_type(
666 {
667 name => "Optional",
668 parent => $_item,
669
# spent 32µs (16+16) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:678] which was called: # once (16µs+16µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm
constraint_generator => sub {
67011µs return $meta->get_type( 'Optional' ) unless @_;
671
67211µs14µs my $param = Types::TypeTiny::to_TypeTiny( shift );
# spent 4µs making 1 call to Types::TypeTiny::to_TypeTiny
67311µs112µs Types::TypeTiny::is_TypeTiny( $param )
# spent 12µs making 1 call to Types::TypeTiny::is_TypeTiny
674 or _croak(
675 "Parameter to Optional[`a] expected to be a type constraint; got $param" );
676
677 sub { $param->check( $_[0] ) }
67816µs },
679
# spent 28µs (8+20) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:686] which was called: # once (8µs+20µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm
inline_generator => sub {
68010s my $param = shift;
68112µs120µs return unless $param->can_be_inlined;
# spent 20µs making 1 call to Type::Tiny::can_be_inlined
682
# spent 1.56ms (114µs+1.44) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:685] which was called 57 times, avg 27µs/call: # 57 times (114µs+1.44ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 27µs/call
return sub {
683578µs my $v = $_[1];
6845783µs570s $param->inline_check( $v );
# spent 1.44ms making 57 calls to Type::Tiny::inline_check, avg 25µs/call, recursion: max depth 2, sum of overlapping time 1.44ms
68515µs };
686 },
687 deep_explanation => sub {
688 my ( $type, $value, $varname ) = @_;
689 my $param = $type->parameters->[0];
690
691 return [
692 sprintf( '%s exists', $varname ),
693 sprintf( '"%s" constrains %s with "%s" if it exists', $type, $varname, $param ),
694 @{ $param->validate_explain( $value, $varname ) },
695 ];
696 },
697 coercion_generator => sub {
698 my ( $parent, $child, $param ) = @_;
699 return unless $param->has_coercion;
700 return $param->coercion;
701 },
702
# spent 8µs (5+3) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:704] which was called: # once (5µs+3µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm
type_default_generator => sub {
70314µs13µs return $_[0]->type_default;
# spent 3µs making 1 call to Type::Tiny::type_default
704 },
705 }
706111µs1770µs);
# spent 770µs making 1 call to Type::Library::add_type
707
70810smy $_slurpy;
709$_slurpy = $meta->add_type(
710 {
711 name => "Slurpy",
712 slurpy => 1,
713 parent => $_item,
714
# spent 248µs (46+202) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] which was called 2 times, avg 124µs/call: # 2 times (46µs+202µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 124µs/call
constraint_generator => sub {
71520s my $self = $_slurpy;
71621µs24µs my $param = @_ ? Types::TypeTiny::to_TypeTiny(shift) : $_any;
# spent 4µs making 2 calls to Types::TypeTiny::to_TypeTiny, avg 2µs/call
71723µs223µs Types::TypeTiny::is_TypeTiny( $param )
# spent 23µs making 2 calls to Types::TypeTiny::is_TypeTiny, avg 12µs/call
718 or _croak(
719 "Parameter to Slurpy[`a] expected to be a type constraint; got $param" );
720
721 return $self->create_child_type(
722 slurpy => 1,
723 display_name => $self->name_generator->( $self, $param ),
724 parameters => [ $param ],
725 constraint => sub { $param->check( $_[0] ) },
726 type_default => $param->type_default,
727
# spent 2.35ms (14µs+2.33) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:732] which was called 2 times, avg 1.17ms/call: # 2 times (14µs+2.33ms) by Type::Tiny::_build_coercion at line 504 of Type/Tiny.pm, avg 1.17ms/call
_build_coercion => sub {
72821µs my $coercion = shift;
72923µs22.33ms $coercion->add_type_coercions( @{ $param->coercion->type_coercion_map } )
# spent 2.33ms making 2 calls to Type::Tiny::has_coercion, avg 1.17ms/call
730 if $param->has_coercion;
73127µs21µs $coercion->freeze;
# spent 1µs making 2 calls to Type::Coercion::freeze, avg 500ns/call
732 },
733 $param->can_be_inlined
73425µs20s
# spent 1.13ms (6µs+1.13) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:734] which was called 2 times, avg 566µs/call: # 2 times (6µs+1.13ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 566µs/call
? ( inlined => sub { $param->inline_check( $_[1] ) } )
# spent 1.12ms making 2 calls to Type::Tiny::inline_check, avg 562µs/call, recursion: max depth 1, sum of overlapping time 1.12ms
735223µs10175µs : (),
# spent 83µs making 2 calls to Type::Tiny::create_child_type, avg 42µs/call # spent 60µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:524], avg 30µs/call # spent 26µs making 2 calls to Type::Tiny::can_be_inlined, avg 13µs/call # spent 4µs making 2 calls to Type::Tiny::name_generator, avg 2µs/call # spent 2µs making 2 calls to Type::Tiny::type_default, avg 1µs/call
736 );
737 },
738 deep_explanation => sub {
739 my ( $type, $value, $varname ) = @_;
740 my $param = $type->parameters->[0];
741 return [
742 sprintf( '%s is slurpy', $varname ),
743 @{ $param->validate_explain( $value, $varname ) },
744 ];
745 },
746 my_methods => {
747
# spent 105µs (44+61) within Types::Standard::Slurpy::my_unslurpy which was called 6 times, avg 18µs/call: # 6 times (44µs+61µs) by Type::Tiny::AUTOLOAD at line 1430 of Type/Tiny.pm, avg 18µs/call
'unslurpy' => sub {
74863µs my $self = shift;
749 $self->{_my_unslurpy} ||= $self->find_parent(
75026µs23µs
# spent 8µs (5+3) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:750] which was called 2 times, avg 4µs/call: # 2 times (5µs+3µs) by Type::Tiny::find_parent at line 744 of Type/Tiny.pm, avg 4µs/call
sub { $_->parent->{uniq} == $_slurpy->{uniq} }
# spent 3µs making 2 calls to Type::Tiny::parent, avg 2µs/call
751638µs861µs )->type_parameter;
# spent 41µs making 2 calls to Type::Tiny::find_parent, avg 20µs/call # spent 15µs making 2 calls to Type::Tiny::type_parameter, avg 8µs/call # spent 5µs making 4 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 1µs/call
752 },
753 'slurp_into' => sub {
754 my $self = shift;
755 my $parameters = $self->find_parent(
756 sub { $_->parent->{uniq} == $_slurpy->{uniq} }
757 )->parameters;
758 if ( $parameters->[1] ) {
759 return $parameters->[1];
760 }
761 my $constraint = $parameters->[0];
762 return 'HASH'
763 if $constraint->is_a_type_of( HashRef() )
764 or $constraint->is_a_type_of( Map() )
765 or $constraint->is_a_type_of( Dict() );
766 return 'ARRAY';
767 },
768 },
769 }
770116µs1891µs);
# spent 891µs making 1 call to Type::Library::add_type
771
772
# spent 4.71ms (26µs+4.69) within Types::Standard::slurpy which was called 3 times, avg 1.57ms/call: # once (6µs+3.96ms) by OpenAPI::Modern::BEGIN@26 at line 122 of JSON/Schema/Modern.pm # once (13µs+672µs) by JSON::Schema::Modern::BEGIN@35 at line 79 of JSON/Schema/Modern/Document.pm # once (7µs+53µs) by OpenAPI::Modern::BEGIN@26 at line 611 of JSON/Schema/Modern.pm
sub slurpy {
77331µs my $t = shift;
77438µs34.69ms my $s = $_slurpy->of( $t );
# spent 4.69ms making 3 calls to Type::Tiny::of, avg 1.56ms/call
77531µs $s->{slurpy} ||= 1;
776311µs wantarray ? ( $s, @_ ) : $s;
777}
778
779$meta->$add_core_type(
780 {
781 name => "Tuple",
782 parent => $_arr,
783
# spent 60µs (26+34) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:786] which was called 2 times, avg 30µs/call: # 2 times (26µs+34µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 30µs/call
name_generator => sub {
78422µs my ( $s, @a ) = @_;
785216µs634µs sprintf( '%s[%s]', $s, join q[,], @a );
# spent 34µs making 6 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 6µs/call
786 },
787112µs5764µs constraint_generator => LazyLoad( Tuple => 'constraint_generator' ),
# spent 757µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 7µs making 4 calls to Types::Standard::LazyLoad, avg 2µs/call
788 inline_generator => LazyLoad( Tuple => 'inline_generator' ),
789 deep_explanation => LazyLoad( Tuple => 'deep_explanation' ),
790 coercion_generator => LazyLoad( Tuple => 'coercion_generator' ),
791 }
792);
793
794$meta->add_type(
795 {
796 name => "CycleTuple",
797 parent => $_arr,
798 name_generator => sub {
799 my ( $s, @a ) = @_;
800 sprintf( '%s[%s]', $s, join q[,], @a );
801 },
802111µs5712µs constraint_generator => LazyLoad( CycleTuple => 'constraint_generator' ),
# spent 707µs making 1 call to Type::Library::add_type # spent 5µs making 4 calls to Types::Standard::LazyLoad, avg 1µs/call
803 inline_generator => LazyLoad( CycleTuple => 'inline_generator' ),
804 deep_explanation => LazyLoad( CycleTuple => 'deep_explanation' ),
805 coercion_generator => LazyLoad( CycleTuple => 'coercion_generator' ),
806 }
807);
808
809$meta->add_type(
810 {
811 name => "Dict",
812 parent => $_hash,
813
# spent 1.31ms (348µs+964µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] which was called 4 times, avg 328µs/call: # 4 times (348µs+964µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 328µs/call
name_generator => sub {
814412µs my ( $s, @p ) = @_;
815424µs12752µs my $l = @p
# spent 672µs making 4 calls to Type::Tiny::is_strictly_a_type_of, avg 168µs/call # spent 57µs making 4 calls to Types::TypeTiny::is_TypeTiny, avg 14µs/call # spent 23µs making 4 calls to Types::Standard::Slurpy, avg 6µs/call
816 && Types::TypeTiny::is_TypeTiny( $p[-1] )
817 && $p[-1]->is_strictly_a_type_of( Types::Standard::Slurpy() )
818 ? pop(@p)
819 : undef;
820423µs my %a = @p;
821 sprintf(
822 '%s[%s%s]', $s,
8234219µs46212µs join( q[,], map sprintf( "%s=>%s", $_, $a{$_} ), sort keys %a ),
# spent 196µs making 39 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 5µs/call # spent 14µs making 4 calls to Types::Standard::CORE:sort, avg 4µs/call # spent 2µs making 3 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 667ns/call
824 $l ? ",$l" : ''
825 );
826 },
827119µs8901µs constraint_generator => LazyLoad( Dict => 'constraint_generator' ),
# spent 897µs making 1 call to Type::Library::add_type # spent 4µs making 7 calls to Types::Standard::LazyLoad, avg 571ns/call
828 inline_generator => LazyLoad( Dict => 'inline_generator' ),
829 deep_explanation => LazyLoad( Dict => 'deep_explanation' ),
830 coercion_generator => LazyLoad( Dict => 'coercion_generator' ),
831 my_methods => {
832 dict_is_slurpy => LazyLoad( Dict => 'dict_is_slurpy' ),
833 hashref_allows_key => LazyLoad( Dict => 'hashref_allows_key' ),
834 hashref_allows_value => LazyLoad( Dict => 'hashref_allows_value' ),
835 },
836 }
837);
838
839$meta->add_type(
840 {
841 name => "Overload",
842 parent => $_obj,
843 constraint => sub { require overload; overload::Overloaded( $_ ) },
844
# spent 14µs (10+4) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] which was called 2 times, avg 7µs/call: # 2 times (10µs+4µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 7µs/call
inlined => sub {
845 $maybe_load_modules->(
846 qw/ Scalar::Util overload /,
847212µs24µs $INC{'overload.pm'}
# spent 4µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µs/call
848 ? "Scalar::Util::blessed($_[1]) and overload::Overloaded($_[1])"
849 : "Scalar::Util::blessed($_[1]) and do { use overload (); overload::Overloaded($_[1]) }"
850 );
851 },
852 constraint_generator => sub {
853 return $meta->get_type( 'Overload' ) unless @_;
854
855 my @operations = map {
856 Types::TypeTiny::is_StringLike( $_ )
857 ? "$_"
858 : _croak( "Parameters to Overload[`a] expected to be a strings; got $_" );
859 } @_;
860
861 require overload;
862 return sub {
863 my $value = shift;
864 for my $op ( @operations ) {
865 return unless overload::Method( $value, $op );
866 }
867 return !!1;
868 }
869 },
870 inline_generator => sub {
871 my @operations = @_;
872 return sub {
873 require overload;
874 my $v = $_[1];
875 $maybe_load_modules->(
876 qw/ Scalar::Util overload /,
877 join " and ",
878 "Scalar::Util::blessed($v)",
879 map "overload::Method($v, q[$_])", @operations
880 );
881 };
882 },
883111µs1832µs is_object => 1,
# spent 832µs making 1 call to Type::Library::add_type
884 }
885);
886
88717µs3767µs$meta->add_type(
# spent 764µs making 1 call to Type::Library::add_type # spent 3µs making 2 calls to Types::Standard::LazyLoad, avg 2µs/call
888 {
889 name => "StrMatch",
890 parent => $_str,
891 constraint_generator => LazyLoad( StrMatch => 'constraint_generator' ),
892 inline_generator => LazyLoad( StrMatch => 'inline_generator' ),
893 }
894);
895
896$meta->add_type(
897 {
898 name => "OptList",
899 parent => $_arr,
900 constraint => sub {
901 for my $inner ( @$_ ) {
902 return unless ref( $inner ) eq q(ARRAY);
903 return unless @$inner == 2;
904 return unless is_Str( $inner->[0] );
905 }
906 return !!1;
907 },
908
# spent 148µs (28+120) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:921] which was called 2 times, avg 74µs/call: # 2 times (28µs+120µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 74µs/call
inlined => sub {
90921µs my ( $self, $var ) = @_;
91025µs44µs my $Str_check = Str()->inline_check( '$inner->[0]' );
# spent 4µs making 2 calls to Types::Standard::Str, avg 2µs/call # spent 116µs making 2 calls to Type::Tiny::inline_check, avg 58µs/call, recursion: max depth 1, sum of overlapping time 116µs
91121µs my @code = 'do { my $ok = 1; ';
91222µs push @code, sprintf( 'for my $inner (@{%s}) { no warnings; ', $var );
91321µs push @code,
914 sprintf(
915 '($ok=0) && last unless ref($inner) eq q(ARRAY) && @$inner == 2 && (%s); ',
916 $Str_check
917 );
91821µs push @code, '} ';
91921µs push @code, '$ok }';
92029µs return ( undef, join( q( ), @code ) );
921 },
922 type_default => sub { return [] },
923 }
92418µs11.18ms);
# spent 1.18ms making 1 call to Type::Library::add_type
925
926$meta->add_type(
927 {
928 name => "Tied",
929 parent => $_ref,
930 constraint => sub {
931 !!tied(
932 Scalar::Util::reftype( $_ ) eq 'HASH' ? %{$_}
933 : Scalar::Util::reftype( $_ ) eq 'ARRAY' ? @{$_}
934 : Scalar::Util::reftype( $_ ) =~ /^(SCALAR|REF)$/ ? ${$_}
935 : undef
936 );
937 },
938
# spent 101µs (24+77) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] which was called 2 times, avg 50µs/call: # 2 times (24µs+77µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 50µs/call
inlined => sub {
93920s my ( $self, $var ) = @_;
940220µs67µs $maybe_load_modules->(
# spent 7µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 4µs/call # spent 70µs making 2 calls to Type::Tiny::inline_check, avg 35µs/call, recursion: max depth 1, sum of overlapping time 70µs # spent 0s making 2 calls to Type::Tiny::parent, avg 0s/call
941 qw/ Scalar::Util /,
942 $self->parent->inline_check( $var )
943 . " and !!tied(Scalar::Util::reftype($var) eq 'HASH' ? \%{$var} : Scalar::Util::reftype($var) eq 'ARRAY' ? \@{$var} : Scalar::Util::reftype($var) =~ /^(SCALAR|REF)\$/ ? \${$var} : undef)"
944 );
945 },
946 name_generator => sub {
947 my $self = shift;
948 my $param = Types::TypeTiny::to_TypeTiny( shift );
949 unless ( Types::TypeTiny::is_TypeTiny( $param ) ) {
950 Types::TypeTiny::is_StringLike( $param )
951 or _croak( "Parameter to Tied[`a] expected to be a class name; got $param" );
952 require B;
953 return sprintf( "%s[%s]", $self, B::perlstring( $param ) );
954 }
955 return sprintf( "%s[%s]", $self, $param );
956 },
957114µs31.27ms constraint_generator => LazyLoad( Tied => 'constraint_generator' ),
# spent 1.26ms making 1 call to Type::Library::add_type # spent 5µs making 2 calls to Types::Standard::LazyLoad, avg 2µs/call
958 inline_generator => LazyLoad( Tied => 'inline_generator' ),
959 }
960);
961
962$meta->add_type(
963 {
964 name => "InstanceOf",
965 parent => $_obj,
966
# spent 4.32ms (2.15+2.17) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:987] which was called 7 times, avg 617µs/call: # 7 times (2.15ms+2.17ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 617µs/call
constraint_generator => sub {
96775µs return $meta->get_type( 'InstanceOf' ) unless @_;
9687676µs require Type::Tiny::Class;
969 my @classes = map {
9701467µs21619µs Types::TypeTiny::is_TypeTiny( $_ )
# spent 547µs making 7 calls to Type::Tiny::Class::new, avg 78µs/call # spent 63µs making 7 calls to Types::TypeTiny::is_TypeTiny, avg 9µs/call # spent 9µs making 7 calls to B::perlstring, avg 1µs/call
971 ? $_
972 : "Type::Tiny::Class"->new(
973 class => $_,
974 display_name => sprintf( 'InstanceOf[%s]', B::perlstring( $_ ) )
975 )
976 } @_;
977719µs return $classes[0] if @classes == 1;
978
979 require B;
980 require Type::Tiny::Union;
981 return "Type::Tiny::Union"->new(
982 type_constraints => \@classes,
983 display_name => sprintf(
984 'InstanceOf[%s]', join q[,], map B::perlstring( $_->class ), @classes
985 ),
986 );
987 },
988 }
98916µs1948µs);
# spent 948µs making 1 call to Type::Library::add_type
990
991$meta->add_type(
992 {
993 name => "ConsumerOf",
994 parent => $_obj,
995 constraint_generator => sub {
996 return $meta->get_type( 'ConsumerOf' ) unless @_;
997 require B;
998 require Type::Tiny::Role;
999 my @roles = map {
1000 Types::TypeTiny::is_TypeTiny( $_ )
1001 ? $_
1002 : "Type::Tiny::Role"->new(
1003 role => $_,
1004 display_name => sprintf( 'ConsumerOf[%s]', B::perlstring( $_ ) )
1005 )
1006 } @_;
1007 return $roles[0] if @roles == 1;
1008
1009 require Type::Tiny::Intersection;
1010 return "Type::Tiny::Intersection"->new(
1011 type_constraints => \@roles,
1012 display_name => sprintf(
1013 'ConsumerOf[%s]', join q[,], map B::perlstring( $_->role ), @roles
1014 ),
1015 );
1016 },
1017 }
101817µs1956µs);
# spent 956µs making 1 call to Type::Library::add_type
1019
1020$meta->add_type(
1021 {
1022 name => "HasMethods",
1023 parent => $_obj,
1024
# spent 1.89ms (1.64+252µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1033] which was called: # once (1.64ms+252µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm
constraint_generator => sub {
102511µs return $meta->get_type( 'HasMethods' ) unless @_;
102611µs require B;
10271544µs require Type::Tiny::Duck;
1028120µs3112µs return "Type::Tiny::Duck"->new(
# spent 108µs making 1 call to Type::Tiny::Duck::new # spent 4µs making 2 calls to B::perlstring, avg 2µs/call
1029 methods => \@_,
1030 display_name =>
1031 sprintf( 'HasMethods[%s]', join q[,], map B::perlstring( $_ ), @_ ),
1032 );
1033 },
1034 }
103516µs1604µs);
# spent 604µs making 1 call to Type::Library::add_type
1036
1037$meta->add_type(
1038 {
1039 name => "Enum",
1040 parent => $_str,
1041
# spent 3.78ms (3.28+501µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1059] which was called 4 times, avg 945µs/call: # 4 times (3.28ms+501µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 945µs/call
constraint_generator => sub {
104241µs return $meta->get_type( 'Enum' ) unless @_;
104347µs my $coercion;
1044421µs42µs if ( ref( $_[0] ) and ref( $_[0] ) eq 'SCALAR' ) {
# spent 2µs making 4 calls to Scalar::Util::blessed, avg 500ns/call
1045 $coercion = ${ +shift };
1046 }
1047 elsif ( ref( $_[0] ) && !blessed( $_[0] )
1048 or blessed( $_[0] ) && $_[0]->isa( 'Type::Coercion' ) )
1049 {
1050 $coercion = shift;
1051 }
105243µs require B;
10534477µs require Type::Tiny::Enum;
1054489µs22330µs return "Type::Tiny::Enum"->new(
# spent 314µs making 4 calls to Type::Tiny::Enum::new, avg 78µs/call # spent 16µs making 18 calls to B::perlstring, avg 889ns/call
1055 values => \@_,
1056 display_name => sprintf( 'Enum[%s]', join q[,], map B::perlstring( $_ ), @_ ),
1057 $coercion ? ( coercion => $coercion ) : (),
1058 );
1059 },
106015µs1485µs type_default => undef,
# spent 485µs making 1 call to Type::Library::add_type
1061 }
1062);
1063
1064113µs2336µs$meta->add_coercion(
# spent 330µs making 1 call to Type::Library::add_coercion # spent 6µs making 1 call to Type::Library::get_type
1065 {
1066 name => "MkOpt",
1067 type_constraint => $meta->get_type( "OptList" ),
1068 type_coercion_map => [
1069 $_arr, q{ Exporter::Tiny::mkopt($_) },
1070 $_hash, q{ Exporter::Tiny::mkopt($_) },
1071 $_undef, q{ [] },
1072 ],
1073 }
1074);
1075
1076$meta->add_coercion(
1077 {
1078 name => "Join",
1079 type_constraint => $_str,
1080 coercion_generator => sub {
1081 my ( $self, $target, $sep ) = @_;
1082 Types::TypeTiny::is_StringLike( $sep )
1083 or _croak( "Parameter to Join[`a] expected to be a string; got $sep" );
1084 require B;
1085 $sep = B::perlstring( $sep );
1086 return ( ArrayRef(), qq{ join($sep, \@\$_) } );
1087 },
1088 }
108915µs1169µs);
# spent 169µs making 1 call to Type::Library::add_coercion
1090
1091$meta->add_coercion(
1092 {
1093 name => "Split",
1094 type_constraint => $_arr,
1095 coercion_generator => sub {
1096 my ( $self, $target, $re ) = @_;
1097 ref( $re ) eq q(Regexp)
1098 or _croak(
1099 "Parameter to Split[`a] expected to be a regular expresssion; got $re" );
1100 my $regexp_string = "$re";
1101 $regexp_string =~ s/\\\//\\\\\//g; # toothpicks
1102 return ( Str(), qq{ [split /$regexp_string/, \$_] } );
1103 },
1104 }
110512µs1158µs);
# spent 158µs making 1 call to Type::Library::add_coercion
1106
110713µs21.63ms__PACKAGE__->meta->make_immutable;
# spent 1.63ms making 1 call to Type::Library::make_immutable # spent 2µs making 1 call to Type::Library::meta
1108
1109186µs1;
1110
1111__END__
 
# spent 14µs within Types::Standard::CORE:sort which was called 4 times, avg 4µs/call: # 4 times (14µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] at line 823, avg 4µs/call
sub Types::Standard::CORE:sort; # opcode