← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Thu Dec 15 15:23:56 2022
Reported on Thu Dec 15 15:27:02 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm
StatementsExecuted 1293 statements in 10.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10119.84ms10.7msTypes::Standard::::__ANON__[:190] Types::Standard::__ANON__[:190]
1112.89ms19.2msTypes::Standard::::BEGIN@19 Types::Standard::BEGIN@19
4112.50ms2.89msTypes::Standard::::__ANON__[:1059] Types::Standard::__ANON__[:1059]
7111.84ms3.56msTypes::Standard::::__ANON__[:987] Types::Standard::__ANON__[:987]
1111.59ms5.71msTypes::Standard::::BEGIN@7 Types::Standard::BEGIN@7
1111.42ms1.64msTypes::Standard::::__ANON__[:1033] Types::Standard::__ANON__[:1033]
411171µs665µsTypes::Standard::::__ANON__[:826] Types::Standard::__ANON__[:826]
111123µs142µsTypes::Standard::::BEGIN@30 Types::Standard::BEGIN@30
5711117µs1.39msTypes::Standard::::__ANON__[:685] Types::Standard::__ANON__[:685]
20201116µs17.3msTypes::Standard::::__ANON__[:127] Types::Standard::__ANON__[:127]
811190µs90µsTypes::Standard::::__ANON__[:523] Types::Standard::__ANON__[:523]
351175µs75µsTypes::Standard::::__ANON__[:277] Types::Standard::__ANON__[:277]
761175µs75µsTypes::Standard::::__ANON__[:438] Types::Standard::__ANON__[:438]
381159µs59µsTypes::Standard::::__ANON__[:501] Types::Standard::__ANON__[:501]
231145µs45µsTypes::Standard::::__ANON__[:362] Types::Standard::__ANON__[:362]
21142µs182µsTypes::Standard::::__ANON__[:737] Types::Standard::__ANON__[:737]
81133µs52µsTypes::Standard::::__ANON__[:532] Types::Standard::__ANON__[:532]
61132µs69µsTypes::Standard::Slurpy::::my_unslurpyTypes::Standard::Slurpy::my_unslurpy
261128µs28µsTypes::Standard::::__ANON__[:241] Types::Standard::__ANON__[:241]
21122µs27µsTypes::Standard::::__ANON__[:456] Types::Standard::__ANON__[:456]
399121µs21µsTypes::Standard::::LazyLoad Types::Standard::LazyLoad
131121µs21µsTypes::Standard::::__ANON__[:229] Types::Standard::__ANON__[:229]
11120µs20µsTypes::Standard::::BEGIN@3 Types::Standard::BEGIN@3
31119µs30µsTypes::Standard::::__ANON__[:295] Types::Standard::__ANON__[:295]
115117µs17µsTypes::Standard::::__ANON__[:140] Types::Standard::__ANON__[:140]
21117µs41µsTypes::Standard::::__ANON__[:786] Types::Standard::__ANON__[:786]
21115µs104µsTypes::Standard::::__ANON__[:921] Types::Standard::__ANON__[:921]
21115µs67µsTypes::Standard::::__ANON__[:945] Types::Standard::__ANON__[:945]
41113µs26µsTypes::Standard::::__ANON__[:510] Types::Standard::__ANON__[:510]
11113µs24µsTypes::Standard::::__ANON__[:678] Types::Standard::__ANON__[:678]
21110µs53µsTypes::Standard::::__ANON__[:328] Types::Standard::__ANON__[:328]
71110µs10µsTypes::Standard::::__ANON__[:384] Types::Standard::__ANON__[:384]
21110µs1.47msTypes::Standard::::__ANON__[:732] Types::Standard::__ANON__[:732]
5119µs9µsTypes::Standard::::__ANON__[:251] Types::Standard::__ANON__[:251]
2119µs12µsTypes::Standard::::__ANON__[:851] Types::Standard::__ANON__[:851]
4118µs8µsTypes::Standard::::CORE:sort Types::Standard::CORE:sort (opcode)
4117µs7µsTypes::Standard::::__ANON__[:348] Types::Standard::__ANON__[:348]
1117µs19µsTypes::Standard::::__ANON__[:686] Types::Standard::__ANON__[:686]
1116µs35µsTypes::Standard::::BEGIN@24 Types::Standard::BEGIN@24
2116µs8µsTypes::Standard::::__ANON__[:488] Types::Standard::__ANON__[:488]
2116µs686µsTypes::Standard::::__ANON__[:734] Types::Standard::__ANON__[:734]
1115µs5µsTypes::Standard::::BEGIN@12 Types::Standard::BEGIN@12
1115µs18µsTypes::Standard::::BEGIN@194 Types::Standard::BEGIN@194
1115µs156µsTypes::Standard::::BEGIN@23 Types::Standard::BEGIN@23
1115µs7µsTypes::Standard::::BEGIN@4 Types::Standard::BEGIN@4
1115µs22µsTypes::Standard::::__ANON__[:661] Types::Standard::__ANON__[:661]
2115µs7µsTypes::Standard::::__ANON__[:750] Types::Standard::__ANON__[:750]
4114µs4µsTypes::Standard::::__ANON__[:264] Types::Standard::__ANON__[:264]
1113µs3µsTypes::Standard::::BEGIN@25 Types::Standard::BEGIN@25
1113µs30µsTypes::Standard::::BEGIN@5 Types::Standard::BEGIN@5
2113µs3µsTypes::Standard::::__ANON__[:375] Types::Standard::__ANON__[:375]
5113µs3µsTypes::Standard::::__ANON__[:566] Types::Standard::__ANON__[:566]
1113µs5µsTypes::Standard::::__ANON__[:704] Types::Standard::__ANON__[:704]
1112µs2µsTypes::Standard::::BEGIN@196 Types::Standard::BEGIN@196
1111µs1µsTypes::Standard::::BEGIN@26 Types::Standard::BEGIN@26
2111µs1µsTypes::Standard::::__ANON__[:470] Types::Standard::__ANON__[:470]
2111µs1µsTypes::Standard::::__ANON__[:545] Types::Standard::__ANON__[:545]
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
0000s0sTypes::Standard::::slurpy Types::Standard::slurpy
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
3236µs120µs
# spent 20µs within Types::Standard::BEGIN@3 which was called: # once (20µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 3
use 5.008001;
# spent 20µs making 1 call to Types::Standard::BEGIN@3
4216µs29µs
# spent 7µs (5+2) within Types::Standard::BEGIN@4 which was called: # once (5µs+2µs) by JSON::Schema::Modern::BEGIN@31 at line 4
use strict;
# spent 7µs making 1 call to Types::Standard::BEGIN@4 # spent 2µs making 1 call to strict::import
5261µs257µs
# spent 30µs (3+27) within Types::Standard::BEGIN@5 which was called: # once (3µs+27µs) by JSON::Schema::Modern::BEGIN@31 at line 5
use warnings;
# spent 30µs making 1 call to Types::Standard::BEGIN@5 # spent 27µs making 1 call to warnings::import
6
7
# spent 5.71ms (1.59+4.12) within Types::Standard::BEGIN@7 which was called: # once (1.59ms+4.12ms) by JSON::Schema::Modern::BEGIN@31 at line 10
BEGIN {
82421µs eval { require re };
915µs if ( $] < 5.010 ) { require Devel::TypeTiny::Perl58Compat }
10156µs15.71ms}
# spent 5.71ms making 1 call to Types::Standard::BEGIN@7
11
12
# spent 5µs within Types::Standard::BEGIN@12 which was called: # once (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 15
BEGIN {
1311µs $Types::Standard::AUTHORITY = 'cpan:TOBYINK';
1412µs $Types::Standard::VERSION = '2.000001';
15134µs15µs}
# spent 5µs making 1 call to Types::Standard::BEGIN@12
16
1711µs$Types::Standard::VERSION =~ tr/_//d;
18
192959µs219.3ms
# spent 19.2ms (2.89+16.3) within Types::Standard::BEGIN@19 which was called: # once (2.89ms+16.3ms) by JSON::Schema::Modern::BEGIN@31 at line 19
use Type::Library -base;
# spent 19.2ms making 1 call to Types::Standard::BEGIN@19 # spent 102µs making 1 call to Exporter::Tiny::import
20
2112µsour @EXPORT_OK = qw( slurpy );
22
23224µs2307µs
# spent 156µs (5+151) within Types::Standard::BEGIN@23 which was called: # once (5µs+151µs) by JSON::Schema::Modern::BEGIN@31 at line 23
use Eval::TypeTiny qw( set_subname );
# spent 156µs making 1 call to Types::Standard::BEGIN@23 # spent 151µs making 1 call to Exporter::Tiny::import
24215µs264µs
# spent 35µs (6+29) within Types::Standard::BEGIN@24 which was called: # once (6µs+29µs) by JSON::Schema::Modern::BEGIN@31 at line 24
use Scalar::Util qw( blessed looks_like_number );
# spent 35µs making 1 call to Types::Standard::BEGIN@24 # spent 29µs making 1 call to Exporter::import
25210µ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
26283µs11µs
# spent 1µs within Types::Standard::BEGIN@26 which was called: # once (1µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 26
use Types::TypeTiny ();
# spent 1µs making 1 call to Types::Standard::BEGIN@26
27
2810smy $is_class_loaded;
29
30
# spent 142µs (123+19) within Types::Standard::BEGIN@30 which was called: # once (123µs+19µ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
48127µs *_is_class_loaded =
# spent 2.77ms executing statements in string eval
# includes 2.19ms 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;
55116µs18µs Ref::Util::XS::->VERSION( 0.100 );
# spent 8µs making 1 call to UNIVERSAL::VERSION
5610s 1;
57 }
58 ? sub () { !!1 }
5913µs : sub () { !!0 };
601400µs1142µs} #/ BEGIN
# spent 142µs making 1 call to Types::Standard::BEGIN@30
61
62
# spent 17.3ms (116µs+17.1) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:127] which was called 20 times, avg 863µs/call: # once (13µs+6.83ms) by JSON::Schema::Modern::BEGIN@31 at line 210 # once (4µs+787µs) by JSON::Schema::Modern::BEGIN@31 at line 459 # once (6µs+651µs) by JSON::Schema::Modern::BEGIN@31 at line 472 # once (6µs+624µs) by JSON::Schema::Modern::BEGIN@31 at line 281 # once (5µs+620µs) by JSON::Schema::Modern::BEGIN@31 at line 512 # once (6µs+602µs) by JSON::Schema::Modern::BEGIN@31 at line 490 # once (6µs+575µs) by JSON::Schema::Modern::BEGIN@31 at line 441 # once (6µs+574µs) by JSON::Schema::Modern::BEGIN@31 at line 427 # once (10µs+538µs) by JSON::Schema::Modern::BEGIN@31 at line 216 # once (8µs+532µs) by JSON::Schema::Modern::BEGIN@31 at line 351 # once (4µs+521µs) by JSON::Schema::Modern::BEGIN@31 at line 232 # once (4µs+519µs) by JSON::Schema::Modern::BEGIN@31 at line 552 # once (5µs+514µs) by JSON::Schema::Modern::BEGIN@31 at line 244 # once (5µs+500µs) by JSON::Schema::Modern::BEGIN@31 at line 533 # once (5µs+497µs) by JSON::Schema::Modern::BEGIN@31 at line 266 # once (6µs+475µs) by JSON::Schema::Modern::BEGIN@31 at line 567 # once (5µs+458µs) by JSON::Schema::Modern::BEGIN@31 at line 663 # once (3µs+456µs) by JSON::Schema::Modern::BEGIN@31 at line 645 # once (6µs+438µs) by JSON::Schema::Modern::BEGIN@31 at line 787 # once (3µs+431µs) by JSON::Schema::Modern::BEGIN@31 at line 252
my $add_core_type = sub {
63206µs my $meta = shift;
64205µs my ( $typedef ) = @_;
65
66205µs my $name = $typedef->{name};
67201µs my ( $xsub, $xsubname );
68
69 # We want Map and Tuple to be XSified, even if they're not
70 # really core.
712011µs $typedef->{_is_core} = 1
72 unless $name eq 'Map' || $name eq 'Tuple';
73
742023µs2021µs if ( Type::Tiny::_USE_XS
# spent 21µs making 20 calls to Type::Tiny::__ANON__[Type/Tiny.pm:55], avg 1µ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
105202µs $typedef->{compiled_type_constraint} = $xsub if $xsub;
106
107203µs my $orig_inlined = $typedef->{inlined};
108202µ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
1262059µs2017.1ms $meta->add_type( $typedef );
# spent 17.1ms making 20 calls to Type::Library::add_type, avg 856µs/call
12713µs};
128
129
# spent 17µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:140] which was called 11 times, avg 2µs/call: # 3 times (3µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] at line 289, avg 1µs/call # 2 times (5µ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:945] at line 940, avg 2µs/call # 2 times (3µ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 # 2 times (2µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:488] at line 483, avg 1µs/call
my $maybe_load_modules = sub {
130112µ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 }
1391132µs $code;
14011µs};
141
142sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
143
14415µs119µsmy $meta = __PACKAGE__->meta;
# spent 19µ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
15710s sub Stringable (&) {
158 bless +{ code => $_[0] }, 'Types::Standard::_Stringable';
159 }
160 Types::Standard::_Stringable->Type::Tiny::_install_overloads(
16114µs114µs q[""] => sub { $_[0]{text} ||= $_[0]{code}->() } );
# spent 14µs making 1 call to Type::Tiny::_install_overloads
162
163
# spent 21µs within Types::Standard::LazyLoad which was called 39 times, avg 538ns/call: # 7 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 827, avg 286ns/call # 6 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 663, avg 333ns/call # 6 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 533, avg 333ns/call # 4 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 512, avg 1µs/call # 4 times (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 787, avg 750ns/call # 4 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 802, avg 500ns/call # 4 times (1µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 552, avg 250ns/call # 2 times (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 957, avg 2µs/call # 2 times (1µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 887, avg 500ns/call
sub LazyLoad ($$) {
1643950µs bless \@_, 'Types::Standard::LazyLoad';
165 }
166 'Types::Standard::LazyLoad'->Type::Tiny::_install_overloads(
167
# spent 10.7ms (9.84+829µ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.07ms/call: # 10 times (9.84ms+829µ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.07ms/call
q[&{}] => sub {
1681011µs my ( $typename, $function ) = @{ $_[0] };
1691021µs1090µs my $type = $meta->get_type( $typename );
# spent 90µs making 10 calls to Type::Library::get_type, avg 9µs/call
170104µs my $class = "Types::Standard::$typename";
17110301µs eval "require $class; 1" or die( $@ );
# spent 686µs executing statements in 2 string evals (merged) # spent 594µs executing statements in 2 string evals (merged) # spent 547µs executing statements in 2 string evals (merged) # spent 482µs executing statements in 2 string evals (merged) # spent 450µs executing statements in 2 string evals (merged)
172
173 # Majorly break encapsulation for Type::Tiny :-O
1741048µs for my $key ( keys %$type ) {
17517854µs next unless ref( $type->{$key} ) eq 'Types::Standard::LazyLoad';
1762014µs my $f = $type->{$key}[1];
17720101µs2027µs $type->{$key} = $class->can( "__$f" );
# spent 27µs making 20 calls to UNIVERSAL::can, avg 1µs/call
178 }
179104µs my $mm = $type->{my_methods} || {};
1801011µs for my $key ( keys %$mm ) {
181143µs next unless ref( $mm->{$key} ) eq 'Types::Standard::LazyLoad';
18271µs my $f = $mm->{$key}[1];
183720µs74µs $mm->{$key} = $class->can( "__$f" );
# spent 4µs making 7 calls to UNIVERSAL::can, avg 571ns/call
184 set_subname(
185 sprintf( "%s::my_%s", $type->qualified_name, $key ),
186721µs1479µs $mm->{$key},
# spent 48µs making 7 calls to Eval::TypeTiny::set_subname, avg 7µs/call # spent 31µs making 7 calls to Type::Tiny::qualified_name, avg 4µs/call
187 );
188 } #/ for my $key ( keys %$mm)
18910126µs107µs return $class->can( "__$function" );
# spent 7µs making 10 calls to UNIVERSAL::can, avg 700ns/call
190 },
19113µs16µs );
# spent 6µs making 1 call to Type::Tiny::_install_overloads
192}
193
194235µs231µs
# spent 18µs (5+13) within Types::Standard::BEGIN@194 which was called: # once (5µs+13µs) by JSON::Schema::Modern::BEGIN@31 at line 194
no warnings;
# spent 18µs making 1 call to Types::Standard::BEGIN@194 # spent 13µs making 1 call to warnings::unimport
195
196
# spent 2µs within Types::Standard::BEGIN@196 which was called: # once (2µ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 }
20113.75ms12µs}
# spent 2µ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 }
21015µs16.85ms);
# spent 6.85ms 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" },
21614µs1548µs parent => $_any,
# spent 548µ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 21µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:229] which was called 13 times, avg 2µs/call: # 13 times (21µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
2281327µ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 }
232131µs1525µs);
# spent 525µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
233
23412µs22.93ms$_bool->coercion->add_type_coercions( $_any, q{!!$_} );
# spent 2.52ms making 1 call to Type::Tiny::coercion # spent 408µ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 $_ },
2412636µs
# spent 28µ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 (28µ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 }
24416µs1519µs);
# spent 519µ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 $_ },
25159µs
# spent 9µ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 (9µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub { "defined($_[1])" },
25214µs1434µs complementary_type => $_undef,
# spent 434µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
253 }
254);
255
256# hackish, but eh
25713µs10sScalar::Util::weaken( $_undef->{complementary_type} ||= $_def );
# spent 0s 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 $_ },
26448µs
# spent 4µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:264] which was called 4 times, avg 1µs/call: # 4 times (4µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µs/call
inlined => sub { "defined($_[1]) and not ref($_[1])" },
265 }
26614µs1502µs);
# spent 502µ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 75µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:277] which was called 35 times, avg 2µs/call: # 35 times (75µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
2763589µ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 }
28116µs1630µs);
# spent 630µ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 30µs (19+11) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] which was called 3 times, avg 10µs/call: # 3 times (19µs+11µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 10µs/call
inlined => sub {
289328µs611µs $maybe_load_modules->(
# spent 8µs making 3 calls to UNIVERSAL::VERSION, avg 3µs/call # spent 3µs making 3 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 1µ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 }
29916µs1525µs);
# spent 525µ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 53µs (10+43) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:328] which was called 2 times, avg 26µs/call: # 2 times (10µs+43µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 26µs/call
inlined => sub {
31827µs41µs 'my $val = '
# spent 1µs making 2 calls to Types::Standard::Value, avg 500ns/call # spent 42µs making 2 calls to Type::Tiny::inline_check, avg 21µs/call, recursion: max depth 1, sum of overlapping time 42µ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 }
33216µs1659µs);
# spent 659µs making 1 call to Type::Library::add_type
333
33413µs1428µsmy $_num = $meta->add_type(
# spent 428µ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 {
34748µs "do { my \$tmp = $_[1]; defined(\$tmp) and !ref(\$tmp) and \$tmp =~ /\\A-?[0-9]+\\z/ }";
348 },
349 type_default => sub { return 0; },
350 }
35115µs1540µs);
# spent 540µ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 45µ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 (45µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
3592365µs $Type::Tiny::AvoidCallbacks
360 ? "($is_class_loaded)->(do { my \$tmp = $_[1] })"
361 : "Types::Standard::_is_class_loaded(do { my \$tmp = $_[1] })";
362 },
363 }
36416µs1475µs);
# spent 475µs 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 3µ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 (3µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
37224µ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 }
37714µs1465µs);
# spent 465µ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 $_ },
384713µs
# spent 10µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:384] which was called 7 times, avg 1µs/call: # 7 times (10µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µ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 }
42718µs1580µs);
# spent 580µ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 75µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:438] which was called 76 times, avg 987ns/call: # 76 times (75µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 987ns/call
inlined => sub {
43576124µ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 }
44115µs1581µs);
# spent 581µ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 27µs (22+5) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:456] which was called 2 times, avg 14µs/call: # 2 times (22µs+5µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 14µs/call
inlined => sub {
45123µs my $v = $_[1];
452215µs25µs $maybe_load_modules->(
# spent 5µ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 }
45915µs1791µs);
# spent 791µ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 1µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:470] which was called 2 times, avg 500ns/call: # 2 times (1µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 500ns/call
inlined => sub {
46724µs _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks
468 ? "Ref::Util::XS::is_plain_globref($_[1])"
469 : "ref($_[1]) eq 'GLOB'";
470 },
471 }
47214µs1657µs);
# spent 657µs 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 8µs (6+2) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:488] which was called 2 times, avg 4µs/call: # 2 times (6µs+2µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 4µs/call
inlined => sub {
48327µs22µs $maybe_load_modules->(
# spent 2µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 1µ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 }
49015µs1608µs);
# spent 608µ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 59µ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 (59µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
4983874µ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 26µs (13+13) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:510] which was called 4 times, avg 6µs/call: # 4 times (13µs+13µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 6µs/call
type_default_generator => sub {
508413µ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 }
512114µs5630µs);
# spent 625µs 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
513
514my $_hash = $meta->$add_core_type(
515 {
516 name => "HashRef",
517 parent => $_ref,
518 constraint => sub { ref $_ eq "HASH" },
519
# spent 90µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:523] which was called 81 times, avg 1µs/call: # 81 times (90µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µs/call
inlined => sub {
52081160µ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 52µs (33+19) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:532] which was called 8 times, avg 6µs/call: # 8 times (33µs+19µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 6µs/call
type_default_generator => sub {
530825µs819µs return $Type::Tiny::parameterize_type->type_default if @_ < 2;
# spent 19µs making 8 calls to Type::Tiny::type_default, avg 2µs/call
531 return undef;
532 },
533115µs7507µs my_methods => {
# spent 505µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 2µs making 6 calls to Types::Standard::LazyLoad, avg 333ns/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" },
54523µs
# spent 1µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:545] which was called 2 times, avg 500ns/call: # 2 times (1µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 500ns/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 }
55217µs5524µs);
# spent 523µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 1µs making 4 calls to Types::Standard::LazyLoad, avg 250ns/call
553
554my $_obj = $meta->$add_core_type(
555 {
556 name => "Object",
557 parent => $_ref,
558 constraint => sub { blessed $_ },
559
# spent 3µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:566] which was called 5 times, avg 600ns/call: # 5 times (3µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 600ns/call
inlined => sub {
56057µ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 },
56714µs1481µs is_object => 1,
# spent 481µs 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 }
645110µs1459µs);
# spent 459µ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 22µs (5+17) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:661] which was called: # once (5µs+17µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm
type_default_generator => sub {
66014µs117µs return $Type::Tiny::parameterize_type->type_default;
# spent 17µs making 1 call to Type::Tiny::type_default
661 },
662 }
66316µs7465µs);
# spent 463µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 2µs making 6 calls to Types::Standard::LazyLoad, avg 333ns/call
664
665my $_Optional = $meta->add_type(
666 {
667 name => "Optional",
668 parent => $_item,
669
# spent 24µs (13+11) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:678] which was called: # once (13µs+11µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm
constraint_generator => sub {
67010s return $meta->get_type( 'Optional' ) unless @_;
671
67211µs12µs my $param = Types::TypeTiny::to_TypeTiny( shift );
# spent 2µs making 1 call to Types::TypeTiny::to_TypeTiny
67311µs19µs Types::TypeTiny::is_TypeTiny( $param )
# spent 9µ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] ) }
67814µs },
679
# spent 19µs (7+12) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:686] which was called: # once (7µs+12µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm
inline_generator => sub {
68011µs my $param = shift;
68111µs112µs return unless $param->can_be_inlined;
# spent 12µs making 1 call to Type::Tiny::can_be_inlined
682
# spent 1.39ms (117µs+1.27) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:685] which was called 57 times, avg 24µs/call: # 57 times (117µs+1.27ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 24µs/call
return sub {
683576µs my $v = $_[1];
68457114µs570s $param->inline_check( $v );
# spent 1.27ms making 57 calls to Type::Tiny::inline_check, avg 22µs/call, recursion: max depth 2, sum of overlapping time 1.27ms
68514µ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 5µs (3+2) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:704] which was called: # once (3µs+2µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm
type_default_generator => sub {
70313µs12µs return $_[0]->type_default;
# spent 2µs making 1 call to Type::Tiny::type_default
704 },
705 }
70618µs1460µs);
# spent 460µ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 182µs (42+140) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] which was called 2 times, avg 91µs/call: # 2 times (42µs+140µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 91µs/call
constraint_generator => sub {
71520s my $self = $_slurpy;
71624µs22µs my $param = @_ ? Types::TypeTiny::to_TypeTiny(shift) : $_any;
# spent 2µs making 2 calls to Types::TypeTiny::to_TypeTiny, avg 1µs/call
71722µs214µs Types::TypeTiny::is_TypeTiny( $param )
# spent 14µs making 2 calls to Types::TypeTiny::is_TypeTiny, avg 7µ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 1.47ms (10µs+1.46) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:732] which was called 2 times, avg 735µs/call: # 2 times (10µs+1.46ms) by Type::Tiny::_build_coercion at line 504 of Type/Tiny.pm, avg 735µs/call
_build_coercion => sub {
72820s my $coercion = shift;
72924µs21.46ms $coercion->add_type_coercions( @{ $param->coercion->type_coercion_map } )
# spent 1.46ms making 2 calls to Type::Tiny::has_coercion, avg 730µs/call
730 if $param->has_coercion;
73123µs20s $coercion->freeze;
# spent 0s making 2 calls to Type::Coercion::freeze, avg 0s/call
732 },
733 $param->can_be_inlined
73424µs20s
# spent 686µs (6+680) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:734] which was called 2 times, avg 343µs/call: # 2 times (6µs+680µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 343µs/call
? ( inlined => sub { $param->inline_check( $_[1] ) } )
# spent 680µs making 2 calls to Type::Tiny::inline_check, avg 340µs/call, recursion: max depth 1, sum of overlapping time 680µs
735218µs10124µs : (),
# spent 65µs making 2 calls to Type::Tiny::create_child_type, avg 32µs/call # spent 41µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:524], avg 20µs/call # spent 13µs making 2 calls to Type::Tiny::can_be_inlined, avg 6µs/call # spent 3µ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 69µs (32+37) within Types::Standard::Slurpy::my_unslurpy which was called 6 times, avg 12µs/call: # 6 times (32µs+37µs) by Type::Tiny::AUTOLOAD at line 1430 of Type/Tiny.pm, avg 12µs/call
'unslurpy' => sub {
74861µs my $self = shift;
749 $self->{_my_unslurpy} ||= $self->find_parent(
75026µs22µs
# spent 7µs (5+2) 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+2µs) by Type::Tiny::find_parent at line 744 of Type/Tiny.pm, avg 4µs/call
sub { $_->parent->{uniq} == $_slurpy->{uniq} }
# spent 2µs making 2 calls to Type::Tiny::parent, avg 1µs/call
751624µs837µs )->type_parameter;
# spent 28µs making 2 calls to Type::Tiny::find_parent, avg 14µs/call # spent 7µs making 2 calls to Type::Tiny::type_parameter, avg 4µs/call # spent 2µs making 4 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 500ns/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 }
770110µs1449µs);
# spent 449µs making 1 call to Type::Library::add_type
771
772sub slurpy {
773 my $t = shift;
774 my $s = $_slurpy->of( $t );
775 $s->{slurpy} ||= 1;
776 wantarray ? ( $s, @_ ) : $s;
777}
778
779$meta->$add_core_type(
780 {
781 name => "Tuple",
782 parent => $_arr,
783
# spent 41µs (17+24) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:786] which was called 2 times, avg 20µs/call: # 2 times (17µs+24µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 20µs/call
name_generator => sub {
78422µs my ( $s, @a ) = @_;
785214µs624µs sprintf( '%s[%s]', $s, join q[,], @a );
# spent 24µs making 6 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 4µs/call
786 },
78718µs5447µs constraint_generator => LazyLoad( Tuple => 'constraint_generator' ),
# spent 444µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 3µs making 4 calls to Types::Standard::LazyLoad, avg 750ns/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 },
80215µs5427µs constraint_generator => LazyLoad( CycleTuple => 'constraint_generator' ),
# spent 425µs making 1 call to Type::Library::add_type # spent 2µs making 4 calls to Types::Standard::LazyLoad, avg 500ns/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 665µs (171+494) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] which was called 4 times, avg 166µs/call: # 4 times (171µs+494µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 166µs/call
name_generator => sub {
814439µs my ( $s, @p ) = @_;
815413µs12384µs my $l = @p
# spent 343µs making 4 calls to Type::Tiny::is_strictly_a_type_of, avg 86µs/call # spent 29µs making 4 calls to Types::TypeTiny::is_TypeTiny, avg 7µs/call # spent 12µs making 4 calls to Types::Standard::Slurpy, avg 3µ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;
82047µs my %a = @p;
821 sprintf(
822 '%s[%s%s]', $s,
823497µs46110µs join( q[,], map sprintf( "%s=>%s", $_, $a{$_} ), sort keys %a ),
# spent 101µs making 39 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 3µs/call # spent 8µs making 4 calls to Types::Standard::CORE:sort, avg 2µs/call # spent 1µs making 3 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 333ns/call
824 $l ? ",$l" : ''
825 );
826 },
82717µs8435µs constraint_generator => LazyLoad( Dict => 'constraint_generator' ),
# spent 433µs making 1 call to Type::Library::add_type # spent 2µs making 7 calls to Types::Standard::LazyLoad, avg 286ns/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 12µs (9+3) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] which was called 2 times, avg 6µs/call: # 2 times (9µs+3µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 6µs/call
inlined => sub {
845 $maybe_load_modules->(
846 qw/ Scalar::Util overload /,
84727µs23µs $INC{'overload.pm'}
# spent 3µ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 },
88318µs1509µs is_object => 1,
# spent 509µs making 1 call to Type::Library::add_type
884 }
885);
886
88716µs3541µs$meta->add_type(
# spent 540µs making 1 call to Type::Library::add_type # spent 1µs making 2 calls to Types::Standard::LazyLoad, avg 500ns/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 104µs (15+89) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:921] which was called 2 times, avg 52µs/call: # 2 times (15µs+89µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 52µs/call
inlined => sub {
90920s my ( $self, $var ) = @_;
91022µs43µs my $Str_check = Str()->inline_check( '$inner->[0]' );
# spent 3µs making 2 calls to Types::Standard::Str, avg 2µs/call # spent 86µs making 2 calls to Type::Tiny::inline_check, avg 43µs/call, recursion: max depth 1, sum of overlapping time 86µ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 );
91820s push @code, '} ';
91921µs push @code, '$ok }';
92027µs return ( undef, join( q( ), @code ) );
921 },
922 type_default => sub { return [] },
923 }
92417µs1951µs);
# spent 951µs 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 67µs (15+52) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] which was called 2 times, avg 34µs/call: # 2 times (15µs+52µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 34µs/call
inlined => sub {
93921µs my ( $self, $var ) = @_;
940210µs66µs $maybe_load_modules->(
# spent 4µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µs/call # spent 2µs making 2 calls to Type::Tiny::parent, avg 1µs/call # spent 46µs making 2 calls to Type::Tiny::inline_check, avg 23µs/call, recursion: max depth 1, sum of overlapping time 46µs
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 },
95719µs3832µs constraint_generator => LazyLoad( Tied => 'constraint_generator' ),
# spent 829µs making 1 call to Type::Library::add_type # spent 3µ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 3.56ms (1.84+1.72) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:987] which was called 7 times, avg 509µs/call: # 7 times (1.84ms+1.72ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 509µs/call
constraint_generator => sub {
96773µs return $meta->get_type( 'InstanceOf' ) unless @_;
9687724µs require Type::Tiny::Class;
969 my @classes = map {
9701454µs21456µs Types::TypeTiny::is_TypeTiny( $_ )
# spent 405µs making 7 calls to Type::Tiny::Class::new, avg 58µs/call # spent 45µs making 7 calls to Types::TypeTiny::is_TypeTiny, avg 6µs/call # spent 6µs making 7 calls to B::perlstring, avg 857ns/call
971 ? $_
972 : "Type::Tiny::Class"->new(
973 class => $_,
974 display_name => sprintf( 'InstanceOf[%s]', B::perlstring( $_ ) )
975 )
976 } @_;
977715µ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 }
98915µs1484µs);
# spent 484µ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 }
101812µs1436µs);
# spent 436µs making 1 call to Type::Library::add_type
1019
1020$meta->add_type(
1021 {
1022 name => "HasMethods",
1023 parent => $_obj,
1024
# spent 1.64ms (1.42+221µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1033] which was called: # once (1.42ms+221µ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;
10271543µs require Type::Tiny::Duck;
1028117µs395µs return "Type::Tiny::Duck"->new(
# spent 91µ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 }
103514µs1571µs);
# spent 571µs making 1 call to Type::Library::add_type
1036
1037$meta->add_type(
1038 {
1039 name => "Enum",
1040 parent => $_str,
1041
# spent 2.89ms (2.50+393µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1059] which was called 4 times, avg 724µs/call: # 4 times (2.50ms+393µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 724µs/call
constraint_generator => sub {
104242µs return $meta->get_type( 'Enum' ) unless @_;
104341µs my $coercion;
1044414µ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 }
105241µs require B;
10534434µs require Type::Tiny::Enum;
1054462µs23283µs return "Type::Tiny::Enum"->new(
# spent 271µs making 4 calls to Type::Tiny::Enum::new, avg 68µs/call # spent 12µs making 19 calls to B::perlstring, avg 632ns/call
1055 values => \@_,
1056 display_name => sprintf( 'Enum[%s]', join q[,], map B::perlstring( $_ ), @_ ),
1057 $coercion ? ( coercion => $coercion ) : (),
1058 );
1059 },
106015µs1558µs type_default => undef,
# spent 558µs making 1 call to Type::Library::add_type
1061 }
1062);
1063
1064111µs2309µs$meta->add_coercion(
# spent 303µ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 }
108912µs1167µs);
# spent 167µ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 }
110513µs1146µs);
# spent 146µs making 1 call to Type::Library::add_coercion
1106
110712µs22.11ms__PACKAGE__->meta->make_immutable;
# spent 2.11ms making 1 call to Type::Library::make_immutable # spent 3µs making 1 call to Type::Library::meta
1108
1109190µs1;
1110
1111__END__
 
# spent 8µs within Types::Standard::CORE:sort which was called 4 times, avg 2µs/call: # 4 times (8µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] at line 823, avg 2µs/call
sub Types::Standard::CORE:sort; # opcode