← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:57:08 2022
Reported on Wed Dec 14 16:00:32 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm
StatementsExecuted 1297 statements in 14.8ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
101113.9ms15.5msTypes::Standard::::__ANON__[:190] Types::Standard::__ANON__[:190]
1113.48ms22.1msTypes::Standard::::BEGIN@19 Types::Standard::BEGIN@19
4112.38ms2.84msTypes::Standard::::__ANON__[:1059] Types::Standard::__ANON__[:1059]
1112.30ms3.06msTypes::Standard::::BEGIN@7 Types::Standard::BEGIN@7
7111.95ms4.26msTypes::Standard::::__ANON__[:987] Types::Standard::__ANON__[:987]
1111.90ms2.29msTypes::Standard::::__ANON__[:1033] Types::Standard::__ANON__[:1033]
411237µs973µsTypes::Standard::::__ANON__[:826] Types::Standard::__ANON__[:826]
20201225µs21.9msTypes::Standard::::__ANON__[:127] Types::Standard::__ANON__[:127]
111214µs250µsTypes::Standard::::BEGIN@30 Types::Standard::BEGIN@30
5711199µs2.44msTypes::Standard::::__ANON__[:685] Types::Standard::__ANON__[:685]
8111186µs186µsTypes::Standard::::__ANON__[:523] Types::Standard::__ANON__[:523]
7611142µs142µsTypes::Standard::::__ANON__[:438] Types::Standard::__ANON__[:438]
3811134µs134µsTypes::Standard::::__ANON__[:501] Types::Standard::__ANON__[:501]
381184µs84µsTypes::Standard::::__ANON__[:277] Types::Standard::__ANON__[:277]
231162µs62µsTypes::Standard::::__ANON__[:362] Types::Standard::__ANON__[:362]
61151µs158µsTypes::Standard::Slurpy::::my_unslurpyTypes::Standard::Slurpy::my_unslurpy
21148µs314µsTypes::Standard::::__ANON__[:737] Types::Standard::__ANON__[:737]
261141µs41µsTypes::Standard::::__ANON__[:241] Types::Standard::__ANON__[:241]
81141µs63µsTypes::Standard::::__ANON__[:532] Types::Standard::__ANON__[:532]
399140µs40µsTypes::Standard::::LazyLoad Types::Standard::LazyLoad
141134µs34µsTypes::Standard::::__ANON__[:229] Types::Standard::__ANON__[:229]
21130µs175µsTypes::Standard::::__ANON__[:921] Types::Standard::__ANON__[:921]
11127µs27µsTypes::Standard::::BEGIN@3 Types::Standard::BEGIN@3
11127µs63µsTypes::Standard::::__ANON__[:678] Types::Standard::__ANON__[:678]
115126µs26µsTypes::Standard::::__ANON__[:140] Types::Standard::__ANON__[:140]
21125µs62µsTypes::Standard::::__ANON__[:786] Types::Standard::__ANON__[:786]
31122µs39µsTypes::Standard::::__ANON__[:295] Types::Standard::__ANON__[:295]
21121µs96µsTypes::Standard::::__ANON__[:945] Types::Standard::__ANON__[:945]
11119µs19µsTypes::Standard::::BEGIN@12 Types::Standard::BEGIN@12
21119µs24µsTypes::Standard::::__ANON__[:488] Types::Standard::__ANON__[:488]
41118µs33µsTypes::Standard::::__ANON__[:510] Types::Standard::__ANON__[:510]
51118µs18µsTypes::Standard::::__ANON__[:566] Types::Standard::__ANON__[:566]
11117µs66µsTypes::Standard::::BEGIN@194 Types::Standard::BEGIN@194
21114µs2.44msTypes::Standard::::__ANON__[:732] Types::Standard::__ANON__[:732]
21113µs60µsTypes::Standard::::__ANON__[:328] Types::Standard::__ANON__[:328]
41113µs13µsTypes::Standard::::__ANON__[:348] Types::Standard::__ANON__[:348]
71113µs13µsTypes::Standard::::__ANON__[:384] Types::Standard::__ANON__[:384]
11112µs59µsTypes::Standard::::BEGIN@24 Types::Standard::BEGIN@24
11111µs299µsTypes::Standard::::BEGIN@23 Types::Standard::BEGIN@23
11111µs13µsTypes::Standard::::BEGIN@4 Types::Standard::BEGIN@4
41111µs11µsTypes::Standard::::CORE:sort Types::Standard::CORE:sort (opcode)
21111µs17µsTypes::Standard::::__ANON__[:851] Types::Standard::__ANON__[:851]
2119µs14µsTypes::Standard::::__ANON__[:456] Types::Standard::__ANON__[:456]
2119µs906µsTypes::Standard::::__ANON__[:734] Types::Standard::__ANON__[:734]
5118µs8µsTypes::Standard::::__ANON__[:251] Types::Standard::__ANON__[:251]
2118µs8µsTypes::Standard::::__ANON__[:750] Types::Standard::__ANON__[:750]
1116µs6µsTypes::Standard::::BEGIN@196 Types::Standard::BEGIN@196
1116µs40µsTypes::Standard::::BEGIN@5 Types::Standard::BEGIN@5
1116µs76µsTypes::Standard::::__ANON__[:661] Types::Standard::__ANON__[:661]
1116µs20µsTypes::Standard::::__ANON__[:686] Types::Standard::__ANON__[:686]
4115µs5µsTypes::Standard::::__ANON__[:264] Types::Standard::__ANON__[:264]
1114µs4µsTypes::Standard::::BEGIN@25 Types::Standard::BEGIN@25
1114µs6µsTypes::Standard::::__ANON__[:704] Types::Standard::__ANON__[:704]
1113µs3µsTypes::Standard::::BEGIN@26 Types::Standard::BEGIN@26
2113µs3µsTypes::Standard::::__ANON__[:470] Types::Standard::__ANON__[:470]
2113µs3µsTypes::Standard::::__ANON__[:545] Types::Standard::__ANON__[:545]
2112µs2µsTypes::Standard::::__ANON__[:375] Types::Standard::__ANON__[:375]
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
3292µs127µs
# spent 27µs within Types::Standard::BEGIN@3 which was called: # once (27µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 3
use 5.008001;
# spent 27µs making 1 call to Types::Standard::BEGIN@3
4226µs215µs
# spent 13µs (11+2) within Types::Standard::BEGIN@4 which was called: # once (11µs+2µs) by JSON::Schema::Modern::BEGIN@31 at line 4
use strict;
# spent 13µs making 1 call to Types::Standard::BEGIN@4 # spent 2µs making 1 call to strict::import
5246µs274µs
# spent 40µs (6+34) within Types::Standard::BEGIN@5 which was called: # once (6µs+34µs) by JSON::Schema::Modern::BEGIN@31 at line 5
use warnings;
# spent 40µs making 1 call to Types::Standard::BEGIN@5 # spent 34µs making 1 call to warnings::import
6
7
# spent 3.06ms (2.30+767µs) within Types::Standard::BEGIN@7 which was called: # once (2.30ms+767µs) by JSON::Schema::Modern::BEGIN@31 at line 10
BEGIN {
82209µs eval { require re };
9110µs if ( $] < 5.010 ) { require Devel::TypeTiny::Perl58Compat }
10177µs13.06ms}
# spent 3.06ms making 1 call to Types::Standard::BEGIN@7
11
12
# spent 19µs within Types::Standard::BEGIN@12 which was called: # once (19µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 15
BEGIN {
13110µs $Types::Standard::AUTHORITY = 'cpan:TOBYINK';
14110µs $Types::Standard::VERSION = '2.000001';
15156µs119µs}
# spent 19µs making 1 call to Types::Standard::BEGIN@12
16
1712µs$Types::Standard::VERSION =~ tr/_//d;
18
192684µs222.2ms
# spent 22.1ms (3.48+18.6) within Types::Standard::BEGIN@19 which was called: # once (3.48ms+18.6ms) by JSON::Schema::Modern::BEGIN@31 at line 19
use Type::Library -base;
# spent 22.1ms making 1 call to Types::Standard::BEGIN@19 # spent 167µs making 1 call to Exporter::Tiny::import
20
2113µsour @EXPORT_OK = qw( slurpy );
22
23248µs2587µs
# spent 299µs (11+288) within Types::Standard::BEGIN@23 which was called: # once (11µs+288µs) by JSON::Schema::Modern::BEGIN@31 at line 23
use Eval::TypeTiny qw( set_subname );
# spent 299µs making 1 call to Types::Standard::BEGIN@23 # spent 288µs making 1 call to Exporter::Tiny::import
24232µs2106µs
# spent 59µs (12+47) within Types::Standard::BEGIN@24 which was called: # once (12µs+47µs) by JSON::Schema::Modern::BEGIN@31 at line 24
use Scalar::Util qw( blessed looks_like_number );
# spent 59µs making 1 call to Types::Standard::BEGIN@24 # spent 47µs making 1 call to Exporter::import
25221µs14µs
# spent 4µs within Types::Standard::BEGIN@25 which was called: # once (4µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 25
use Type::Tiny ();
# spent 4µs making 1 call to Types::Standard::BEGIN@25
262162µ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
2811µsmy $is_class_loaded;
29
30
# spent 250µs (214+36) within Types::Standard::BEGIN@30 which was called: # once (214µs+36µs) by JSON::Schema::Modern::BEGIN@31 at line 60
BEGIN {
3111µs $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
48149µs *_is_class_loaded =
# spent 3.60ms executing statements in string eval
# includes 2.73ms 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 {
5411µs require Ref::Util::XS;
55129µs113µs Ref::Util::XS::->VERSION( 0.100 );
# spent 13µs making 1 call to UNIVERSAL::VERSION
5610s 1;
57 }
58 ? sub () { !!1 }
5913µs : sub () { !!0 };
601819µs1250µs} #/ BEGIN
# spent 250µs making 1 call to Types::Standard::BEGIN@30
61
62
# spent 21.9ms (225µs+21.7) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:127] which was called 20 times, avg 1.09ms/call: # once (15µs+4.55ms) by JSON::Schema::Modern::BEGIN@31 at line 210 # once (15µs+1.26ms) by JSON::Schema::Modern::BEGIN@31 at line 266 # once (13µs+1.19ms) by JSON::Schema::Modern::BEGIN@31 at line 216 # once (13µs+1.18ms) by JSON::Schema::Modern::BEGIN@31 at line 787 # once (11µs+1.17ms) by JSON::Schema::Modern::BEGIN@31 at line 427 # once (13µs+1.12ms) by JSON::Schema::Modern::BEGIN@31 at line 232 # once (11µs+1.09ms) by JSON::Schema::Modern::BEGIN@31 at line 490 # once (19µs+1.07ms) by JSON::Schema::Modern::BEGIN@31 at line 441 # once (7µs+1.07ms) by JSON::Schema::Modern::BEGIN@31 at line 645 # once (12µs+844µs) by JSON::Schema::Modern::BEGIN@31 at line 252 # once (14µs+837µs) by JSON::Schema::Modern::BEGIN@31 at line 244 # once (9µs+830µs) by JSON::Schema::Modern::BEGIN@31 at line 567 # once (11µs+797µs) by JSON::Schema::Modern::BEGIN@31 at line 512 # once (11µs+768µs) by JSON::Schema::Modern::BEGIN@31 at line 472 # once (12µs+745µs) by JSON::Schema::Modern::BEGIN@31 at line 459 # once (8µs+696µs) by JSON::Schema::Modern::BEGIN@31 at line 663 # once (7µs+687µs) by JSON::Schema::Modern::BEGIN@31 at line 552 # once (8µs+659µs) by JSON::Schema::Modern::BEGIN@31 at line 351 # once (9µs+559µs) by JSON::Schema::Modern::BEGIN@31 at line 533 # once (7µs+532µs) by JSON::Schema::Modern::BEGIN@31 at line 281
my $add_core_type = sub {
63209µs my $meta = shift;
64208µs my ( $typedef ) = @_;
65
662011µ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.
712029µs $typedef->{_is_core} = 1
72 unless $name eq 'Map' || $name eq 'Tuple';
73
742048µs2045µs if ( Type::Tiny::_USE_XS
# spent 45µ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
105205µs $typedef->{compiled_type_constraint} = $xsub if $xsub;
106
107207µs my $orig_inlined = $typedef->{inlined};
1082011µ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
1262094µs2021.6ms $meta->add_type( $typedef );
# spent 21.6ms making 20 calls to Type::Library::add_type, avg 1.08ms/call
12715µs};
128
129
# spent 26µ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 (7µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] at line 289, avg 2µs/call # 2 times (6µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] at line 847, avg 3µ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 (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 (3µ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
my $maybe_load_modules = sub {
130111µs my $code = pop;
131116µ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
144110µs131µsmy $meta = __PACKAGE__->meta;
# spent 31µ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
15711µs sub Stringable (&) {
158 bless +{ code => $_[0] }, 'Types::Standard::_Stringable';
159 }
160 Types::Standard::_Stringable->Type::Tiny::_install_overloads(
16116µs119µs q[""] => sub { $_[0]{text} ||= $_[0]{code}->() } );
# spent 19µs making 1 call to Type::Tiny::_install_overloads
162
163
# spent 40µs within Types::Standard::LazyLoad which was called 39 times, avg 1µs/call: # 7 times (6µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 827, avg 857ns/call # 6 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 663, avg 833ns/call # 6 times (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 533, avg 500ns/call # 4 times (6µ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 802, avg 1µs/call # 4 times (4µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 552, avg 1µs/call # 2 times (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 957, avg 2µs/call # 2 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 887, avg 1µs/call
sub LazyLoad ($$) {
1643975µs bless \@_, 'Types::Standard::LazyLoad';
165 }
166 'Types::Standard::LazyLoad'->Type::Tiny::_install_overloads(
167
# spent 15.5ms (13.9+1.58) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] which was called 10 times, avg 1.55ms/call: # 10 times (13.9ms+1.58ms) 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.55ms/call
q[&{}] => sub {
1681019µs my ( $typename, $function ) = @{ $_[0] };
1691035µs10144µs my $type = $meta->get_type( $typename );
# spent 144µs making 10 calls to Type::Library::get_type, avg 14µs/call
170102µs my $class = "Types::Standard::$typename";
17110478µs eval "require $class; 1" or die( $@ );
# spent 722µs executing statements in 2 string evals (merged) # spent 686µs executing statements in 2 string evals (merged) # spent 633µs executing statements in 2 string evals (merged) # spent 436µs executing statements in 2 string evals (merged) # spent 420µs executing statements in 2 string evals (merged)
172
173 # Majorly break encapsulation for Type::Tiny :-O
1741091µs for my $key ( keys %$type ) {
175178178µs next unless ref( $type->{$key} ) eq 'Types::Standard::LazyLoad';
1762017µs my $f = $type->{$key}[1];
17720147µs2034µs $type->{$key} = $class->can( "__$f" );
# spent 34µs making 20 calls to UNIVERSAL::can, avg 2µs/call
178 }
179108µs my $mm = $type->{my_methods} || {};
1801012µs for my $key ( keys %$mm ) {
1811416µs next unless ref( $mm->{$key} ) eq 'Types::Standard::LazyLoad';
18275µs my $f = $mm->{$key}[1];
183736µs78µs $mm->{$key} = $class->can( "__$f" );
# spent 8µs making 7 calls to UNIVERSAL::can, avg 1µs/call
184 set_subname(
185 sprintf( "%s::my_%s", $type->qualified_name, $key ),
186736µs14138µs $mm->{$key},
# spent 82µs making 7 calls to Eval::TypeTiny::set_subname, avg 12µs/call # spent 56µs making 7 calls to Type::Tiny::qualified_name, avg 8µs/call
187 );
188 } #/ for my $key ( keys %$mm)
18910109µs1023µs return $class->can( "__$function" );
# spent 23µs making 10 calls to UNIVERSAL::can, avg 2µs/call
190 },
19115µs19µs );
# spent 9µs making 1 call to Type::Tiny::_install_overloads
192}
193
194290µs2115µs
# spent 66µs (17+49) within Types::Standard::BEGIN@194 which was called: # once (17µs+49µs) by JSON::Schema::Modern::BEGIN@31 at line 194
no warnings;
# spent 66µs making 1 call to Types::Standard::BEGIN@194 # spent 49µs making 1 call to warnings::unimport
195
196
# spent 6µs within Types::Standard::BEGIN@196 which was called: # once (6µ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 }
20116.69ms16µs}
# spent 6µ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µs14.56ms);
# spent 4.56ms 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" },
21618µs11.20ms parent => $_any,
# spent 1.20ms 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 34µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:229] which was called 14 times, avg 2µs/call: # 14 times (34µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
2281443µ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 }
232112µs11.14ms);
# spent 1.14ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
233
23414µs23.60ms$_bool->coercion->add_type_coercions( $_any, q{!!$_} );
# spent 3.02ms making 1 call to Type::Tiny::coercion # spent 577µ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 41µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:241] which was called 26 times, avg 2µs/call: # 26 times (41µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub { "!defined($_[1])" },
242 type_default => sub { return undef; },
243 }
24419µs1851µs);
# spent 851µ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 $_ },
251512µs
# spent 8µ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 (8µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub { "defined($_[1])" },
25219µs1856µs complementary_type => $_undef,
# spent 856µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
253 }
254);
255
256# hackish, but eh
25718µ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 $_ },
264410µs
# spent 5µ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 (5µ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 }
26617µs11.28ms);
# spent 1.28ms 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 84µ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 (84µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
2763897µ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 }
28118µs1539µs);
# spent 539µ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 39µs (22+17) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] which was called 3 times, avg 13µs/call: # 3 times (22µs+17µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 13µs/call
inlined => sub {
289333µs617µs $maybe_load_modules->(
# spent 10µs making 3 calls to UNIVERSAL::VERSION, avg 3µs/call # spent 7µs making 3 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µ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 }
29918µs1558µs);
# spent 558µ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 60µs (13+47) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:328] which was called 2 times, avg 30µs/call: # 2 times (13µs+47µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 30µs/call
inlined => sub {
31827µs41µs 'my $val = '
# spent 1µs making 2 calls to Types::Standard::Value, avg 500ns/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
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µs1898µs);
# spent 898µs making 1 call to Type::Library::add_type
333
33414µs1753µsmy $_num = $meta->add_type(
# spent 753µ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 13µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:348] which was called 4 times, avg 3µs/call: # 4 times (13µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 3µs/call
inlined => sub {
347411µ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µs1667µs);
# spent 667µ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 62µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:362] which was called 23 times, avg 3µs/call: # 23 times (62µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 3µs/call
inlined => sub {
3592368µs $Type::Tiny::AvoidCallbacks
360 ? "($is_class_loaded)->(do { my \$tmp = $_[1] })"
361 : "Types::Standard::_is_class_loaded(do { my \$tmp = $_[1] })";
362 },
363 }
36415µs1741µs);
# spent 741µ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 2µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:375] which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µ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 }
37717µs1627µs);
# spent 627µ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 $_ },
384718µs
# spent 13µ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 (13µ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µs11.18ms);
# spent 1.18ms 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 142µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:438] which was called 76 times, avg 2µs/call: # 76 times (142µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
43576241µ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 }
441120µs11.09ms);
# spent 1.09ms 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 14µs (9+5) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:456] which was called 2 times, avg 7µs/call: # 2 times (9µs+5µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 7µs/call
inlined => sub {
45121µs my $v = $_[1];
45227µ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 }
45918µs1757µs);
# spent 757µ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 3µ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 (3µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
46726µs _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks
468 ? "Ref::Util::XS::is_plain_globref($_[1])"
469 : "ref($_[1]) eq 'GLOB'";
470 },
471 }
47217µs1779µs);
# spent 779µ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 24µs (19+5) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:488] which was called 2 times, avg 12µs/call: # 2 times (19µs+5µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 12µs/call
inlined => sub {
483212µ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 }
49019µs11.10ms);
# spent 1.10ms 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 134µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:501] which was called 38 times, avg 4µs/call: # 38 times (134µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 4µs/call
inlined => sub {
49838147µ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 33µs (18+15) 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 (18µs+15µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 8µs/call
type_default_generator => sub {
508418µs415µs return $Type::Tiny::parameterize_type->type_default if @_ < 2;
# spent 15µs making 4 calls to Type::Tiny::type_default, avg 4µs/call
509 return undef;
510 },
511 }
512118µs5814µs);
# spent 808µs 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 186µ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 (186µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
52081185µ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 63µs (41+22) 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 (41µs+22µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 8µs/call
type_default_generator => sub {
530829µs822µs return $Type::Tiny::parameterize_type->type_default if @_ < 2;
# spent 22µs making 8 calls to Type::Tiny::type_default, avg 3µs/call
531 return undef;
532 },
533119µs7571µs my_methods => {
# spent 568µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 3µs making 6 calls to Types::Standard::LazyLoad, avg 500ns/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" },
54524µs
# spent 3µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:545] 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 { "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 }
552110µs5698µs);
# spent 694µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 4µ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 18µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:566] which was called 5 times, avg 4µs/call: # 5 times (18µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 4µs/call
inlined => sub {
560515µ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 },
56717µs1839µs is_object => 1,
# spent 839µ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 }
645116µs11.07ms);
# spent 1.07ms 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 76µs (6+70) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:661] which was called: # once (6µs+70µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm
type_default_generator => sub {
66016µs170µs return $Type::Tiny::parameterize_type->type_default;
# spent 70µs making 1 call to Type::Tiny::type_default
661 },
662 }
663111µs7709µs);
# spent 704µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 5µs making 6 calls to Types::Standard::LazyLoad, avg 833ns/call
664
665my $_Optional = $meta->add_type(
666 {
667 name => "Optional",
668 parent => $_item,
669
# spent 63µs (27+36) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:678] which was called: # once (27µs+36µ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µs12µs my $param = Types::TypeTiny::to_TypeTiny( shift );
# spent 2µs making 1 call to Types::TypeTiny::to_TypeTiny
67312µs134µs Types::TypeTiny::is_TypeTiny( $param )
# spent 34µ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] ) }
67815µs },
679
# spent 20µs (6+14) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:686] which was called: # once (6µs+14µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm
inline_generator => sub {
68010s my $param = shift;
68112µs114µs return unless $param->can_be_inlined;
# spent 14µs making 1 call to Type::Tiny::can_be_inlined
682
# spent 2.44ms (199µs+2.24) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:685] which was called 57 times, avg 43µs/call: # 57 times (199µs+2.24ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 43µs/call
return sub {
683579µs my $v = $_[1];
68457126µs570s $param->inline_check( $v );
# spent 2.24ms making 57 calls to Type::Tiny::inline_check, avg 39µs/call, recursion: max depth 2, sum of overlapping time 2.24ms
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 6µs (4+2) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:704] which was called: # once (4µs+2µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm
type_default_generator => sub {
70312µs12µs return $_[0]->type_default;
# spent 2µs making 1 call to Type::Tiny::type_default
704 },
705 }
706137µs11.12ms);
# spent 1.12ms making 1 call to Type::Library::add_type
707
70811µsmy $_slurpy;
709$_slurpy = $meta->add_type(
710 {
711 name => "Slurpy",
712 slurpy => 1,
713 parent => $_item,
714
# spent 314µs (48+266) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] which was called 2 times, avg 157µs/call: # 2 times (48µs+266µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 157µs/call
constraint_generator => sub {
71521µs my $self = $_slurpy;
71622µs28µs my $param = @_ ? Types::TypeTiny::to_TypeTiny(shift) : $_any;
# spent 8µs making 2 calls to Types::TypeTiny::to_TypeTiny, avg 4µs/call
71722µs226µs Types::TypeTiny::is_TypeTiny( $param )
# spent 26µs making 2 calls to Types::TypeTiny::is_TypeTiny, avg 13µ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.44ms (14µs+2.42) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:732] which was called 2 times, avg 1.22ms/call: # 2 times (14µs+2.42ms) by Type::Tiny::_build_coercion at line 504 of Type/Tiny.pm, avg 1.22ms/call
_build_coercion => sub {
72821µs my $coercion = shift;
72924µs22.42ms $coercion->add_type_coercions( @{ $param->coercion->type_coercion_map } )
# spent 2.42ms making 2 calls to Type::Tiny::has_coercion, avg 1.21ms/call
730 if $param->has_coercion;
73128µs21µs $coercion->freeze;
# spent 1µs making 2 calls to Type::Coercion::freeze, avg 500ns/call
732 },
733 $param->can_be_inlined
73428µs20s
# spent 906µs (9+897) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:734] which was called 2 times, avg 453µs/call: # 2 times (9µs+897µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 453µs/call
? ( inlined => sub { $param->inline_check( $_[1] ) } )
# spent 897µs making 2 calls to Type::Tiny::inline_check, avg 448µs/call, recursion: max depth 1, sum of overlapping time 897µs
735227µs10232µs : (),
# spent 119µs making 2 calls to Type::Tiny::create_child_type, avg 60µs/call # spent 72µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:524], avg 36µs/call # spent 27µs making 2 calls to Type::Tiny::can_be_inlined, avg 14µs/call # spent 9µs making 2 calls to Type::Tiny::name_generator, avg 4µs/call # spent 5µs making 2 calls to Type::Tiny::type_default, avg 2µ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 158µs (51+107) within Types::Standard::Slurpy::my_unslurpy which was called 6 times, avg 26µs/call: # 6 times (51µs+107µs) by Type::Tiny::AUTOLOAD at line 1430 of Type/Tiny.pm, avg 26µs/call
'unslurpy' => sub {
74861µs my $self = shift;
749 $self->{_my_unslurpy} ||= $self->find_parent(
750210µs20s
# spent 8µs 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 (8µs+0s) by Type::Tiny::find_parent at line 744 of Type/Tiny.pm, avg 4µs/call
sub { $_->parent->{uniq} == $_slurpy->{uniq} }
# spent 0s making 2 calls to Type::Tiny::parent, avg 0s/call
751641µs8107µs )->type_parameter;
# spent 68µs making 2 calls to Type::Tiny::find_parent, avg 34µs/call # spent 34µs making 2 calls to Type::Tiny::type_parameter, avg 17µ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 }
770127µs11.33ms);
# spent 1.33ms 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 62µs (25+37) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:786] which was called 2 times, avg 31µs/call: # 2 times (25µs+37µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 31µs/call
name_generator => sub {
78421µs my ( $s, @a ) = @_;
785221µs637µs sprintf( '%s[%s]', $s, join q[,], @a );
# spent 37µs making 6 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 6µs/call
786 },
787115µs51.20ms constraint_generator => LazyLoad( Tuple => 'constraint_generator' ),
# spent 1.19ms 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
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 },
802116µs51.03ms constraint_generator => LazyLoad( CycleTuple => 'constraint_generator' ),
# spent 1.03ms 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 973µs (237+736) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] which was called 4 times, avg 243µs/call: # 4 times (237µs+736µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 243µs/call
name_generator => sub {
814414µs my ( $s, @p ) = @_;
815418µs12535µs my $l = @p
# spent 485µs making 4 calls to Type::Tiny::is_strictly_a_type_of, avg 121µs/call # spent 35µs making 4 calls to Types::TypeTiny::is_TypeTiny, avg 9µs/call # spent 15µs making 4 calls to Types::Standard::Slurpy, avg 4µ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;
820414µs my %a = @p;
821 sprintf(
822 '%s[%s%s]', $s,
8234164µs46201µs join( q[,], map sprintf( "%s=>%s", $_, $a{$_} ), sort keys %a ),
# spent 187µs making 39 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 5µs/call # spent 11µs making 4 calls to Types::Standard::CORE:sort, avg 3µs/call # spent 3µs making 3 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 1µs/call
824 $l ? ",$l" : ''
825 );
826 },
827127µs81.43ms constraint_generator => LazyLoad( Dict => 'constraint_generator' ),
# spent 1.42ms making 1 call to Type::Library::add_type # spent 6µs making 7 calls to Types::Standard::LazyLoad, avg 857ns/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 17µs (11+6) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] which was called 2 times, avg 8µs/call: # 2 times (11µs+6µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 8µs/call
inlined => sub {
845 $maybe_load_modules->(
846 qw/ Scalar::Util overload /,
847216µs26µs $INC{'overload.pm'}
# spent 6µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 3µ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 },
883137µs11.26ms is_object => 1,
# spent 1.26ms making 1 call to Type::Library::add_type
884 }
885);
886
88718µs31.04ms$meta->add_type(
# spent 1.04ms making 1 call to Type::Library::add_type # spent 2µs making 2 calls to Types::Standard::LazyLoad, avg 1µ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 175µs (30+145) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:921] which was called 2 times, avg 88µs/call: # 2 times (30µs+145µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 88µs/call
inlined => sub {
90922µs my ( $self, $var ) = @_;
91026µ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 142µs making 2 calls to Type::Tiny::inline_check, avg 71µs/call, recursion: max depth 1, sum of overlapping time 142µs
91122µ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 );
91822µs push @code, '} ';
91921µs push @code, '$ok }';
92029µs return ( undef, join( q( ), @code ) );
921 },
922 type_default => sub { return [] },
923 }
924110µs11.37ms);
# spent 1.37ms 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 96µs (21+75) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] which was called 2 times, avg 48µs/call: # 2 times (21µs+75µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 48µs/call
inlined => sub {
93921µs my ( $self, $var ) = @_;
940215µs67µs $maybe_load_modules->(
# spent 4µs making 2 calls to Type::Tiny::parent, avg 2µs/call # spent 3µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µs/call # spent 68µs making 2 calls to Type::Tiny::inline_check, avg 34µs/call, recursion: max depth 1, sum of overlapping time 68µ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 },
957112µs31.12ms constraint_generator => LazyLoad( Tied => 'constraint_generator' ),
# spent 1.12ms 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 4.26ms (1.95+2.31) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:987] which was called 7 times, avg 608µs/call: # 7 times (1.95ms+2.31ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 608µs/call
constraint_generator => sub {
96773µs return $meta->get_type( 'InstanceOf' ) unless @_;
9687628µs require Type::Tiny::Class;
969 my @classes = map {
9701470µs21634µs Types::TypeTiny::is_TypeTiny( $_ )
# spent 556µs making 7 calls to Type::Tiny::Class::new, avg 79µs/call # spent 68µs making 7 calls to Types::TypeTiny::is_TypeTiny, avg 10µs/call # spent 10µ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 } @_;
977720µ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 }
98917µs1874µs);
# spent 874µ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µs11.25ms);
# spent 1.25ms making 1 call to Type::Library::add_type
1019
1020$meta->add_type(
1021 {
1022 name => "HasMethods",
1023 parent => $_obj,
1024
# spent 2.29ms (1.90+398µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1033] which was called: # once (1.90ms+398µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm
constraint_generator => sub {
102510s return $meta->get_type( 'HasMethods' ) unless @_;
102611µs require B;
10271505µs require Type::Tiny::Duck;
1028144µs3199µs return "Type::Tiny::Duck"->new(
# spent 179µs making 1 call to Type::Tiny::Duck::new # spent 20µs making 2 calls to B::perlstring, avg 10µs/call
1029 methods => \@_,
1030 display_name =>
1031 sprintf( 'HasMethods[%s]', join q[,], map B::perlstring( $_ ), @_ ),
1032 );
1033 },
1034 }
103519µs1912µs);
# spent 912µs making 1 call to Type::Library::add_type
1036
1037$meta->add_type(
1038 {
1039 name => "Enum",
1040 parent => $_str,
1041
# spent 2.84ms (2.38+463µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1059] which was called 4 times, avg 711µs/call: # 4 times (2.38ms+463µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 711µs/call
constraint_generator => sub {
104242µs return $meta->get_type( 'Enum' ) unless @_;
104341µs my $coercion;
1044415µs43µs if ( ref( $_[0] ) and ref( $_[0] ) eq 'SCALAR' ) {
# spent 3µs making 4 calls to Scalar::Util::blessed, avg 750ns/call
1045 $coercion = ${ +shift };
1046 }
1047 elsif ( ref( $_[0] ) && !blessed( $_[0] )
1048 or blessed( $_[0] ) && $_[0]->isa( 'Type::Coercion' ) )
1049 {
1050 $coercion = shift;
1051 }
105242µs require B;
10534436µs require Type::Tiny::Enum;
1054468µs23348µs return "Type::Tiny::Enum"->new(
# spent 337µs making 4 calls to Type::Tiny::Enum::new, avg 84µs/call # spent 11µs making 19 calls to B::perlstring, avg 579ns/call
1055 values => \@_,
1056 display_name => sprintf( 'Enum[%s]', join q[,], map B::perlstring( $_ ), @_ ),
1057 $coercion ? ( coercion => $coercion ) : (),
1058 );
1059 },
106018µs1867µs type_default => undef,
# spent 867µs making 1 call to Type::Library::add_type
1061 }
1062);
1063
1064120µs2632µs$meta->add_coercion(
# spent 621µs making 1 call to Type::Library::add_coercion # spent 11µ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 }
108917µs1354µs);
# spent 354µ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 }
1105145µs1387µs);
# spent 387µs making 1 call to Type::Library::add_coercion
1106
110718µs23.27ms__PACKAGE__->meta->make_immutable;
# spent 3.26ms making 1 call to Type::Library::make_immutable # spent 6µs making 1 call to Type::Library::meta
1108
11091195µs1;
1110
1111__END__
 
# spent 11µs within Types::Standard::CORE:sort which was called 4 times, avg 3µs/call: # 4 times (11µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] at line 823, avg 3µs/call
sub Types::Standard::CORE:sort; # opcode