← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 16:10:05 2022
Reported on Wed Dec 14 16:12:57 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm
StatementsExecuted 1293 statements in 12.8ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
101111.5ms12.6msTypes::Standard::::__ANON__[:190] Types::Standard::__ANON__[:190]
4112.61ms3.07msTypes::Standard::::__ANON__[:1059] Types::Standard::__ANON__[:1059]
1112.40ms20.8msTypes::Standard::::BEGIN@19 Types::Standard::BEGIN@19
7111.70ms3.64msTypes::Standard::::__ANON__[:987] Types::Standard::__ANON__[:987]
1111.52ms1.78msTypes::Standard::::__ANON__[:1033] Types::Standard::__ANON__[:1033]
1111.05ms1.49msTypes::Standard::::BEGIN@7 Types::Standard::BEGIN@7
411289µs1.43msTypes::Standard::::__ANON__[:826] Types::Standard::__ANON__[:826]
111241µs273µsTypes::Standard::::BEGIN@30 Types::Standard::BEGIN@30
20201211µs20.4msTypes::Standard::::__ANON__[:127] Types::Standard::__ANON__[:127]
5711182µs1.54msTypes::Standard::::__ANON__[:685] Types::Standard::__ANON__[:685]
8111159µs159µsTypes::Standard::::__ANON__[:523] Types::Standard::__ANON__[:523]
3511114µs114µsTypes::Standard::::__ANON__[:277] Types::Standard::__ANON__[:277]
211100µs240µsTypes::Standard::::__ANON__[:921] Types::Standard::__ANON__[:921]
381190µs90µsTypes::Standard::::__ANON__[:501] Types::Standard::__ANON__[:501]
761167µs67µsTypes::Standard::::__ANON__[:438] Types::Standard::__ANON__[:438]
81166µs91µsTypes::Standard::::__ANON__[:532] Types::Standard::__ANON__[:532]
11162µs81µsTypes::Standard::::__ANON__[:678] Types::Standard::__ANON__[:678]
61150µs96µsTypes::Standard::Slurpy::::my_unslurpyTypes::Standard::Slurpy::my_unslurpy
231150µs50µsTypes::Standard::::__ANON__[:362] Types::Standard::__ANON__[:362]
261145µs45µsTypes::Standard::::__ANON__[:241] Types::Standard::__ANON__[:241]
21144µs344µsTypes::Standard::::__ANON__[:737] Types::Standard::__ANON__[:737]
31131µs50µsTypes::Standard::::__ANON__[:295] Types::Standard::__ANON__[:295]
131130µs30µsTypes::Standard::::__ANON__[:229] Types::Standard::__ANON__[:229]
115130µs30µsTypes::Standard::::__ANON__[:140] Types::Standard::__ANON__[:140]
11127µs27µsTypes::Standard::::BEGIN@3 Types::Standard::BEGIN@3
41119µs32µsTypes::Standard::::__ANON__[:510] Types::Standard::__ANON__[:510]
21119µs47µsTypes::Standard::::__ANON__[:786] Types::Standard::__ANON__[:786]
399117µs17µsTypes::Standard::::LazyLoad Types::Standard::LazyLoad
71117µs17µsTypes::Standard::::__ANON__[:384] Types::Standard::__ANON__[:384]
21115µs1.78msTypes::Standard::::__ANON__[:732] Types::Standard::__ANON__[:732]
41113µs13µsTypes::Standard::::CORE:sort Types::Standard::CORE:sort (opcode)
21113µs56µsTypes::Standard::::__ANON__[:945] Types::Standard::__ANON__[:945]
11112µs37µsTypes::Standard::::__ANON__[:661] Types::Standard::__ANON__[:661]
21111µs60µsTypes::Standard::::__ANON__[:328] Types::Standard::__ANON__[:328]
21111µs25µsTypes::Standard::::__ANON__[:851] Types::Standard::__ANON__[:851]
41110µs10µsTypes::Standard::::__ANON__[:348] Types::Standard::__ANON__[:348]
1119µs41µsTypes::Standard::::BEGIN@24 Types::Standard::BEGIN@24
2119µs12µsTypes::Standard::::__ANON__[:456] Types::Standard::__ANON__[:456]
1118µs39µsTypes::Standard::::BEGIN@194 Types::Standard::BEGIN@194
1118µs233µsTypes::Standard::::BEGIN@23 Types::Standard::BEGIN@23
1117µs10µsTypes::Standard::::BEGIN@4 Types::Standard::BEGIN@4
5117µs7µsTypes::Standard::::__ANON__[:251] Types::Standard::__ANON__[:251]
4117µs7µsTypes::Standard::::__ANON__[:264] Types::Standard::__ANON__[:264]
5117µs7µsTypes::Standard::::__ANON__[:566] Types::Standard::__ANON__[:566]
1117µs31µsTypes::Standard::::__ANON__[:686] Types::Standard::__ANON__[:686]
2116µs9µsTypes::Standard::::__ANON__[:488] Types::Standard::__ANON__[:488]
2116µs677µsTypes::Standard::::__ANON__[:734] Types::Standard::__ANON__[:734]
2116µs8µsTypes::Standard::::__ANON__[:750] Types::Standard::__ANON__[:750]
1115µs5µsTypes::Standard::::BEGIN@196 Types::Standard::BEGIN@196
2115µs5µsTypes::Standard::::__ANON__[:375] Types::Standard::__ANON__[:375]
1114µs31µsTypes::Standard::::BEGIN@5 Types::Standard::BEGIN@5
2114µs4µsTypes::Standard::::__ANON__[:545] Types::Standard::__ANON__[:545]
1114µs7µsTypes::Standard::::__ANON__[:704] Types::Standard::__ANON__[:704]
1113µs3µsTypes::Standard::::BEGIN@12 Types::Standard::BEGIN@12
1113µs3µsTypes::Standard::::BEGIN@26 Types::Standard::BEGIN@26
1112µs2µsTypes::Standard::::BEGIN@25 Types::Standard::BEGIN@25
2111µs1µsTypes::Standard::::__ANON__[:470] Types::Standard::__ANON__[:470]
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
32155µ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
4247µs213µs
# spent 10µs (7+3) within Types::Standard::BEGIN@4 which was called: # once (7µs+3µs) by JSON::Schema::Modern::BEGIN@31 at line 4
use strict;
# spent 10µs making 1 call to Types::Standard::BEGIN@4 # spent 3µs making 1 call to strict::import
5261µs258µs
# spent 31µs (4+27) within Types::Standard::BEGIN@5 which was called: # once (4µs+27µs) by JSON::Schema::Modern::BEGIN@31 at line 5
use warnings;
# spent 31µs making 1 call to Types::Standard::BEGIN@5 # spent 27µs making 1 call to warnings::import
6
7
# spent 1.49ms (1.05+436µs) within Types::Standard::BEGIN@7 which was called: # once (1.05ms+436µs) by JSON::Schema::Modern::BEGIN@31 at line 10
BEGIN {
82146µs eval { require re };
913µs if ( $] < 5.010 ) { require Devel::TypeTiny::Perl58Compat }
10129µs11.49ms}
# spent 1.49ms making 1 call to Types::Standard::BEGIN@7
11
12
# spent 3µs within Types::Standard::BEGIN@12 which was called: # once (3µ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';
15126µs13µs}
# spent 3µs making 1 call to Types::Standard::BEGIN@12
16
1712µs$Types::Standard::VERSION =~ tr/_//d;
18
192536µs220.9ms
# spent 20.8ms (2.40+18.4) within Types::Standard::BEGIN@19 which was called: # once (2.40ms+18.4ms) by JSON::Schema::Modern::BEGIN@31 at line 19
use Type::Library -base;
# spent 20.8ms making 1 call to Types::Standard::BEGIN@19 # spent 134µs making 1 call to Exporter::Tiny::import
20
2112µsour @EXPORT_OK = qw( slurpy );
22
23241µs2458µs
# spent 233µs (8+225) within Types::Standard::BEGIN@23 which was called: # once (8µs+225µs) by JSON::Schema::Modern::BEGIN@31 at line 23
use Eval::TypeTiny qw( set_subname );
# spent 233µs making 1 call to Types::Standard::BEGIN@23 # spent 225µs making 1 call to Exporter::Tiny::import
24224µs273µs
# spent 41µs (9+32) within Types::Standard::BEGIN@24 which was called: # once (9µs+32µs) by JSON::Schema::Modern::BEGIN@31 at line 24
use Scalar::Util qw( blessed looks_like_number );
# spent 41µs making 1 call to Types::Standard::BEGIN@24 # spent 32µs making 1 call to Exporter::import
25213µs12µs
# spent 2µs within Types::Standard::BEGIN@25 which was called: # once (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 25
use Type::Tiny ();
# spent 2µs making 1 call to Types::Standard::BEGIN@25
262192µs13µs
# spent 3µs within Types::Standard::BEGIN@26 which was called: # once (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 26
use Types::TypeTiny ();
# spent 3µs making 1 call to Types::Standard::BEGIN@26
27
2810smy $is_class_loaded;
29
30
# spent 273µs (241+32) within Types::Standard::BEGIN@30 which was called: # once (241µs+32µ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
48175µs *_is_class_loaded =
# spent 3.31ms executing statements in string eval
# includes 2.60ms 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;
55123µs112µs Ref::Util::XS::->VERSION( 0.100 );
# spent 12µs making 1 call to UNIVERSAL::VERSION
5610s 1;
57 }
58 ? sub () { !!1 }
5915µs : sub () { !!0 };
601679µs1273µs} #/ BEGIN
# spent 273µs making 1 call to Types::Standard::BEGIN@30
61
62
# spent 20.4ms (211µs+20.2) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:127] which was called 20 times, avg 1.02ms/call: # once (15µs+3.87ms) by JSON::Schema::Modern::BEGIN@31 at line 210 # once (19µs+1.48ms) by JSON::Schema::Modern::BEGIN@31 at line 232 # once (12µs+1.14ms) by JSON::Schema::Modern::BEGIN@31 at line 351 # once (15µs+1.11ms) by JSON::Schema::Modern::BEGIN@31 at line 567 # once (11µs+1.06ms) by JSON::Schema::Modern::BEGIN@31 at line 427 # once (14µs+1.04ms) by JSON::Schema::Modern::BEGIN@31 at line 281 # once (13µs+961µs) by JSON::Schema::Modern::BEGIN@31 at line 244 # once (8µs+954µs) by JSON::Schema::Modern::BEGIN@31 at line 266 # once (9µs+901µs) by JSON::Schema::Modern::BEGIN@31 at line 645 # once (9µs+893µs) by JSON::Schema::Modern::BEGIN@31 at line 216 # once (19µs+845µs) by JSON::Schema::Modern::BEGIN@31 at line 252 # once (9µs+787µs) by JSON::Schema::Modern::BEGIN@31 at line 787 # once (10µs+718µs) by JSON::Schema::Modern::BEGIN@31 at line 663 # once (5µs+694µs) by JSON::Schema::Modern::BEGIN@31 at line 472 # once (9µs+678µs) by JSON::Schema::Modern::BEGIN@31 at line 459 # once (5µs+634µs) by JSON::Schema::Modern::BEGIN@31 at line 512 # once (9µs+629µs) by JSON::Schema::Modern::BEGIN@31 at line 441 # once (7µs+628µs) by JSON::Schema::Modern::BEGIN@31 at line 533 # once (7µs+608µs) by JSON::Schema::Modern::BEGIN@31 at line 552 # once (6µs+536µs) by JSON::Schema::Modern::BEGIN@31 at line 490
my $add_core_type = sub {
632011µs my $meta = shift;
64205µs my ( $typedef ) = @_;
65
662011µs my $name = $typedef->{name};
67202µs my ( $xsub, $xsubname );
68
69 # We want Map and Tuple to be XSified, even if they're not
70 # really core.
712035µs $typedef->{_is_core} = 1
72 unless $name eq 'Map' || $name eq 'Tuple';
73
742051µs2049µs if ( Type::Tiny::_USE_XS
# spent 49µ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
105202µs $typedef->{compiled_type_constraint} = $xsub if $xsub;
106
107209µ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
12620100µs2020.1ms $meta->add_type( $typedef );
# spent 20.1ms making 20 calls to Type::Library::add_type, avg 1.01ms/call
12718µs};
128
129
# spent 30µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:140] which was called 11 times, avg 3µs/call: # 3 times (6µ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 (14µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] at line 847, avg 7µ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:488] at line 483, 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:456] at line 452, avg 2µs/call
my $maybe_load_modules = sub {
130113µs my $code = pop;
1311110µ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 }
1391130µs $code;
14012µs};
141
142sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
143
144110µs129µsmy $meta = __PACKAGE__->meta;
# spent 29µ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(
16115µs119µs q[""] => sub { $_[0]{text} ||= $_[0]{code}->() } );
# spent 19µs making 1 call to Type::Tiny::_install_overloads
162
163
# spent 17µs within Types::Standard::LazyLoad which was called 39 times, avg 436ns/call: # 7 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 827, avg 286ns/call # 6 times (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 663, avg 500ns/call # 6 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 533, avg 333ns/call # 4 times (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 552, avg 750ns/call # 4 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 802, avg 500ns/call # 4 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 512, avg 500ns/call # 4 times (0s+0s) by JSON::Schema::Modern::BEGIN@31 at line 787, avg 0s/call # 2 times (2µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 957, avg 1µs/call # 2 times (1µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 887, avg 500ns/call
sub LazyLoad ($$) {
1643948µs bless \@_, 'Types::Standard::LazyLoad';
165 }
166 'Types::Standard::LazyLoad'->Type::Tiny::_install_overloads(
167
# spent 12.6ms (11.5+1.11) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] which was called 10 times, avg 1.26ms/call: # 10 times (11.5ms+1.11ms) 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.26ms/call
q[&{}] => sub {
1681017µs my ( $typename, $function ) = @{ $_[0] };
1691031µs10115µs my $type = $meta->get_type( $typename );
# spent 115µs making 10 calls to Type::Library::get_type, avg 12µs/call
170103µs my $class = "Types::Standard::$typename";
17110398µs eval "require $class; 1" or die( $@ );
# spent 600µs executing statements in 2 string evals (merged) # spent 572µs executing statements in 2 string evals (merged) # spent 492µs executing statements in 2 string evals (merged) # spent 459µs executing statements in 2 string evals (merged) # spent 311µs executing statements in 2 string evals (merged)
172
173 # Majorly break encapsulation for Type::Tiny :-O
1741070µs for my $key ( keys %$type ) {
17517897µs next unless ref( $type->{$key} ) eq 'Types::Standard::LazyLoad';
1762017µs my $f = $type->{$key}[1];
17720126µs2026µs $type->{$key} = $class->can( "__$f" );
# spent 26µs making 20 calls to UNIVERSAL::can, avg 1µs/call
178 }
179108µs my $mm = $type->{my_methods} || {};
1801010µs for my $key ( keys %$mm ) {
181148µs next unless ref( $mm->{$key} ) eq 'Types::Standard::LazyLoad';
18273µs my $f = $mm->{$key}[1];
183730µs77µs $mm->{$key} = $class->can( "__$f" );
# spent 7µs making 7 calls to UNIVERSAL::can, avg 1µs/call
184 set_subname(
185 sprintf( "%s::my_%s", $type->qualified_name, $key ),
186731µs14114µs $mm->{$key},
# spent 71µs making 7 calls to Eval::TypeTiny::set_subname, avg 10µs/call # spent 43µs making 7 calls to Type::Tiny::qualified_name, avg 6µs/call
187 );
188 } #/ for my $key ( keys %$mm)
18910101µs1013µs return $class->can( "__$function" );
# spent 13µs making 10 calls to UNIVERSAL::can, avg 1µs/call
190 },
19114µs110µs );
# spent 10µs making 1 call to Type::Tiny::_install_overloads
192}
193
194262µs270µs
# spent 39µs (8+31) within Types::Standard::BEGIN@194 which was called: # once (8µs+31µs) by JSON::Schema::Modern::BEGIN@31 at line 194
no warnings;
# spent 39µs making 1 call to Types::Standard::BEGIN@194 # spent 31µs making 1 call to warnings::unimport
195
196
# spent 5µs within Types::Standard::BEGIN@196 which was called: # once (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 201
BEGIN {
197 *STRICTNUM =
198 $ENV{PERL_TYPES_STANDARD_STRICTNUM}
199 ? sub() { !!1 }
200 : sub() { !!0 }
20115.61ms15µs}
# spent 5µ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µs13.89ms);
# spent 3.89ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
211
212my $_item = $meta->$add_core_type(
213 {
214 name => "Item",
215 inlined => sub { "!!1" },
21616µs1902µs parent => $_any,
# spent 902µ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 30µ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 (30µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
2281336µ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 }
232111µs11.50ms);
# spent 1.50ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
233
23414µs25.03ms$_bool->coercion->add_type_coercions( $_any, q{!!$_} );
# spent 4.29ms making 1 call to Type::Tiny::coercion # spent 737µ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 $_ },
24126128µs
# spent 45µ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 (45µ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 }
244110µs1974µs);
# spent 974µ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 7µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:251] which was called 5 times, avg 1µs/call: # 5 times (7µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µs/call
inlined => sub { "defined($_[1])" },
252113µs1864µs complementary_type => $_undef,
# spent 864µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
253 }
254);
255
256# hackish, but eh
25715µs11µsScalar::Util::weaken( $_undef->{complementary_type} ||= $_def );
# spent 1µs making 1 call to Scalar::Util::weaken
258
259my $_val = $meta->$add_core_type(
260 {
261 name => "Value",
262 parent => $_def,
263 constraint => sub { not ref $_ },
264411µs
# spent 7µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:264] which was called 4 times, avg 2µs/call: # 4 times (7µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub { "defined($_[1]) and not ref($_[1])" },
265 }
26617µs1962µs);
# spent 962µ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 114µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:277] which was called 35 times, avg 3µs/call: # 35 times (114µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 3µs/call
inlined => sub {
2763599µ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 }
281110µs11.05ms);
# spent 1.05ms 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 50µs (31+19) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] which was called 3 times, avg 17µs/call: # 3 times (31µs+19µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 17µs/call
inlined => sub {
289342µs619µs $maybe_load_modules->(
# spent 13µs making 3 calls to UNIVERSAL::VERSION, avg 4µs/call # spent 6µ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 }
29919µs1902µs);
# spent 902µ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 (11+49) 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 (11µs+49µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 30µs/call
inlined => sub {
31828µs43µs 'my $val = '
# spent 3µs making 2 calls to Types::Standard::Value, avg 2µ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
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 }
33217µs1838µs);
# spent 838µs making 1 call to Type::Library::add_type
333
33413µs1599µsmy $_num = $meta->add_type(
# spent 599µ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 10µ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 (10µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
347413µs "do { my \$tmp = $_[1]; defined(\$tmp) and !ref(\$tmp) and \$tmp =~ /\\A-?[0-9]+\\z/ }";
348 },
349 type_default => sub { return 0; },
350 }
35118µs11.15ms);
# spent 1.15ms 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 50µ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 (50µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
3592399µs $Type::Tiny::AvoidCallbacks
360 ? "($is_class_loaded)->(do { my \$tmp = $_[1] })"
361 : "Types::Standard::_is_class_loaded(do { my \$tmp = $_[1] })";
362 },
363 }
36418µs1898µs);
# spent 898µ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 5µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:375] which was called 2 times, avg 2µs/call: # 2 times (5µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
37227µs $Type::Tiny::AvoidCallbacks
373 ? "($is_class_loaded)->(do { my \$tmp = $_[1] }) and not $_[1]\->can('new')"
374 : "Types::Standard::_is_class_loaded(do { my \$tmp = $_[1] }) and not $_[1]\->can('new')";
375 },
376 }
37715µs11.01ms);
# spent 1.01ms making 1 call to Type::Library::add_type
378
379my $_ref = $meta->$add_core_type(
380 {
381 name => "Ref",
382 parent => $_def,
383 constraint => sub { ref $_ },
384719µs
# spent 17µ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 (17µ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.07ms);
# spent 1.07ms 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 67µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:438] which was called 76 times, avg 882ns/call: # 76 times (67µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 882ns/call
inlined => sub {
43576118µ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 }
44118µs1638µs);
# spent 638µ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 12µs (9+3) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:456] 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 {
45120s my $v = $_[1];
45226µs23µs $maybe_load_modules->(
# spent 3µ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 }
45917µs1687µs);
# spent 687µ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 }
47215µs1699µs);
# spent 699µ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 9µs (6+3) 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+3µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 4µs/call
inlined => sub {
48326µs23µs $maybe_load_modules->(
# spent 3µ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 }
49015µs1542µs);
# spent 542µ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 90µ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 (90µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
49838103µs _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks
499 ? "Ref::Util::XS::is_plain_arrayref($_[1])"
500 : "ref($_[1]) eq 'ARRAY'";
501 },
502 constraint_generator => LazyLoad( ArrayRef => 'constraint_generator' ),
503 inline_generator => LazyLoad( ArrayRef => 'inline_generator' ),
504 deep_explanation => LazyLoad( ArrayRef => 'deep_explanation' ),
505 coercion_generator => LazyLoad( ArrayRef => 'coercion_generator' ),
506 type_default => sub { return []; },
507
# spent 32µs (19+13) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:510] which was called 4 times, avg 8µs/call: # 4 times (19µs+13µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 8µs/call
type_default_generator => sub {
508417µ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µs5641µs);
# spent 639µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 2µs making 4 calls to Types::Standard::LazyLoad, avg 500ns/call
513
514my $_hash = $meta->$add_core_type(
515 {
516 name => "HashRef",
517 parent => $_ref,
518 constraint => sub { ref $_ eq "HASH" },
519
# spent 159µ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 (159µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call
inlined => sub {
52081241µ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 91µs (66+25) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:532] which was called 8 times, avg 11µs/call: # 8 times (66µs+25µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 11µs/call
type_default_generator => sub {
530833µs825µs return $Type::Tiny::parameterize_type->type_default if @_ < 2;
# spent 25µs making 8 calls to Type::Tiny::type_default, avg 3µs/call
531 return undef;
532 },
533116µs7637µs my_methods => {
# spent 635µ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" },
54526µs
# spent 4µ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 (4µ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µs5618µs);
# spent 615µ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
553
554my $_obj = $meta->$add_core_type(
555 {
556 name => "Object",
557 parent => $_ref,
558 constraint => sub { blessed $_ },
559
# spent 7µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:566] which was called 5 times, avg 1µs/call: # 5 times (7µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µs/call
inlined => sub {
560511µ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 },
56719µs11.13ms is_object => 1,
# spent 1.13ms 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 }
645113µs1910µs);
# spent 910µ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 37µs (12+25) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:661] which was called: # once (12µs+25µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm
type_default_generator => sub {
66015µs125µs return $Type::Tiny::parameterize_type->type_default;
# spent 25µs making 1 call to Type::Tiny::type_default
661 },
662 }
663110µs7731µs);
# spent 728µ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
664
665my $_Optional = $meta->add_type(
666 {
667 name => "Optional",
668 parent => $_item,
669
# spent 81µs (62+19) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:678] which was called: # once (62µs+19µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm
constraint_generator => sub {
67011µs return $meta->get_type( 'Optional' ) unless @_;
671
67212µs13µs my $param = Types::TypeTiny::to_TypeTiny( shift );
# spent 3µs making 1 call to Types::TypeTiny::to_TypeTiny
67311µs116µs Types::TypeTiny::is_TypeTiny( $param )
# spent 16µs making 1 call to Types::TypeTiny::is_TypeTiny
674 or _croak(
675 "Parameter to Optional[`a] expected to be a type constraint; got $param" );
676
677 sub { $param->check( $_[0] ) }
67816µs },
679
# spent 31µs (7+24) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:686] which was called: # once (7µs+24µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm
inline_generator => sub {
68010s my $param = shift;
68112µs124µs return unless $param->can_be_inlined;
# spent 24µs making 1 call to Type::Tiny::can_be_inlined
682
# spent 1.54ms (182µs+1.35) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:685] which was called 57 times, avg 27µs/call: # 57 times (182µs+1.35ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 27µs/call
return sub {
683578µs my $v = $_[1];
6845795µs570s $param->inline_check( $v );
# spent 1.35ms making 57 calls to Type::Tiny::inline_check, avg 24µs/call, recursion: max depth 2, sum of overlapping time 1.35ms
68515µs };
686 },
687 deep_explanation => sub {
688 my ( $type, $value, $varname ) = @_;
689 my $param = $type->parameters->[0];
690
691 return [
692 sprintf( '%s exists', $varname ),
693 sprintf( '"%s" constrains %s with "%s" if it exists', $type, $varname, $param ),
694 @{ $param->validate_explain( $value, $varname ) },
695 ];
696 },
697 coercion_generator => sub {
698 my ( $parent, $child, $param ) = @_;
699 return unless $param->has_coercion;
700 return $param->coercion;
701 },
702
# spent 7µs (4+3) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:704] which was called: # once (4µs+3µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm
type_default_generator => sub {
70318µs13µs return $_[0]->type_default;
# spent 3µs making 1 call to Type::Tiny::type_default
704 },
705 }
70619µs1528µs);
# spent 528µs 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 344µs (44+300) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] which was called 2 times, avg 172µs/call: # 2 times (44µs+300µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 172µs/call
constraint_generator => sub {
71521µs my $self = $_slurpy;
71622µs24µs my $param = @_ ? Types::TypeTiny::to_TypeTiny(shift) : $_any;
# spent 4µs making 2 calls to Types::TypeTiny::to_TypeTiny, avg 2µs/call
71721µs230µs Types::TypeTiny::is_TypeTiny( $param )
# spent 30µs making 2 calls to Types::TypeTiny::is_TypeTiny, avg 15µ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.78ms (15µs+1.76) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:732] which was called 2 times, avg 890µs/call: # 2 times (15µs+1.76ms) by Type::Tiny::_build_coercion at line 504 of Type/Tiny.pm, avg 890µs/call
_build_coercion => sub {
72821µs my $coercion = shift;
72924µs21.76ms $coercion->add_type_coercions( @{ $param->coercion->type_coercion_map } )
# spent 1.76ms making 2 calls to Type::Tiny::has_coercion, avg 882µs/call
730 if $param->has_coercion;
73125µs21µs $coercion->freeze;
# spent 1µs making 2 calls to Type::Coercion::freeze, avg 500ns/call
732 },
733 $param->can_be_inlined
73426µs20s
# spent 677µs (6+671) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:734] which was called 2 times, avg 338µs/call: # 2 times (6µs+671µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 338µs/call
? ( inlined => sub { $param->inline_check( $_[1] ) } )
# spent 671µs making 2 calls to Type::Tiny::inline_check, avg 336µs/call, recursion: max depth 1, sum of overlapping time 671µs
735235µs10266µs : (),
# spent 153µs making 2 calls to Type::Tiny::create_child_type, avg 76µs/call # spent 67µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:524], avg 34µs/call # spent 30µs making 2 calls to Type::Tiny::can_be_inlined, avg 15µs/call # spent 11µs making 2 calls to Type::Tiny::type_default, avg 6µs/call # spent 5µs making 2 calls to Type::Tiny::name_generator, 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 96µs (50+46) within Types::Standard::Slurpy::my_unslurpy which was called 6 times, avg 16µs/call: # 6 times (50µs+46µs) by Type::Tiny::AUTOLOAD at line 1430 of Type/Tiny.pm, avg 16µs/call
'unslurpy' => sub {
74861µs my $self = shift;
749 $self->{_my_unslurpy} ||= $self->find_parent(
75026µs22µs
# spent 8µs (6+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 (6µ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
751636µs846µs )->type_parameter;
# spent 32µs making 2 calls to Type::Tiny::find_parent, avg 16µs/call # spent 10µs making 2 calls to Type::Tiny::type_parameter, avg 5µs/call # spent 4µ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 }
770111µs1497µs);
# spent 497µ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 47µs (19+28) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:786] which was called 2 times, avg 24µs/call: # 2 times (19µs+28µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 24µs/call
name_generator => sub {
78422µs my ( $s, @a ) = @_;
785215µs628µs sprintf( '%s[%s]', $s, join q[,], @a );
# spent 28µs making 6 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 5µs/call
786 },
78717µs5796µs constraint_generator => LazyLoad( Tuple => 'constraint_generator' ),
# spent 796µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] # spent 0s making 4 calls to Types::Standard::LazyLoad, avg 0s/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 },
80218µs5458µs constraint_generator => LazyLoad( CycleTuple => 'constraint_generator' ),
# spent 456µ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 1.43ms (289µs+1.14) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] which was called 4 times, avg 358µs/call: # 4 times (289µs+1.14ms) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 358µs/call
name_generator => sub {
814414µs my ( $s, @p ) = @_;
815422µs12954µs my $l = @p
# spent 882µs making 4 calls to Type::Tiny::is_strictly_a_type_of, avg 220µs/call # spent 55µs making 4 calls to Types::TypeTiny::is_TypeTiny, avg 14µs/call # spent 17µ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;
820417µs my %a = @p;
821 sprintf(
822 '%s[%s%s]', $s,
8234216µs46189µs join( q[,], map sprintf( "%s=>%s", $_, $a{$_} ), sort keys %a ),
# spent 174µs making 39 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 4µs/call # spent 13µs making 4 calls to Types::Standard::CORE:sort, avg 3µs/call # spent 2µs making 3 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 667ns/call
824 $l ? ",$l" : ''
825 );
826 },
82717µs8482µs constraint_generator => LazyLoad( Dict => 'constraint_generator' ),
# spent 480µ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 25µs (11+14) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] which was called 2 times, avg 12µs/call: # 2 times (11µs+14µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 12µs/call
inlined => sub {
845 $maybe_load_modules->(
846 qw/ Scalar::Util overload /,
847214µs214µs $INC{'overload.pm'}
# spent 14µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 7µ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µs1859µs is_object => 1,
# spent 859µs making 1 call to Type::Library::add_type
884 }
885);
886
88714µs3629µs$meta->add_type(
# spent 628µ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 240µs (100+140) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:921] which was called 2 times, avg 120µs/call: # 2 times (100µs+140µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 120µs/call
inlined => sub {
90922µs my ( $self, $var ) = @_;
910264µs44µs my $Str_check = Str()->inline_check( '$inner->[0]' );
# spent 4µs making 2 calls to Types::Standard::Str, avg 2µs/call # spent 136µs making 2 calls to Type::Tiny::inline_check, avg 68µs/call, recursion: max depth 1, sum of overlapping time 136µ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 );
91821µs push @code, '} ';
91921µs push @code, '$ok }';
920219µs return ( undef, join( q( ), @code ) );
921 },
922 type_default => sub { return [] },
923 }
92417µs11.67ms);
# spent 1.67ms 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 56µs (13+43) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] which was called 2 times, avg 28µs/call: # 2 times (13µs+43µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 28µs/call
inlined => sub {
93920s my ( $self, $var ) = @_;
940211µs64µs $maybe_load_modules->(
# spent 4µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µs/call # spent 39µs making 2 calls to Type::Tiny::inline_check, avg 20µs/call, recursion: max depth 1, sum of overlapping time 39µs # spent 0s making 2 calls to Type::Tiny::parent, avg 0s/call
941 qw/ Scalar::Util /,
942 $self->parent->inline_check( $var )
943 . " and !!tied(Scalar::Util::reftype($var) eq 'HASH' ? \%{$var} : Scalar::Util::reftype($var) eq 'ARRAY' ? \@{$var} : Scalar::Util::reftype($var) =~ /^(SCALAR|REF)\$/ ? \${$var} : undef)"
944 );
945 },
946 name_generator => sub {
947 my $self = shift;
948 my $param = Types::TypeTiny::to_TypeTiny( shift );
949 unless ( Types::TypeTiny::is_TypeTiny( $param ) ) {
950 Types::TypeTiny::is_StringLike( $param )
951 or _croak( "Parameter to Tied[`a] expected to be a class name; got $param" );
952 require B;
953 return sprintf( "%s[%s]", $self, B::perlstring( $param ) );
954 }
955 return sprintf( "%s[%s]", $self, $param );
956 },
957110µs3944µs constraint_generator => LazyLoad( Tied => 'constraint_generator' ),
# spent 942µs making 1 call to Type::Library::add_type # spent 2µs making 2 calls to Types::Standard::LazyLoad, avg 1µ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.64ms (1.70+1.94) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:987] which was called 7 times, avg 520µs/call: # 7 times (1.70ms+1.94ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 520µs/call
constraint_generator => sub {
96774µs return $meta->get_type( 'InstanceOf' ) unless @_;
9687547µs require Type::Tiny::Class;
969 my @classes = map {
9701478µs21637µs Types::TypeTiny::is_TypeTiny( $_ )
# spent 560µs making 7 calls to Type::Tiny::Class::new, avg 80µs/call # spent 68µs making 7 calls to Types::TypeTiny::is_TypeTiny, avg 10µs/call # spent 9µs making 7 calls to B::perlstring, avg 1µs/call
971 ? $_
972 : "Type::Tiny::Class"->new(
973 class => $_,
974 display_name => sprintf( 'InstanceOf[%s]', B::perlstring( $_ ) )
975 )
976 } @_;
977717µ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 }
98914µs1464µs);
# spent 464µ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 }
101814µs1481µs);
# spent 481µs making 1 call to Type::Library::add_type
1019
1020$meta->add_type(
1021 {
1022 name => "HasMethods",
1023 parent => $_obj,
1024
# spent 1.78ms (1.52+267µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1033] which was called: # once (1.52ms+267µ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;
10271409µs require Type::Tiny::Duck;
1028121µs3114µs return "Type::Tiny::Duck"->new(
# spent 110µ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 }
1035110µs1900µs);
# spent 900µs making 1 call to Type::Library::add_type
1036
1037$meta->add_type(
1038 {
1039 name => "Enum",
1040 parent => $_str,
1041
# spent 3.07ms (2.61+457µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1059] which was called 4 times, avg 766µs/call: # 4 times (2.61ms+457µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 766µs/call
constraint_generator => sub {
104241µs return $meta->get_type( 'Enum' ) unless @_;
104342µs my $coercion;
1044416µs42µs if ( ref( $_[0] ) and ref( $_[0] ) eq 'SCALAR' ) {
# spent 2µs making 4 calls to Scalar::Util::blessed, avg 500ns/call
1045 $coercion = ${ +shift };
1046 }
1047 elsif ( ref( $_[0] ) && !blessed( $_[0] )
1048 or blessed( $_[0] ) && $_[0]->isa( 'Type::Coercion' ) )
1049 {
1050 $coercion = shift;
1051 }
105243µs require B;
10534375µs require Type::Tiny::Enum;
1054476µs23323µs return "Type::Tiny::Enum"->new(
# spent 312µs making 4 calls to Type::Tiny::Enum::new, avg 78µ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µs1782µs type_default => undef,
# spent 782µs making 1 call to Type::Library::add_type
1061 }
1062);
1063
1064119µs2549µs$meta->add_coercion(
# spent 539µs making 1 call to Type::Library::add_coercion # spent 10µs making 1 call to Type::Library::get_type
1065 {
1066 name => "MkOpt",
1067 type_constraint => $meta->get_type( "OptList" ),
1068 type_coercion_map => [
1069 $_arr, q{ Exporter::Tiny::mkopt($_) },
1070 $_hash, q{ Exporter::Tiny::mkopt($_) },
1071 $_undef, q{ [] },
1072 ],
1073 }
1074);
1075
1076$meta->add_coercion(
1077 {
1078 name => "Join",
1079 type_constraint => $_str,
1080 coercion_generator => sub {
1081 my ( $self, $target, $sep ) = @_;
1082 Types::TypeTiny::is_StringLike( $sep )
1083 or _croak( "Parameter to Join[`a] expected to be a string; got $sep" );
1084 require B;
1085 $sep = B::perlstring( $sep );
1086 return ( ArrayRef(), qq{ join($sep, \@\$_) } );
1087 },
1088 }
108915µs1363µs);
# spent 363µ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 }
110514µs1318µs);
# spent 318µs making 1 call to Type::Library::add_coercion
1106
1107171µs23.90ms__PACKAGE__->meta->make_immutable;
# spent 3.89ms making 1 call to Type::Library::make_immutable # spent 11µs making 1 call to Type::Library::meta
1108
11091141µs1;
1110
1111__END__
 
# spent 13µs within Types::Standard::CORE:sort which was called 4 times, avg 3µs/call: # 4 times (13µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] at line 823, avg 3µs/call
sub Types::Standard::CORE:sort; # opcode