| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm |
| Statements | Executed 1309 statements in 14.0ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 10 | 1 | 1 | 9.98ms | 10.8ms | Types::Standard::__ANON__[:190] |
| 1 | 1 | 1 | 3.47ms | 26.0ms | Types::Standard::BEGIN@19 |
| 4 | 1 | 1 | 3.28ms | 3.78ms | Types::Standard::__ANON__[:1059] |
| 1 | 1 | 1 | 2.38ms | 4.24ms | Types::Standard::BEGIN@7 |
| 7 | 1 | 1 | 2.15ms | 4.32ms | Types::Standard::__ANON__[:987] |
| 1 | 1 | 1 | 1.64ms | 1.89ms | Types::Standard::__ANON__[:1033] |
| 4 | 1 | 1 | 348µs | 1.31ms | Types::Standard::__ANON__[:826] |
| 1 | 1 | 1 | 238µs | 312µs | Types::Standard::BEGIN@30 |
| 20 | 20 | 1 | 221µs | 22.4ms | Types::Standard::__ANON__[:127] |
| 81 | 1 | 1 | 152µs | 152µs | Types::Standard::__ANON__[:523] |
| 57 | 1 | 1 | 114µs | 1.56ms | Types::Standard::__ANON__[:685] |
| 38 | 1 | 1 | 93µs | 93µs | Types::Standard::__ANON__[:501] |
| 38 | 1 | 1 | 89µs | 89µs | Types::Standard::__ANON__[:277] |
| 76 | 1 | 1 | 76µs | 76µs | Types::Standard::__ANON__[:438] |
| 23 | 1 | 1 | 49µs | 49µs | Types::Standard::__ANON__[:362] |
| 39 | 9 | 1 | 47µs | 47µs | Types::Standard::LazyLoad |
| 2 | 1 | 1 | 46µs | 248µs | Types::Standard::__ANON__[:737] |
| 14 | 1 | 1 | 45µs | 45µs | Types::Standard::__ANON__[:229] |
| 6 | 1 | 1 | 44µs | 105µs | Types::Standard::Slurpy::my_unslurpy |
| 1 | 1 | 1 | 43µs | 43µs | Types::Standard::BEGIN@3 |
| 8 | 1 | 1 | 39µs | 65µs | Types::Standard::__ANON__[:532] |
| 3 | 1 | 1 | 38µs | 71µs | Types::Standard::__ANON__[:295] |
| 11 | 5 | 1 | 31µs | 31µs | Types::Standard::__ANON__[:140] |
| 26 | 1 | 1 | 29µs | 29µs | Types::Standard::__ANON__[:241] |
| 2 | 1 | 1 | 28µs | 148µs | Types::Standard::__ANON__[:921] |
| 2 | 1 | 1 | 26µs | 60µs | Types::Standard::__ANON__[:786] |
| 3 | 3 | 2 | 26µs | 4.71ms | Types::Standard::slurpy |
| 2 | 1 | 1 | 24µs | 101µs | Types::Standard::__ANON__[:945] |
| 4 | 1 | 1 | 19µs | 32µs | Types::Standard::__ANON__[:510] |
| 2 | 1 | 1 | 16µs | 119µs | Types::Standard::__ANON__[:328] |
| 2 | 1 | 1 | 16µs | 20µs | Types::Standard::__ANON__[:456] |
| 1 | 1 | 1 | 16µs | 32µs | Types::Standard::__ANON__[:678] |
| 7 | 1 | 1 | 15µs | 15µs | Types::Standard::__ANON__[:384] |
| 1 | 1 | 1 | 14µs | 60µs | Types::Standard::BEGIN@5 |
| 4 | 1 | 1 | 14µs | 14µs | Types::Standard::CORE:sort (opcode) |
| 2 | 1 | 1 | 14µs | 19µs | Types::Standard::__ANON__[:488] |
| 2 | 1 | 1 | 14µs | 2.35ms | Types::Standard::__ANON__[:732] |
| 5 | 1 | 1 | 13µs | 13µs | Types::Standard::__ANON__[:566] |
| 1 | 1 | 1 | 11µs | 38µs | Types::Standard::BEGIN@194 |
| 1 | 1 | 1 | 10µs | 244µs | Types::Standard::BEGIN@23 |
| 5 | 1 | 1 | 10µs | 10µs | Types::Standard::__ANON__[:251] |
| 4 | 1 | 1 | 10µs | 10µs | Types::Standard::__ANON__[:264] |
| 2 | 1 | 1 | 10µs | 10µs | Types::Standard::__ANON__[:545] |
| 2 | 1 | 1 | 10µs | 14µs | Types::Standard::__ANON__[:851] |
| 1 | 1 | 1 | 9µs | 9µs | Types::Standard::BEGIN@12 |
| 1 | 1 | 1 | 8µs | 42µs | Types::Standard::BEGIN@24 |
| 1 | 1 | 1 | 8µs | 13µs | Types::Standard::BEGIN@4 |
| 1 | 1 | 1 | 8µs | 28µs | Types::Standard::__ANON__[:686] |
| 4 | 1 | 1 | 7µs | 7µs | Types::Standard::__ANON__[:348] |
| 2 | 1 | 1 | 6µs | 1.13ms | Types::Standard::__ANON__[:734] |
| 2 | 1 | 1 | 5µs | 5µs | Types::Standard::__ANON__[:375] |
| 1 | 1 | 1 | 5µs | 8µs | Types::Standard::__ANON__[:704] |
| 2 | 1 | 1 | 5µs | 8µs | Types::Standard::__ANON__[:750] |
| 1 | 1 | 1 | 4µs | 4µs | Types::Standard::BEGIN@196 |
| 2 | 1 | 1 | 4µs | 4µs | Types::Standard::__ANON__[:470] |
| 1 | 1 | 1 | 3µs | 3µs | Types::Standard::BEGIN@25 |
| 1 | 1 | 1 | 3µs | 3µs | Types::Standard::BEGIN@26 |
| 1 | 1 | 1 | 3µs | 27µs | Types::Standard::__ANON__[:661] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::Slurpy::my_slurp_into |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::Stringable |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:1016] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:1087] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:1103] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:123] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:161] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:206] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:208] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:215] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:226] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:230] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:240] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:242] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:250] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:263] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:274] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:278] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:279] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:287] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:296] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:297] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:316] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:329] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:330] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:345] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:349] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:370] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:383] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:397] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:398] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:407] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:408] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:425] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:433] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:439] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:449] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:457] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:465] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:481] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:496] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:506] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:518] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:528] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:544] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:550] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:558] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:601] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:604] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:621] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:622] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:634] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:639] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:640] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:643] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:677] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:696] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:701] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:725] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:745] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:752] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:756] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:767] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:801] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:843] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:868] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:869] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:881] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:882] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:907] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:922] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:937] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::__ANON__[:956] |
| 0 | 0 | 0 | 0s | 0s | Types::Standard::_croak |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Types::Standard; | ||||
| 2 | |||||
| 3 | 2 | 140µs | 1 | 43µs | # spent 43µs within Types::Standard::BEGIN@3 which was called:
# once (43µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 3 # spent 43µs making 1 call to Types::Standard::BEGIN@3 |
| 4 | 2 | 61µs | 2 | 18µs | # spent 13µs (8+5) within Types::Standard::BEGIN@4 which was called:
# once (8µs+5µs) by JSON::Schema::Modern::BEGIN@31 at line 4 # spent 13µs making 1 call to Types::Standard::BEGIN@4
# spent 5µs making 1 call to strict::import |
| 5 | 2 | 95µs | 2 | 106µs | # spent 60µs (14+46) within Types::Standard::BEGIN@5 which was called:
# once (14µs+46µs) by JSON::Schema::Modern::BEGIN@31 at line 5 # spent 60µs making 1 call to Types::Standard::BEGIN@5
# spent 46µs making 1 call to warnings::import |
| 6 | |||||
| 7 | # spent 4.24ms (2.38+1.86) within Types::Standard::BEGIN@7 which was called:
# once (2.38ms+1.86ms) by JSON::Schema::Modern::BEGIN@31 at line 10 | ||||
| 8 | 2 | 436µs | eval { require re }; | ||
| 9 | 1 | 7µs | if ( $] < 5.010 ) { require Devel::TypeTiny::Perl58Compat } | ||
| 10 | 1 | 79µs | 1 | 4.24ms | } # spent 4.24ms making 1 call to Types::Standard::BEGIN@7 |
| 11 | |||||
| 12 | # spent 9µs within Types::Standard::BEGIN@12 which was called:
# once (9µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 15 | ||||
| 13 | 1 | 0s | $Types::Standard::AUTHORITY = 'cpan:TOBYINK'; | ||
| 14 | 1 | 3µs | $Types::Standard::VERSION = '2.000001'; | ||
| 15 | 1 | 58µs | 1 | 9µs | } # spent 9µs making 1 call to Types::Standard::BEGIN@12 |
| 16 | |||||
| 17 | 1 | 2µs | $Types::Standard::VERSION =~ tr/_//d; | ||
| 18 | |||||
| 19 | 2 | 932µs | 2 | 26.1ms | # spent 26.0ms (3.47+22.5) within Types::Standard::BEGIN@19 which was called:
# once (3.47ms+22.5ms) by JSON::Schema::Modern::BEGIN@31 at line 19 # spent 26.0ms making 1 call to Types::Standard::BEGIN@19
# spent 143µs making 1 call to Exporter::Tiny::import |
| 20 | |||||
| 21 | 1 | 2µs | our @EXPORT_OK = qw( slurpy ); | ||
| 22 | |||||
| 23 | 2 | 36µs | 2 | 478µs | # spent 244µs (10+234) within Types::Standard::BEGIN@23 which was called:
# once (10µs+234µs) by JSON::Schema::Modern::BEGIN@31 at line 23 # spent 244µs making 1 call to Types::Standard::BEGIN@23
# spent 234µs making 1 call to Exporter::Tiny::import |
| 24 | 2 | 23µs | 2 | 76µs | # spent 42µs (8+34) within Types::Standard::BEGIN@24 which was called:
# once (8µs+34µs) by JSON::Schema::Modern::BEGIN@31 at line 24 # spent 42µs making 1 call to Types::Standard::BEGIN@24
# spent 34µs making 1 call to Exporter::import |
| 25 | 2 | 16µs | 1 | 3µs | # spent 3µs within Types::Standard::BEGIN@25 which was called:
# once (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 25 # spent 3µs making 1 call to Types::Standard::BEGIN@25 |
| 26 | 2 | 124µs | 1 | 3µ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 # spent 3µs making 1 call to Types::Standard::BEGIN@26 |
| 27 | |||||
| 28 | 1 | 0s | my $is_class_loaded; | ||
| 29 | |||||
| 30 | # spent 312µs (238+74) within Types::Standard::BEGIN@30 which was called:
# once (238µs+74µs) by JSON::Schema::Modern::BEGIN@31 at line 60 | ||||
| 31 | 1 | 0s | $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 | |||||
| 48 | 1 | 45µs | *_is_class_loaded = # spent 2.76ms executing statements in string eval # includes 2.21ms spent executing 557 calls to 2 subs defined therein. | ||
| 49 | Type::Tiny::_USE_XS | ||||
| 50 | ? \&Type::Tiny::XS::Util::is_class_loaded | ||||
| 51 | : eval $is_class_loaded; | ||||
| 52 | |||||
| 53 | *_HAS_REFUTILXS = eval { | ||||
| 54 | 1 | 0s | require Ref::Util::XS; | ||
| 55 | 1 | 29µs | 1 | 17µs | Ref::Util::XS::->VERSION( 0.100 ); # spent 17µs making 1 call to UNIVERSAL::VERSION |
| 56 | 1 | 0s | 1; | ||
| 57 | } | ||||
| 58 | ? sub () { !!1 } | ||||
| 59 | 1 | 4µs | : sub () { !!0 }; | ||
| 60 | 1 | 664µs | 1 | 312µs | } #/ BEGIN # spent 312µs making 1 call to Types::Standard::BEGIN@30 |
| 61 | |||||
| 62 | # spent 22.4ms (221µs+22.2) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:127] which was called 20 times, avg 1.12ms/call:
# once (18µs+5.26ms) by JSON::Schema::Modern::BEGIN@31 at line 210
# once (15µs+1.22ms) by JSON::Schema::Modern::BEGIN@31 at line 552
# once (12µs+1.09ms) by JSON::Schema::Modern::BEGIN@31 at line 567
# once (7µs+1.01ms) by JSON::Schema::Modern::BEGIN@31 at line 512
# once (10µs+1.01ms) by JSON::Schema::Modern::BEGIN@31 at line 472
# once (15µs+987µs) by JSON::Schema::Modern::BEGIN@31 at line 533
# once (11µs+960µs) by JSON::Schema::Modern::BEGIN@31 at line 427
# once (10µs+939µs) by JSON::Schema::Modern::BEGIN@31 at line 351
# once (11µs+917µs) by JSON::Schema::Modern::BEGIN@31 at line 232
# once (10µs+890µs) by JSON::Schema::Modern::BEGIN@31 at line 490
# once (12µs+878µs) by JSON::Schema::Modern::BEGIN@31 at line 645
# once (10µs+849µs) by JSON::Schema::Modern::BEGIN@31 at line 266
# once (8µs+835µs) by JSON::Schema::Modern::BEGIN@31 at line 459
# once (9µs+833µs) by JSON::Schema::Modern::BEGIN@31 at line 663
# once (12µs+794µs) by JSON::Schema::Modern::BEGIN@31 at line 244
# once (9µs+783µs) by JSON::Schema::Modern::BEGIN@31 at line 252
# once (8µs+766µs) by JSON::Schema::Modern::BEGIN@31 at line 281
# once (16µs+742µs) by JSON::Schema::Modern::BEGIN@31 at line 216
# once (11µs+746µs) by JSON::Schema::Modern::BEGIN@31 at line 787
# once (7µs+676µs) by JSON::Schema::Modern::BEGIN@31 at line 441 | ||||
| 63 | 20 | 11µs | my $meta = shift; | ||
| 64 | 20 | 15µs | my ( $typedef ) = @_; | ||
| 65 | |||||
| 66 | 20 | 7µs | my $name = $typedef->{name}; | ||
| 67 | 20 | 6µs | my ( $xsub, $xsubname ); | ||
| 68 | |||||
| 69 | # We want Map and Tuple to be XSified, even if they're not | ||||
| 70 | # really core. | ||||
| 71 | 20 | 21µs | $typedef->{_is_core} = 1 | ||
| 72 | unless $name eq 'Map' || $name eq 'Tuple'; | ||||
| 73 | |||||
| 74 | 20 | 40µs | 20 | 37µs | if ( Type::Tiny::_USE_XS # spent 37µs making 20 calls to Type::Tiny::__ANON__[Type/Tiny.pm:55], avg 2µs/call |
| 75 | and not( $name eq 'RegexpRef' ) ) | ||||
| 76 | { | ||||
| 77 | $xsub = Type::Tiny::XS::get_coderef_for( $name ); | ||||
| 78 | $xsubname = Type::Tiny::XS::get_subname_for( $name ); | ||||
| 79 | } | ||||
| 80 | |||||
| 81 | elsif ( Type::Tiny::_USE_MOUSE | ||||
| 82 | and not( $name eq 'RegexpRef' or $name eq 'Int' or $name eq 'Object' ) ) | ||||
| 83 | { | ||||
| 84 | require Mouse::Util::TypeConstraints; | ||||
| 85 | $xsub = "Mouse::Util::TypeConstraints"->can( $name ); | ||||
| 86 | $xsubname = "Mouse::Util::TypeConstraints::$name" if $xsub; | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | if ( Type::Tiny::_USE_XS | ||||
| 90 | and Type::Tiny::XS->VERSION < 0.014 | ||||
| 91 | and $name eq 'Bool' ) | ||||
| 92 | { | ||||
| 93 | # Broken implementation of Bool | ||||
| 94 | $xsub = $xsubname = undef; | ||||
| 95 | } | ||||
| 96 | |||||
| 97 | if ( Type::Tiny::_USE_XS | ||||
| 98 | and ( Type::Tiny::XS->VERSION < 0.016 or $] < 5.018 ) | ||||
| 99 | and $name eq 'Int' ) | ||||
| 100 | { | ||||
| 101 | # Broken implementation of Int | ||||
| 102 | $xsub = $xsubname = undef; | ||||
| 103 | } | ||||
| 104 | |||||
| 105 | 20 | 3µs | $typedef->{compiled_type_constraint} = $xsub if $xsub; | ||
| 106 | |||||
| 107 | 20 | 6µs | my $orig_inlined = $typedef->{inlined}; | ||
| 108 | 20 | 4µ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 | |||||
| 126 | 20 | 106µs | 20 | 22.1ms | $meta->add_type( $typedef ); # spent 22.1ms making 20 calls to Type::Library::add_type, avg 1.11ms/call |
| 127 | 1 | 4µs | }; | ||
| 128 | |||||
| 129 | # spent 31µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:140] which was called 11 times, avg 3µs/call:
# 3 times (11µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] at line 289, avg 4µs/call
# 2 times (7µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] at line 940, avg 4µs/call
# 2 times (5µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:488] at line 483, avg 2µs/call
# 2 times (4µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:456] at line 452, avg 2µs/call
# 2 times (4µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] at line 847, avg 2µs/call | ||||
| 130 | 11 | 5µs | my $code = pop; | ||
| 131 | 11 | 2µ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 | } | ||||
| 139 | 11 | 38µs | $code; | ||
| 140 | 1 | 2µs | }; | ||
| 141 | |||||
| 142 | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } | ||||
| 143 | |||||
| 144 | 1 | 10µs | 1 | 37µs | my $meta = __PACKAGE__->meta; # spent 37µs making 1 call to Type::Library::meta |
| 145 | |||||
| 146 | # Stringable and LazyLoad are optimizations that complicate | ||||
| 147 | # this module somewhat, but they have led to performance | ||||
| 148 | # improvements. If Types::Standard wasn't such a key type | ||||
| 149 | # library, I wouldn't use them. I strongly discourage anybody | ||||
| 150 | # from using them in their own code. If you're looking for | ||||
| 151 | # examples of how to write a type library sanely, you're | ||||
| 152 | # better off looking at the code for Types::Common::Numeric | ||||
| 153 | # and Types::Common::String. | ||||
| 154 | |||||
| 155 | { | ||||
| 156 | |||||
| 157 | 1 | 2µs | sub Stringable (&) { | ||
| 158 | bless +{ code => $_[0] }, 'Types::Standard::_Stringable'; | ||||
| 159 | } | ||||
| 160 | Types::Standard::_Stringable->Type::Tiny::_install_overloads( | ||||
| 161 | 1 | 5µs | 1 | 25µs | q[""] => sub { $_[0]{text} ||= $_[0]{code}->() } ); # spent 25µs making 1 call to Type::Tiny::_install_overloads |
| 162 | |||||
| 163 | # spent 47µs within Types::Standard::LazyLoad which was called 39 times, avg 1µs/call:
# 7 times (4µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 827, avg 571ns/call
# 6 times (7µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 663, avg 1µs/call
# 6 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 533, avg 833ns/call
# 4 times (7µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 787, avg 2µs/call
# 4 times (6µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 512, avg 2µs/call
# 4 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 552, avg 1µs/call
# 4 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 802, avg 1µs/call
# 2 times (5µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 957, avg 2µs/call
# 2 times (3µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 887, avg 2µs/call | ||||
| 164 | 39 | 86µs | bless \@_, 'Types::Standard::LazyLoad'; | ||
| 165 | } | ||||
| 166 | 'Types::Standard::LazyLoad'->Type::Tiny::_install_overloads( | ||||
| 167 | # spent 10.8ms (9.98+825µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:190] which was called 10 times, avg 1.08ms/call:
# 10 times (9.98ms+825µs) by Type::Tiny::parameterize or Types::Standard::ArrayRef::__constraint_generator or Types::Standard::Dict::__constraint_generator or Types::Standard::HashRef::__constraint_generator or Types::Standard::Map::__constraint_generator or Types::Standard::Tuple::__constraint_generator at line 1044 of Type/Tiny.pm, avg 1.08ms/call | ||||
| 168 | 10 | 11µs | my ( $typename, $function ) = @{ $_[0] }; | ||
| 169 | 10 | 32µs | 10 | 106µs | my $type = $meta->get_type( $typename ); # spent 106µs making 10 calls to Type::Library::get_type, avg 11µs/call |
| 170 | 10 | 2µs | my $class = "Types::Standard::$typename"; | ||
| 171 | 10 | 328µs | eval "require $class; 1" or die( $@ ); # spent 505µs executing statements in 2 string evals (merged)
# spent 479µs executing statements in 2 string evals (merged)
# spent 435µs executing statements in 2 string evals (merged)
# spent 427µs executing statements in 2 string evals (merged)
# spent 405µs executing statements in 2 string evals (merged) | ||
| 172 | |||||
| 173 | # Majorly break encapsulation for Type::Tiny :-O | ||||
| 174 | 10 | 51µs | for my $key ( keys %$type ) { | ||
| 175 | 178 | 71µs | next unless ref( $type->{$key} ) eq 'Types::Standard::LazyLoad'; | ||
| 176 | 20 | 14µs | my $f = $type->{$key}[1]; | ||
| 177 | 20 | 109µs | 20 | 22µs | $type->{$key} = $class->can( "__$f" ); # spent 22µs making 20 calls to UNIVERSAL::can, avg 1µs/call |
| 178 | } | ||||
| 179 | 10 | 8µs | my $mm = $type->{my_methods} || {}; | ||
| 180 | 10 | 7µs | for my $key ( keys %$mm ) { | ||
| 181 | 14 | 8µs | next unless ref( $mm->{$key} ) eq 'Types::Standard::LazyLoad'; | ||
| 182 | 7 | 2µs | my $f = $mm->{$key}[1]; | ||
| 183 | 7 | 24µs | 7 | 7µ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 ), | ||||
| 186 | 7 | 24µs | 14 | 90µs | $mm->{$key}, # spent 58µs making 7 calls to Eval::TypeTiny::set_subname, avg 8µs/call
# spent 32µs making 7 calls to Type::Tiny::qualified_name, avg 5µs/call |
| 187 | ); | ||||
| 188 | } #/ for my $key ( keys %$mm) | ||||
| 189 | 10 | 63µs | 10 | 8µs | return $class->can( "__$function" ); # spent 8µs making 10 calls to UNIVERSAL::can, avg 800ns/call |
| 190 | }, | ||||
| 191 | 1 | 4µs | 1 | 8µs | ); # spent 8µs making 1 call to Type::Tiny::_install_overloads |
| 192 | } | ||||
| 193 | |||||
| 194 | 2 | 58µs | 2 | 65µs | # spent 38µs (11+27) within Types::Standard::BEGIN@194 which was called:
# once (11µs+27µs) by JSON::Schema::Modern::BEGIN@31 at line 194 # spent 38µs making 1 call to Types::Standard::BEGIN@194
# spent 27µs making 1 call to warnings::unimport |
| 195 | |||||
| 196 | # spent 4µs within Types::Standard::BEGIN@196 which was called:
# once (4µs+0s) by JSON::Schema::Modern::BEGIN@31 at line 201 | ||||
| 197 | *STRICTNUM = | ||||
| 198 | $ENV{PERL_TYPES_STANDARD_STRICTNUM} | ||||
| 199 | ? sub() { !!1 } | ||||
| 200 | : sub() { !!0 } | ||||
| 201 | 1 | 5.98ms | 1 | 4µs | } # spent 4µs making 1 call to Types::Standard::BEGIN@196 |
| 202 | |||||
| 203 | my $_any = $meta->$add_core_type( | ||||
| 204 | { | ||||
| 205 | name => "Any", | ||||
| 206 | inlined => sub { "!!1" }, | ||||
| 207 | complement_name => 'None', | ||||
| 208 | type_default => sub { return undef; }, | ||||
| 209 | } | ||||
| 210 | 1 | 8µs | 1 | 5.28ms | ); # spent 5.28ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 211 | |||||
| 212 | my $_item = $meta->$add_core_type( | ||||
| 213 | { | ||||
| 214 | name => "Item", | ||||
| 215 | inlined => sub { "!!1" }, | ||||
| 216 | 1 | 6µs | 1 | 758µs | parent => $_any, # spent 758µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 217 | } | ||||
| 218 | ); | ||||
| 219 | |||||
| 220 | my $_bool = $meta->$add_core_type( | ||||
| 221 | { | ||||
| 222 | name => "Bool", | ||||
| 223 | parent => $_item, | ||||
| 224 | constraint => sub { | ||||
| 225 | !ref $_ and ( !defined $_ or $_ eq q() or $_ eq '0' or $_ eq '1' ); | ||||
| 226 | }, | ||||
| 227 | # spent 45µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:229] which was called 14 times, avg 3µs/call:
# 14 times (45µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 3µs/call | ||||
| 228 | 14 | 32µ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 | } | ||||
| 232 | 1 | 9µs | 1 | 928µs | ); # spent 928µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 233 | |||||
| 234 | 1 | 4µs | 2 | 4.59ms | $_bool->coercion->add_type_coercions( $_any, q{!!$_} ); # spent 3.97ms making 1 call to Type::Tiny::coercion
# spent 617µs making 1 call to Type::Coercion::add_type_coercions |
| 235 | |||||
| 236 | my $_undef = $meta->$add_core_type( | ||||
| 237 | { | ||||
| 238 | name => "Undef", | ||||
| 239 | parent => $_item, | ||||
| 240 | constraint => sub { !defined $_ }, | ||||
| 241 | 26 | 53µs | # spent 29µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:241] which was called 26 times, avg 1µs/call:
# 26 times (29µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µs/call | ||
| 242 | type_default => sub { return undef; }, | ||||
| 243 | } | ||||
| 244 | 1 | 9µs | 1 | 806µs | ); # spent 806µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 245 | |||||
| 246 | my $_def = $meta->$add_core_type( | ||||
| 247 | { | ||||
| 248 | name => "Defined", | ||||
| 249 | parent => $_item, | ||||
| 250 | constraint => sub { defined $_ }, | ||||
| 251 | 5 | 13µs | # spent 10µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:251] which was called 5 times, avg 2µs/call:
# 5 times (10µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||
| 252 | 1 | 6µs | 1 | 792µs | complementary_type => $_undef, # spent 792µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 253 | } | ||||
| 254 | ); | ||||
| 255 | |||||
| 256 | # hackish, but eh | ||||
| 257 | 1 | 6µs | 1 | 1µs | Scalar::Util::weaken( $_undef->{complementary_type} ||= $_def ); # spent 1µs making 1 call to Scalar::Util::weaken |
| 258 | |||||
| 259 | my $_val = $meta->$add_core_type( | ||||
| 260 | { | ||||
| 261 | name => "Value", | ||||
| 262 | parent => $_def, | ||||
| 263 | constraint => sub { not ref $_ }, | ||||
| 264 | 4 | 11µs | # spent 10µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:264] which was called 4 times, avg 2µs/call:
# 4 times (10µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||
| 265 | } | ||||
| 266 | 1 | 7µs | 1 | 859µs | ); # spent 859µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 267 | |||||
| 268 | my $_str = $meta->$add_core_type( | ||||
| 269 | { | ||||
| 270 | name => "Str", | ||||
| 271 | parent => $_val, | ||||
| 272 | constraint => sub { | ||||
| 273 | ref( \$_ ) eq 'SCALAR' or ref( \( my $val = $_ ) ) eq 'SCALAR'; | ||||
| 274 | }, | ||||
| 275 | # spent 89µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:277] which was called 38 times, avg 2µs/call:
# 38 times (89µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||||
| 276 | 38 | 105µ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 | } | ||||
| 281 | 1 | 9µs | 1 | 774µs | ); # spent 774µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 282 | |||||
| 283 | my $_laxnum = $meta->add_type( | ||||
| 284 | { | ||||
| 285 | name => "LaxNum", | ||||
| 286 | parent => $_str, | ||||
| 287 | constraint => sub { looks_like_number( $_ ) and ref( \$_ ) ne 'GLOB' }, | ||||
| 288 | # spent 71µs (38+33) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:295] which was called 3 times, avg 24µs/call:
# 3 times (38µs+33µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 24µs/call | ||||
| 289 | 3 | 60µs | 6 | 33µs | $maybe_load_modules->( # spent 22µs making 3 calls to UNIVERSAL::VERSION, avg 7µs/call
# spent 11µs making 3 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 4µs/call |
| 290 | qw/ Scalar::Util /, | ||||
| 291 | 'Scalar::Util'->VERSION ge '1.18' # RT 132426 | ||||
| 292 | ? "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1])" | ||||
| 293 | : "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1]) && ref(\\($_[1])) ne 'GLOB'" | ||||
| 294 | ); | ||||
| 295 | }, | ||||
| 296 | sorter => sub { $_[0] <=> $_[1] }, | ||||
| 297 | type_default => sub { return 0; }, | ||||
| 298 | } | ||||
| 299 | 1 | 11µs | 1 | 974µs | ); # spent 974µs making 1 call to Type::Library::add_type |
| 300 | |||||
| 301 | my $_strictnum = $meta->add_type( | ||||
| 302 | { | ||||
| 303 | name => "StrictNum", | ||||
| 304 | parent => $_str, | ||||
| 305 | constraint => sub { | ||||
| 306 | my $val = $_; | ||||
| 307 | ( $val =~ /\A[+-]?[0-9]+\z/ ) | ||||
| 308 | || ( | ||||
| 309 | $val =~ /\A(?:[+-]?) #matches optional +- in the beginning | ||||
| 310 | (?=[0-9]|\.[0-9]) #matches previous +- only if there is something like 3 or .3 | ||||
| 311 | [0-9]* #matches 0-9 zero or more times | ||||
| 312 | (?:\.[0-9]+)? #matches optional .89 or nothing | ||||
| 313 | (?:[Ee](?:[+-]?[0-9]+))? #matches E1 or e1 or e-1 or e+1 etc | ||||
| 314 | \z/x | ||||
| 315 | ); | ||||
| 316 | }, | ||||
| 317 | # spent 119µs (16+103) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:328] which was called 2 times, avg 60µs/call:
# 2 times (16µs+103µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 60µs/call | ||||
| 318 | 2 | 13µs | 4 | 6µs | 'my $val = ' # spent 6µs making 2 calls to Types::Standard::Value, avg 3µs/call
# spent 97µs making 2 calls to Type::Tiny::inline_check, avg 48µs/call, recursion: max depth 1, sum of overlapping time 97µs |
| 319 | . $_[1] . ';' | ||||
| 320 | . Value()->inline_check( '$val' ) | ||||
| 321 | . ' && ( $val =~ /\A[+-]?[0-9]+\z/ || ' | ||||
| 322 | . '$val =~ /\A(?:[+-]?) # matches optional +- in the beginning | ||||
| 323 | (?=[0-9]|\.[0-9]) # matches previous +- only if there is something like 3 or .3 | ||||
| 324 | [0-9]* # matches 0-9 zero or more times | ||||
| 325 | (?:\.[0-9]+)? # matches optional .89 or nothing | ||||
| 326 | (?:[Ee](?:[+-]?[0-9]+))? # matches E1 or e1 or e-1 or e+1 etc | ||||
| 327 | \z/x ); ' | ||||
| 328 | }, | ||||
| 329 | sorter => sub { $_[0] <=> $_[1] }, | ||||
| 330 | type_default => sub { return 0; }, | ||||
| 331 | } | ||||
| 332 | 1 | 10µs | 1 | 1.48ms | ); # spent 1.48ms making 1 call to Type::Library::add_type |
| 333 | |||||
| 334 | 1 | 4µs | 1 | 926µs | my $_num = $meta->add_type( # spent 926µs making 1 call to Type::Library::add_type |
| 335 | { | ||||
| 336 | name => "Num", | ||||
| 337 | parent => ( STRICTNUM ? $_strictnum : $_laxnum ), | ||||
| 338 | } | ||||
| 339 | ); | ||||
| 340 | |||||
| 341 | $meta->$add_core_type( | ||||
| 342 | { | ||||
| 343 | name => "Int", | ||||
| 344 | parent => $_num, | ||||
| 345 | constraint => sub { /\A-?[0-9]+\z/ }, | ||||
| 346 | # spent 7µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:348] which was called 4 times, avg 2µs/call:
# 4 times (7µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||||
| 347 | 4 | 10µs | "do { my \$tmp = $_[1]; defined(\$tmp) and !ref(\$tmp) and \$tmp =~ /\\A-?[0-9]+\\z/ }"; | ||
| 348 | }, | ||||
| 349 | type_default => sub { return 0; }, | ||||
| 350 | } | ||||
| 351 | 1 | 9µs | 1 | 949µs | ); # spent 949µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 352 | |||||
| 353 | my $_classn = $meta->add_type( | ||||
| 354 | { | ||||
| 355 | name => "ClassName", | ||||
| 356 | parent => $_str, | ||||
| 357 | constraint => \&_is_class_loaded, | ||||
| 358 | # spent 49µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:362] which was called 23 times, avg 2µs/call:
# 23 times (49µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||||
| 359 | 23 | 59µs | $Type::Tiny::AvoidCallbacks | ||
| 360 | ? "($is_class_loaded)->(do { my \$tmp = $_[1] })" | ||||
| 361 | : "Types::Standard::_is_class_loaded(do { my \$tmp = $_[1] })"; | ||||
| 362 | }, | ||||
| 363 | } | ||||
| 364 | 1 | 12µs | 1 | 1.43ms | ); # spent 1.43ms making 1 call to Type::Library::add_type |
| 365 | |||||
| 366 | $meta->add_type( | ||||
| 367 | { | ||||
| 368 | name => "RoleName", | ||||
| 369 | parent => $_classn, | ||||
| 370 | constraint => sub { not $_->can( "new" ) }, | ||||
| 371 | # spent 5µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:375] which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||||
| 372 | 2 | 7µ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 | } | ||||
| 377 | 1 | 9µs | 1 | 865µs | ); # spent 865µs making 1 call to Type::Library::add_type |
| 378 | |||||
| 379 | my $_ref = $meta->$add_core_type( | ||||
| 380 | { | ||||
| 381 | name => "Ref", | ||||
| 382 | parent => $_def, | ||||
| 383 | constraint => sub { ref $_ }, | ||||
| 384 | 7 | 19µs | # spent 15µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:384] which was called 7 times, avg 2µs/call:
# 7 times (15µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||
| 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 | } | ||||
| 427 | 1 | 12µs | 1 | 971µs | ); # spent 971µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 428 | |||||
| 429 | $meta->$add_core_type( | ||||
| 430 | { | ||||
| 431 | name => "CodeRef", | ||||
| 432 | parent => $_ref, | ||||
| 433 | constraint => sub { ref $_ eq "CODE" }, | ||||
| 434 | # spent 76µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:438] which was called 76 times, avg 1µs/call:
# 76 times (76µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 1µs/call | ||||
| 435 | 76 | 155µ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 | } | ||||
| 441 | 1 | 7µs | 1 | 683µs | ); # spent 683µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 442 | |||||
| 443 | my $_regexp = $meta->$add_core_type( | ||||
| 444 | { | ||||
| 445 | name => "RegexpRef", | ||||
| 446 | parent => $_ref, | ||||
| 447 | constraint => sub { | ||||
| 448 | ref( $_ ) && !!re::is_regexp( $_ ) or blessed( $_ ) && $_->isa( 'Regexp' ); | ||||
| 449 | }, | ||||
| 450 | # spent 20µs (16+4) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:456] which was called 2 times, avg 10µs/call:
# 2 times (16µs+4µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 10µs/call | ||||
| 451 | 2 | 0s | my $v = $_[1]; | ||
| 452 | 2 | 11µs | 2 | 4µs | $maybe_load_modules->( # spent 4µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µs/call |
| 453 | qw/ Scalar::Util re /, | ||||
| 454 | "ref($v) && !!re::is_regexp($v) or Scalar::Util::blessed($v) && $v\->isa('Regexp')" | ||||
| 455 | ); | ||||
| 456 | }, | ||||
| 457 | type_default => sub { return qr//; }, | ||||
| 458 | } | ||||
| 459 | 1 | 9µs | 1 | 843µs | ); # spent 843µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 460 | |||||
| 461 | $meta->$add_core_type( | ||||
| 462 | { | ||||
| 463 | name => "GlobRef", | ||||
| 464 | parent => $_ref, | ||||
| 465 | constraint => sub { ref $_ eq "GLOB" }, | ||||
| 466 | # spent 4µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:470] which was called 2 times, avg 2µs/call:
# 2 times (4µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||||
| 467 | 2 | 5µs | _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks | ||
| 468 | ? "Ref::Util::XS::is_plain_globref($_[1])" | ||||
| 469 | : "ref($_[1]) eq 'GLOB'"; | ||||
| 470 | }, | ||||
| 471 | } | ||||
| 472 | 1 | 6µs | 1 | 1.02ms | ); # spent 1.02ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 473 | |||||
| 474 | $meta->$add_core_type( | ||||
| 475 | { | ||||
| 476 | name => "FileHandle", | ||||
| 477 | parent => $_ref, | ||||
| 478 | constraint => sub { | ||||
| 479 | ( ref( $_ ) && Scalar::Util::openhandle( $_ ) ) | ||||
| 480 | or ( blessed( $_ ) && $_->isa( "IO::Handle" ) ); | ||||
| 481 | }, | ||||
| 482 | # spent 19µs (14+5) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:488] which was called 2 times, avg 10µs/call:
# 2 times (14µs+5µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 10µs/call | ||||
| 483 | 2 | 11µs | 2 | 5µ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 | } | ||||
| 490 | 1 | 8µs | 1 | 900µs | ); # spent 900µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 491 | |||||
| 492 | my $_arr = $meta->$add_core_type( | ||||
| 493 | { | ||||
| 494 | name => "ArrayRef", | ||||
| 495 | parent => $_ref, | ||||
| 496 | constraint => sub { ref $_ eq "ARRAY" }, | ||||
| 497 | # spent 93µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:501] which was called 38 times, avg 2µs/call:
# 38 times (93µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||||
| 498 | 38 | 144µ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 | ||||
| 508 | 4 | 18µs | 4 | 13µ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 | } | ||||
| 512 | 1 | 19µs | 5 | 1.02ms | ); # spent 1.02ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
# spent 6µs making 4 calls to Types::Standard::LazyLoad, avg 2µs/call |
| 513 | |||||
| 514 | my $_hash = $meta->$add_core_type( | ||||
| 515 | { | ||||
| 516 | name => "HashRef", | ||||
| 517 | parent => $_ref, | ||||
| 518 | constraint => sub { ref $_ eq "HASH" }, | ||||
| 519 | # spent 152µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:523] which was called 81 times, avg 2µs/call:
# 81 times (152µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 2µs/call | ||||
| 520 | 81 | 196µs | _HAS_REFUTILXS && !$Type::Tiny::AvoidCallbacks | ||
| 521 | ? "Ref::Util::XS::is_plain_hashref($_[1])" | ||||
| 522 | : "ref($_[1]) eq 'HASH'"; | ||||
| 523 | }, | ||||
| 524 | constraint_generator => LazyLoad( HashRef => 'constraint_generator' ), | ||||
| 525 | inline_generator => LazyLoad( HashRef => 'inline_generator' ), | ||||
| 526 | deep_explanation => LazyLoad( HashRef => 'deep_explanation' ), | ||||
| 527 | coercion_generator => LazyLoad( HashRef => 'coercion_generator' ), | ||||
| 528 | type_default => sub { return {}; }, | ||||
| 529 | # spent 65µs (39+26) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:532] which was called 8 times, avg 8µs/call:
# 8 times (39µs+26µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm, avg 8µs/call | ||||
| 530 | 8 | 30µs | 8 | 26µs | return $Type::Tiny::parameterize_type->type_default if @_ < 2; # spent 26µs making 8 calls to Type::Tiny::type_default, avg 3µs/call |
| 531 | return undef; | ||||
| 532 | }, | ||||
| 533 | 1 | 23µs | 7 | 1.01ms | my_methods => { # spent 1.00ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
# spent 5µs making 6 calls to Types::Standard::LazyLoad, avg 833ns/call |
| 534 | hashref_allows_key => LazyLoad( HashRef => 'hashref_allows_key' ), | ||||
| 535 | hashref_allows_value => LazyLoad( HashRef => 'hashref_allows_value' ), | ||||
| 536 | }, | ||||
| 537 | } | ||||
| 538 | ); | ||||
| 539 | |||||
| 540 | $meta->$add_core_type( | ||||
| 541 | { | ||||
| 542 | name => "ScalarRef", | ||||
| 543 | parent => $_ref, | ||||
| 544 | constraint => sub { ref $_ eq "SCALAR" or ref $_ eq "REF" }, | ||||
| 545 | 2 | 107µs | # spent 10µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:545] which was called 2 times, avg 5µs/call:
# 2 times (10µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 5µs/call | ||
| 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 | } | ||||
| 552 | 1 | 15µs | 5 | 1.24ms | ); # spent 1.24ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
# spent 5µs making 4 calls to Types::Standard::LazyLoad, avg 1µs/call |
| 553 | |||||
| 554 | my $_obj = $meta->$add_core_type( | ||||
| 555 | { | ||||
| 556 | name => "Object", | ||||
| 557 | parent => $_ref, | ||||
| 558 | constraint => sub { blessed $_ }, | ||||
| 559 | # spent 13µs within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:566] which was called 5 times, avg 3µs/call:
# 5 times (13µs+0s) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 3µs/call | ||||
| 560 | 5 | 16µ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 | }, | ||||
| 567 | 1 | 8µs | 1 | 1.10ms | is_object => 1, # spent 1.10ms making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 568 | } | ||||
| 569 | ); | ||||
| 570 | |||||
| 571 | $meta->$add_core_type( | ||||
| 572 | { | ||||
| 573 | name => "Maybe", | ||||
| 574 | parent => $_item, | ||||
| 575 | constraint_generator => sub { | ||||
| 576 | return $meta->get_type( 'Maybe' ) unless @_; | ||||
| 577 | |||||
| 578 | my $param = Types::TypeTiny::to_TypeTiny( shift ); | ||||
| 579 | Types::TypeTiny::is_TypeTiny( $param ) | ||||
| 580 | or _croak( | ||||
| 581 | "Parameter to Maybe[`a] expected to be a type constraint; got $param" ); | ||||
| 582 | |||||
| 583 | my $param_compiled_check = $param->compiled_check; | ||||
| 584 | my @xsub; | ||||
| 585 | if ( Type::Tiny::_USE_XS ) { | ||||
| 586 | my $paramname = Type::Tiny::XS::is_known( $param_compiled_check ); | ||||
| 587 | push @xsub, Type::Tiny::XS::get_coderef_for( "Maybe[$paramname]" ) | ||||
| 588 | if $paramname; | ||||
| 589 | } | ||||
| 590 | elsif ( Type::Tiny::_USE_MOUSE and $param->_has_xsub ) { | ||||
| 591 | require Mouse::Util::TypeConstraints; | ||||
| 592 | my $maker = "Mouse::Util::TypeConstraints"->can( "_parameterize_Maybe_for" ); | ||||
| 593 | push @xsub, $maker->( $param ) if $maker; | ||||
| 594 | } | ||||
| 595 | |||||
| 596 | return ( | ||||
| 597 | sub { | ||||
| 598 | my $value = shift; | ||||
| 599 | return !!1 unless defined $value; | ||||
| 600 | return $param->check( $value ); | ||||
| 601 | }, | ||||
| 602 | @xsub, | ||||
| 603 | ); | ||||
| 604 | }, | ||||
| 605 | inline_generator => sub { | ||||
| 606 | my $param = shift; | ||||
| 607 | |||||
| 608 | my $param_compiled_check = $param->compiled_check; | ||||
| 609 | my $xsubname; | ||||
| 610 | if ( Type::Tiny::_USE_XS ) { | ||||
| 611 | my $paramname = Type::Tiny::XS::is_known( $param_compiled_check ); | ||||
| 612 | $xsubname = Type::Tiny::XS::get_subname_for( "Maybe[$paramname]" ); | ||||
| 613 | } | ||||
| 614 | |||||
| 615 | return unless $param->can_be_inlined; | ||||
| 616 | return sub { | ||||
| 617 | my $v = $_[1]; | ||||
| 618 | return "$xsubname\($v\)" if $xsubname && !$Type::Tiny::AvoidCallbacks; | ||||
| 619 | my $param_check = $param->inline_check( $v ); | ||||
| 620 | "!defined($v) or $param_check"; | ||||
| 621 | }; | ||||
| 622 | }, | ||||
| 623 | deep_explanation => sub { | ||||
| 624 | my ( $type, $value, $varname ) = @_; | ||||
| 625 | my $param = $type->parameters->[0]; | ||||
| 626 | |||||
| 627 | return [ | ||||
| 628 | sprintf( '%s is defined', Type::Tiny::_dd( $value ) ), | ||||
| 629 | sprintf( | ||||
| 630 | '"%s" constrains the value with "%s" if it is defined', $type, $param | ||||
| 631 | ), | ||||
| 632 | @{ $param->validate_explain( $value, $varname ) }, | ||||
| 633 | ]; | ||||
| 634 | }, | ||||
| 635 | coercion_generator => sub { | ||||
| 636 | my ( $parent, $child, $param ) = @_; | ||||
| 637 | return unless $param->has_coercion; | ||||
| 638 | return $param->coercion; | ||||
| 639 | }, | ||||
| 640 | type_default => sub { return undef; }, | ||||
| 641 | type_default_generator => sub { | ||||
| 642 | $_[0]->type_default || $Type::Tiny::parameterize_type->type_default ; | ||||
| 643 | }, | ||||
| 644 | } | ||||
| 645 | 1 | 17µs | 1 | 890µs | ); # spent 890µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127] |
| 646 | |||||
| 647 | my $_map = $meta->$add_core_type( | ||||
| 648 | { | ||||
| 649 | name => "Map", | ||||
| 650 | parent => $_hash, | ||||
| 651 | constraint_generator => LazyLoad( Map => 'constraint_generator' ), | ||||
| 652 | inline_generator => LazyLoad( Map => 'inline_generator' ), | ||||
| 653 | deep_explanation => LazyLoad( Map => 'deep_explanation' ), | ||||
| 654 | coercion_generator => LazyLoad( Map => 'coercion_generator' ), | ||||
| 655 | my_methods => { | ||||
| 656 | hashref_allows_key => LazyLoad( Map => 'hashref_allows_key' ), | ||||
| 657 | hashref_allows_value => LazyLoad( Map => 'hashref_allows_value' ), | ||||
| 658 | }, | ||||
| 659 | # spent 27µs (3+24) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:661] which was called:
# once (3µs+24µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm | ||||
| 660 | 1 | 5µs | 1 | 24µs | return $Type::Tiny::parameterize_type->type_default; # spent 24µs making 1 call to Type::Tiny::type_default |
| 661 | }, | ||||
| 662 | } | ||||
| 663 | 1 | 14µs | 7 | 849µs | ); # spent 842µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
# spent 7µs making 6 calls to Types::Standard::LazyLoad, avg 1µs/call |
| 664 | |||||
| 665 | my $_Optional = $meta->add_type( | ||||
| 666 | { | ||||
| 667 | name => "Optional", | ||||
| 668 | parent => $_item, | ||||
| 669 | # spent 32µs (16+16) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:678] which was called:
# once (16µs+16µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm | ||||
| 670 | 1 | 1µs | return $meta->get_type( 'Optional' ) unless @_; | ||
| 671 | |||||
| 672 | 1 | 1µs | 1 | 4µs | my $param = Types::TypeTiny::to_TypeTiny( shift ); # spent 4µs making 1 call to Types::TypeTiny::to_TypeTiny |
| 673 | 1 | 1µs | 1 | 12µs | Types::TypeTiny::is_TypeTiny( $param ) # spent 12µs making 1 call to Types::TypeTiny::is_TypeTiny |
| 674 | or _croak( | ||||
| 675 | "Parameter to Optional[`a] expected to be a type constraint; got $param" ); | ||||
| 676 | |||||
| 677 | sub { $param->check( $_[0] ) } | ||||
| 678 | 1 | 6µs | }, | ||
| 679 | # spent 28µs (8+20) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:686] which was called:
# once (8µs+20µs) by Type::Tiny::parameterize at line 1057 of Type/Tiny.pm | ||||
| 680 | 1 | 0s | my $param = shift; | ||
| 681 | 1 | 2µs | 1 | 20µs | return unless $param->can_be_inlined; # spent 20µs making 1 call to Type::Tiny::can_be_inlined |
| 682 | # spent 1.56ms (114µs+1.44) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:685] which was called 57 times, avg 27µs/call:
# 57 times (114µs+1.44ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 27µs/call | ||||
| 683 | 57 | 8µs | my $v = $_[1]; | ||
| 684 | 57 | 83µs | 57 | 0s | $param->inline_check( $v ); # spent 1.44ms making 57 calls to Type::Tiny::inline_check, avg 25µs/call, recursion: max depth 2, sum of overlapping time 1.44ms |
| 685 | 1 | 5µs | }; | ||
| 686 | }, | ||||
| 687 | deep_explanation => sub { | ||||
| 688 | my ( $type, $value, $varname ) = @_; | ||||
| 689 | my $param = $type->parameters->[0]; | ||||
| 690 | |||||
| 691 | return [ | ||||
| 692 | sprintf( '%s exists', $varname ), | ||||
| 693 | sprintf( '"%s" constrains %s with "%s" if it exists', $type, $varname, $param ), | ||||
| 694 | @{ $param->validate_explain( $value, $varname ) }, | ||||
| 695 | ]; | ||||
| 696 | }, | ||||
| 697 | coercion_generator => sub { | ||||
| 698 | my ( $parent, $child, $param ) = @_; | ||||
| 699 | return unless $param->has_coercion; | ||||
| 700 | return $param->coercion; | ||||
| 701 | }, | ||||
| 702 | # spent 8µs (5+3) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:704] which was called:
# once (5µs+3µs) by Type::Tiny::parameterize at line 1060 of Type/Tiny.pm | ||||
| 703 | 1 | 4µs | 1 | 3µs | return $_[0]->type_default; # spent 3µs making 1 call to Type::Tiny::type_default |
| 704 | }, | ||||
| 705 | } | ||||
| 706 | 1 | 11µs | 1 | 770µs | ); # spent 770µs making 1 call to Type::Library::add_type |
| 707 | |||||
| 708 | 1 | 0s | my $_slurpy; | ||
| 709 | $_slurpy = $meta->add_type( | ||||
| 710 | { | ||||
| 711 | name => "Slurpy", | ||||
| 712 | slurpy => 1, | ||||
| 713 | parent => $_item, | ||||
| 714 | # spent 248µs (46+202) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:737] which was called 2 times, avg 124µs/call:
# 2 times (46µs+202µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 124µs/call | ||||
| 715 | 2 | 0s | my $self = $_slurpy; | ||
| 716 | 2 | 1µs | 2 | 4µs | my $param = @_ ? Types::TypeTiny::to_TypeTiny(shift) : $_any; # spent 4µs making 2 calls to Types::TypeTiny::to_TypeTiny, avg 2µs/call |
| 717 | 2 | 3µs | 2 | 23µs | Types::TypeTiny::is_TypeTiny( $param ) # spent 23µs making 2 calls to Types::TypeTiny::is_TypeTiny, avg 12µs/call |
| 718 | or _croak( | ||||
| 719 | "Parameter to Slurpy[`a] expected to be a type constraint; got $param" ); | ||||
| 720 | |||||
| 721 | return $self->create_child_type( | ||||
| 722 | slurpy => 1, | ||||
| 723 | display_name => $self->name_generator->( $self, $param ), | ||||
| 724 | parameters => [ $param ], | ||||
| 725 | constraint => sub { $param->check( $_[0] ) }, | ||||
| 726 | type_default => $param->type_default, | ||||
| 727 | # spent 2.35ms (14µs+2.33) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:732] which was called 2 times, avg 1.17ms/call:
# 2 times (14µs+2.33ms) by Type::Tiny::_build_coercion at line 504 of Type/Tiny.pm, avg 1.17ms/call | ||||
| 728 | 2 | 1µs | my $coercion = shift; | ||
| 729 | 2 | 3µs | 2 | 2.33ms | $coercion->add_type_coercions( @{ $param->coercion->type_coercion_map } ) # spent 2.33ms making 2 calls to Type::Tiny::has_coercion, avg 1.17ms/call |
| 730 | if $param->has_coercion; | ||||
| 731 | 2 | 7µs | 2 | 1µs | $coercion->freeze; # spent 1µs making 2 calls to Type::Coercion::freeze, avg 500ns/call |
| 732 | }, | ||||
| 733 | $param->can_be_inlined | ||||
| 734 | 2 | 5µs | 2 | 0s | # spent 1.13ms (6µs+1.13) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:734] which was called 2 times, avg 566µs/call:
# 2 times (6µs+1.13ms) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 566µs/call # spent 1.12ms making 2 calls to Type::Tiny::inline_check, avg 562µs/call, recursion: max depth 1, sum of overlapping time 1.12ms |
| 735 | 2 | 23µs | 10 | 175µs | : (), # spent 83µs making 2 calls to Type::Tiny::create_child_type, avg 42µs/call
# spent 60µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:524], avg 30µs/call
# spent 26µs making 2 calls to Type::Tiny::can_be_inlined, avg 13µs/call
# spent 4µs making 2 calls to Type::Tiny::name_generator, avg 2µs/call
# spent 2µs making 2 calls to Type::Tiny::type_default, avg 1µs/call |
| 736 | ); | ||||
| 737 | }, | ||||
| 738 | deep_explanation => sub { | ||||
| 739 | my ( $type, $value, $varname ) = @_; | ||||
| 740 | my $param = $type->parameters->[0]; | ||||
| 741 | return [ | ||||
| 742 | sprintf( '%s is slurpy', $varname ), | ||||
| 743 | @{ $param->validate_explain( $value, $varname ) }, | ||||
| 744 | ]; | ||||
| 745 | }, | ||||
| 746 | my_methods => { | ||||
| 747 | # spent 105µs (44+61) within Types::Standard::Slurpy::my_unslurpy which was called 6 times, avg 18µs/call:
# 6 times (44µs+61µs) by Type::Tiny::AUTOLOAD at line 1430 of Type/Tiny.pm, avg 18µs/call | ||||
| 748 | 6 | 3µs | my $self = shift; | ||
| 749 | $self->{_my_unslurpy} ||= $self->find_parent( | ||||
| 750 | 2 | 6µs | 2 | 3µs | # spent 8µs (5+3) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:750] which was called 2 times, avg 4µs/call:
# 2 times (5µs+3µs) by Type::Tiny::find_parent at line 744 of Type/Tiny.pm, avg 4µs/call # spent 3µs making 2 calls to Type::Tiny::parent, avg 2µs/call |
| 751 | 6 | 38µs | 8 | 61µs | )->type_parameter; # spent 41µs making 2 calls to Type::Tiny::find_parent, avg 20µs/call
# spent 15µs making 2 calls to Type::Tiny::type_parameter, avg 8µs/call
# spent 5µs making 4 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 1µs/call |
| 752 | }, | ||||
| 753 | 'slurp_into' => sub { | ||||
| 754 | my $self = shift; | ||||
| 755 | my $parameters = $self->find_parent( | ||||
| 756 | sub { $_->parent->{uniq} == $_slurpy->{uniq} } | ||||
| 757 | )->parameters; | ||||
| 758 | if ( $parameters->[1] ) { | ||||
| 759 | return $parameters->[1]; | ||||
| 760 | } | ||||
| 761 | my $constraint = $parameters->[0]; | ||||
| 762 | return 'HASH' | ||||
| 763 | if $constraint->is_a_type_of( HashRef() ) | ||||
| 764 | or $constraint->is_a_type_of( Map() ) | ||||
| 765 | or $constraint->is_a_type_of( Dict() ); | ||||
| 766 | return 'ARRAY'; | ||||
| 767 | }, | ||||
| 768 | }, | ||||
| 769 | } | ||||
| 770 | 1 | 16µs | 1 | 891µs | ); # spent 891µs making 1 call to Type::Library::add_type |
| 771 | |||||
| 772 | # spent 4.71ms (26µs+4.69) within Types::Standard::slurpy which was called 3 times, avg 1.57ms/call:
# once (6µs+3.96ms) by OpenAPI::Modern::BEGIN@26 at line 122 of JSON/Schema/Modern.pm
# once (13µs+672µs) by JSON::Schema::Modern::BEGIN@35 at line 79 of JSON/Schema/Modern/Document.pm
# once (7µs+53µs) by OpenAPI::Modern::BEGIN@26 at line 611 of JSON/Schema/Modern.pm | ||||
| 773 | 3 | 1µs | my $t = shift; | ||
| 774 | 3 | 8µs | 3 | 4.69ms | my $s = $_slurpy->of( $t ); # spent 4.69ms making 3 calls to Type::Tiny::of, avg 1.56ms/call |
| 775 | 3 | 1µs | $s->{slurpy} ||= 1; | ||
| 776 | 3 | 11µs | wantarray ? ( $s, @_ ) : $s; | ||
| 777 | } | ||||
| 778 | |||||
| 779 | $meta->$add_core_type( | ||||
| 780 | { | ||||
| 781 | name => "Tuple", | ||||
| 782 | parent => $_arr, | ||||
| 783 | # spent 60µs (26+34) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:786] which was called 2 times, avg 30µs/call:
# 2 times (26µs+34µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 30µs/call | ||||
| 784 | 2 | 2µs | my ( $s, @a ) = @_; | ||
| 785 | 2 | 16µs | 6 | 34µs | sprintf( '%s[%s]', $s, join q[,], @a ); # spent 34µs making 6 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 6µs/call |
| 786 | }, | ||||
| 787 | 1 | 12µs | 5 | 764µs | constraint_generator => LazyLoad( Tuple => 'constraint_generator' ), # spent 757µs making 1 call to Types::Standard::__ANON__[Types/Standard.pm:127]
# spent 7µs making 4 calls to Types::Standard::LazyLoad, avg 2µs/call |
| 788 | inline_generator => LazyLoad( Tuple => 'inline_generator' ), | ||||
| 789 | deep_explanation => LazyLoad( Tuple => 'deep_explanation' ), | ||||
| 790 | coercion_generator => LazyLoad( Tuple => 'coercion_generator' ), | ||||
| 791 | } | ||||
| 792 | ); | ||||
| 793 | |||||
| 794 | $meta->add_type( | ||||
| 795 | { | ||||
| 796 | name => "CycleTuple", | ||||
| 797 | parent => $_arr, | ||||
| 798 | name_generator => sub { | ||||
| 799 | my ( $s, @a ) = @_; | ||||
| 800 | sprintf( '%s[%s]', $s, join q[,], @a ); | ||||
| 801 | }, | ||||
| 802 | 1 | 11µs | 5 | 712µs | constraint_generator => LazyLoad( CycleTuple => 'constraint_generator' ), # spent 707µs making 1 call to Type::Library::add_type
# spent 5µs making 4 calls to Types::Standard::LazyLoad, avg 1µs/call |
| 803 | inline_generator => LazyLoad( CycleTuple => 'inline_generator' ), | ||||
| 804 | deep_explanation => LazyLoad( CycleTuple => 'deep_explanation' ), | ||||
| 805 | coercion_generator => LazyLoad( CycleTuple => 'coercion_generator' ), | ||||
| 806 | } | ||||
| 807 | ); | ||||
| 808 | |||||
| 809 | $meta->add_type( | ||||
| 810 | { | ||||
| 811 | name => "Dict", | ||||
| 812 | parent => $_hash, | ||||
| 813 | # spent 1.31ms (348µs+964µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] which was called 4 times, avg 328µs/call:
# 4 times (348µs+964µs) by Type::Tiny::parameterize at line 1050 of Type/Tiny.pm, avg 328µs/call | ||||
| 814 | 4 | 12µs | my ( $s, @p ) = @_; | ||
| 815 | 4 | 24µs | 12 | 752µs | my $l = @p # spent 672µs making 4 calls to Type::Tiny::is_strictly_a_type_of, avg 168µs/call
# spent 57µs making 4 calls to Types::TypeTiny::is_TypeTiny, avg 14µs/call
# spent 23µs making 4 calls to Types::Standard::Slurpy, avg 6µs/call |
| 816 | && Types::TypeTiny::is_TypeTiny( $p[-1] ) | ||||
| 817 | && $p[-1]->is_strictly_a_type_of( Types::Standard::Slurpy() ) | ||||
| 818 | ? pop(@p) | ||||
| 819 | : undef; | ||||
| 820 | 4 | 23µs | my %a = @p; | ||
| 821 | sprintf( | ||||
| 822 | '%s[%s%s]', $s, | ||||
| 823 | 4 | 219µs | 46 | 212µs | join( q[,], map sprintf( "%s=>%s", $_, $a{$_} ), sort keys %a ), # spent 196µs making 39 calls to Type::Tiny::__ANON__[Type/Tiny.pm:100], avg 5µs/call
# spent 14µs making 4 calls to Types::Standard::CORE:sort, avg 4µs/call
# spent 2µs making 3 calls to Type::Tiny::__ANON__[Type/Tiny.pm:101], avg 667ns/call |
| 824 | $l ? ",$l" : '' | ||||
| 825 | ); | ||||
| 826 | }, | ||||
| 827 | 1 | 19µs | 8 | 901µs | constraint_generator => LazyLoad( Dict => 'constraint_generator' ), # spent 897µs making 1 call to Type::Library::add_type
# spent 4µs making 7 calls to Types::Standard::LazyLoad, avg 571ns/call |
| 828 | inline_generator => LazyLoad( Dict => 'inline_generator' ), | ||||
| 829 | deep_explanation => LazyLoad( Dict => 'deep_explanation' ), | ||||
| 830 | coercion_generator => LazyLoad( Dict => 'coercion_generator' ), | ||||
| 831 | my_methods => { | ||||
| 832 | dict_is_slurpy => LazyLoad( Dict => 'dict_is_slurpy' ), | ||||
| 833 | hashref_allows_key => LazyLoad( Dict => 'hashref_allows_key' ), | ||||
| 834 | hashref_allows_value => LazyLoad( Dict => 'hashref_allows_value' ), | ||||
| 835 | }, | ||||
| 836 | } | ||||
| 837 | ); | ||||
| 838 | |||||
| 839 | $meta->add_type( | ||||
| 840 | { | ||||
| 841 | name => "Overload", | ||||
| 842 | parent => $_obj, | ||||
| 843 | constraint => sub { require overload; overload::Overloaded( $_ ) }, | ||||
| 844 | # spent 14µs (10+4) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:851] which was called 2 times, avg 7µs/call:
# 2 times (10µs+4µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 7µs/call | ||||
| 845 | $maybe_load_modules->( | ||||
| 846 | qw/ Scalar::Util overload /, | ||||
| 847 | 2 | 12µs | 2 | 4µs | $INC{'overload.pm'} # spent 4µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 2µs/call |
| 848 | ? "Scalar::Util::blessed($_[1]) and overload::Overloaded($_[1])" | ||||
| 849 | : "Scalar::Util::blessed($_[1]) and do { use overload (); overload::Overloaded($_[1]) }" | ||||
| 850 | ); | ||||
| 851 | }, | ||||
| 852 | constraint_generator => sub { | ||||
| 853 | return $meta->get_type( 'Overload' ) unless @_; | ||||
| 854 | |||||
| 855 | my @operations = map { | ||||
| 856 | Types::TypeTiny::is_StringLike( $_ ) | ||||
| 857 | ? "$_" | ||||
| 858 | : _croak( "Parameters to Overload[`a] expected to be a strings; got $_" ); | ||||
| 859 | } @_; | ||||
| 860 | |||||
| 861 | require overload; | ||||
| 862 | return sub { | ||||
| 863 | my $value = shift; | ||||
| 864 | for my $op ( @operations ) { | ||||
| 865 | return unless overload::Method( $value, $op ); | ||||
| 866 | } | ||||
| 867 | return !!1; | ||||
| 868 | } | ||||
| 869 | }, | ||||
| 870 | inline_generator => sub { | ||||
| 871 | my @operations = @_; | ||||
| 872 | return sub { | ||||
| 873 | require overload; | ||||
| 874 | my $v = $_[1]; | ||||
| 875 | $maybe_load_modules->( | ||||
| 876 | qw/ Scalar::Util overload /, | ||||
| 877 | join " and ", | ||||
| 878 | "Scalar::Util::blessed($v)", | ||||
| 879 | map "overload::Method($v, q[$_])", @operations | ||||
| 880 | ); | ||||
| 881 | }; | ||||
| 882 | }, | ||||
| 883 | 1 | 11µs | 1 | 832µs | is_object => 1, # spent 832µs making 1 call to Type::Library::add_type |
| 884 | } | ||||
| 885 | ); | ||||
| 886 | |||||
| 887 | 1 | 7µs | 3 | 767µs | $meta->add_type( # spent 764µs making 1 call to Type::Library::add_type
# spent 3µs making 2 calls to Types::Standard::LazyLoad, avg 2µs/call |
| 888 | { | ||||
| 889 | name => "StrMatch", | ||||
| 890 | parent => $_str, | ||||
| 891 | constraint_generator => LazyLoad( StrMatch => 'constraint_generator' ), | ||||
| 892 | inline_generator => LazyLoad( StrMatch => 'inline_generator' ), | ||||
| 893 | } | ||||
| 894 | ); | ||||
| 895 | |||||
| 896 | $meta->add_type( | ||||
| 897 | { | ||||
| 898 | name => "OptList", | ||||
| 899 | parent => $_arr, | ||||
| 900 | constraint => sub { | ||||
| 901 | for my $inner ( @$_ ) { | ||||
| 902 | return unless ref( $inner ) eq q(ARRAY); | ||||
| 903 | return unless @$inner == 2; | ||||
| 904 | return unless is_Str( $inner->[0] ); | ||||
| 905 | } | ||||
| 906 | return !!1; | ||||
| 907 | }, | ||||
| 908 | # spent 148µs (28+120) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:921] which was called 2 times, avg 74µs/call:
# 2 times (28µs+120µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 74µs/call | ||||
| 909 | 2 | 1µs | my ( $self, $var ) = @_; | ||
| 910 | 2 | 5µs | 4 | 4µs | my $Str_check = Str()->inline_check( '$inner->[0]' ); # spent 4µs making 2 calls to Types::Standard::Str, avg 2µs/call
# spent 116µs making 2 calls to Type::Tiny::inline_check, avg 58µs/call, recursion: max depth 1, sum of overlapping time 116µs |
| 911 | 2 | 1µs | my @code = 'do { my $ok = 1; '; | ||
| 912 | 2 | 2µs | push @code, sprintf( 'for my $inner (@{%s}) { no warnings; ', $var ); | ||
| 913 | 2 | 1µs | push @code, | ||
| 914 | sprintf( | ||||
| 915 | '($ok=0) && last unless ref($inner) eq q(ARRAY) && @$inner == 2 && (%s); ', | ||||
| 916 | $Str_check | ||||
| 917 | ); | ||||
| 918 | 2 | 1µs | push @code, '} '; | ||
| 919 | 2 | 1µs | push @code, '$ok }'; | ||
| 920 | 2 | 9µs | return ( undef, join( q( ), @code ) ); | ||
| 921 | }, | ||||
| 922 | type_default => sub { return [] }, | ||||
| 923 | } | ||||
| 924 | 1 | 8µs | 1 | 1.18ms | ); # spent 1.18ms making 1 call to Type::Library::add_type |
| 925 | |||||
| 926 | $meta->add_type( | ||||
| 927 | { | ||||
| 928 | name => "Tied", | ||||
| 929 | parent => $_ref, | ||||
| 930 | constraint => sub { | ||||
| 931 | !!tied( | ||||
| 932 | Scalar::Util::reftype( $_ ) eq 'HASH' ? %{$_} | ||||
| 933 | : Scalar::Util::reftype( $_ ) eq 'ARRAY' ? @{$_} | ||||
| 934 | : Scalar::Util::reftype( $_ ) =~ /^(SCALAR|REF)$/ ? ${$_} | ||||
| 935 | : undef | ||||
| 936 | ); | ||||
| 937 | }, | ||||
| 938 | # spent 101µs (24+77) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:945] which was called 2 times, avg 50µs/call:
# 2 times (24µs+77µs) by Type::Tiny::inline_check at line 895 of Type/Tiny.pm, avg 50µs/call | ||||
| 939 | 2 | 0s | my ( $self, $var ) = @_; | ||
| 940 | 2 | 20µs | 6 | 7µs | $maybe_load_modules->( # spent 7µs making 2 calls to Types::Standard::__ANON__[Types/Standard.pm:140], avg 4µs/call
# spent 70µs making 2 calls to Type::Tiny::inline_check, avg 35µs/call, recursion: max depth 1, sum of overlapping time 70µs
# spent 0s making 2 calls to Type::Tiny::parent, avg 0s/call |
| 941 | qw/ Scalar::Util /, | ||||
| 942 | $self->parent->inline_check( $var ) | ||||
| 943 | . " and !!tied(Scalar::Util::reftype($var) eq 'HASH' ? \%{$var} : Scalar::Util::reftype($var) eq 'ARRAY' ? \@{$var} : Scalar::Util::reftype($var) =~ /^(SCALAR|REF)\$/ ? \${$var} : undef)" | ||||
| 944 | ); | ||||
| 945 | }, | ||||
| 946 | name_generator => sub { | ||||
| 947 | my $self = shift; | ||||
| 948 | my $param = Types::TypeTiny::to_TypeTiny( shift ); | ||||
| 949 | unless ( Types::TypeTiny::is_TypeTiny( $param ) ) { | ||||
| 950 | Types::TypeTiny::is_StringLike( $param ) | ||||
| 951 | or _croak( "Parameter to Tied[`a] expected to be a class name; got $param" ); | ||||
| 952 | require B; | ||||
| 953 | return sprintf( "%s[%s]", $self, B::perlstring( $param ) ); | ||||
| 954 | } | ||||
| 955 | return sprintf( "%s[%s]", $self, $param ); | ||||
| 956 | }, | ||||
| 957 | 1 | 14µs | 3 | 1.27ms | constraint_generator => LazyLoad( Tied => 'constraint_generator' ), # spent 1.26ms making 1 call to Type::Library::add_type
# spent 5µs making 2 calls to Types::Standard::LazyLoad, avg 2µs/call |
| 958 | inline_generator => LazyLoad( Tied => 'inline_generator' ), | ||||
| 959 | } | ||||
| 960 | ); | ||||
| 961 | |||||
| 962 | $meta->add_type( | ||||
| 963 | { | ||||
| 964 | name => "InstanceOf", | ||||
| 965 | parent => $_obj, | ||||
| 966 | # spent 4.32ms (2.15+2.17) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:987] which was called 7 times, avg 617µs/call:
# 7 times (2.15ms+2.17ms) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 617µs/call | ||||
| 967 | 7 | 5µs | return $meta->get_type( 'InstanceOf' ) unless @_; | ||
| 968 | 7 | 676µs | require Type::Tiny::Class; | ||
| 969 | my @classes = map { | ||||
| 970 | 14 | 67µs | 21 | 619µs | Types::TypeTiny::is_TypeTiny( $_ ) # spent 547µs making 7 calls to Type::Tiny::Class::new, avg 78µs/call
# spent 63µs making 7 calls to Types::TypeTiny::is_TypeTiny, avg 9µs/call
# spent 9µs making 7 calls to B::perlstring, avg 1µs/call |
| 971 | ? $_ | ||||
| 972 | : "Type::Tiny::Class"->new( | ||||
| 973 | class => $_, | ||||
| 974 | display_name => sprintf( 'InstanceOf[%s]', B::perlstring( $_ ) ) | ||||
| 975 | ) | ||||
| 976 | } @_; | ||||
| 977 | 7 | 19µ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 | } | ||||
| 989 | 1 | 6µs | 1 | 948µs | ); # spent 948µs making 1 call to Type::Library::add_type |
| 990 | |||||
| 991 | $meta->add_type( | ||||
| 992 | { | ||||
| 993 | name => "ConsumerOf", | ||||
| 994 | parent => $_obj, | ||||
| 995 | constraint_generator => sub { | ||||
| 996 | return $meta->get_type( 'ConsumerOf' ) unless @_; | ||||
| 997 | require B; | ||||
| 998 | require Type::Tiny::Role; | ||||
| 999 | my @roles = map { | ||||
| 1000 | Types::TypeTiny::is_TypeTiny( $_ ) | ||||
| 1001 | ? $_ | ||||
| 1002 | : "Type::Tiny::Role"->new( | ||||
| 1003 | role => $_, | ||||
| 1004 | display_name => sprintf( 'ConsumerOf[%s]', B::perlstring( $_ ) ) | ||||
| 1005 | ) | ||||
| 1006 | } @_; | ||||
| 1007 | return $roles[0] if @roles == 1; | ||||
| 1008 | |||||
| 1009 | require Type::Tiny::Intersection; | ||||
| 1010 | return "Type::Tiny::Intersection"->new( | ||||
| 1011 | type_constraints => \@roles, | ||||
| 1012 | display_name => sprintf( | ||||
| 1013 | 'ConsumerOf[%s]', join q[,], map B::perlstring( $_->role ), @roles | ||||
| 1014 | ), | ||||
| 1015 | ); | ||||
| 1016 | }, | ||||
| 1017 | } | ||||
| 1018 | 1 | 7µs | 1 | 956µs | ); # spent 956µs making 1 call to Type::Library::add_type |
| 1019 | |||||
| 1020 | $meta->add_type( | ||||
| 1021 | { | ||||
| 1022 | name => "HasMethods", | ||||
| 1023 | parent => $_obj, | ||||
| 1024 | # spent 1.89ms (1.64+252µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1033] which was called:
# once (1.64ms+252µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm | ||||
| 1025 | 1 | 1µs | return $meta->get_type( 'HasMethods' ) unless @_; | ||
| 1026 | 1 | 1µs | require B; | ||
| 1027 | 1 | 544µs | require Type::Tiny::Duck; | ||
| 1028 | 1 | 20µs | 3 | 112µs | return "Type::Tiny::Duck"->new( # spent 108µs making 1 call to Type::Tiny::Duck::new
# spent 4µs making 2 calls to B::perlstring, avg 2µs/call |
| 1029 | methods => \@_, | ||||
| 1030 | display_name => | ||||
| 1031 | sprintf( 'HasMethods[%s]', join q[,], map B::perlstring( $_ ), @_ ), | ||||
| 1032 | ); | ||||
| 1033 | }, | ||||
| 1034 | } | ||||
| 1035 | 1 | 6µs | 1 | 604µs | ); # spent 604µs making 1 call to Type::Library::add_type |
| 1036 | |||||
| 1037 | $meta->add_type( | ||||
| 1038 | { | ||||
| 1039 | name => "Enum", | ||||
| 1040 | parent => $_str, | ||||
| 1041 | # spent 3.78ms (3.28+501µs) within Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:1059] which was called 4 times, avg 945µs/call:
# 4 times (3.28ms+501µs) by Type::Tiny::parameterize at line 1044 of Type/Tiny.pm, avg 945µs/call | ||||
| 1042 | 4 | 1µs | return $meta->get_type( 'Enum' ) unless @_; | ||
| 1043 | 4 | 7µs | my $coercion; | ||
| 1044 | 4 | 21µs | 4 | 2µ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 | } | ||||
| 1052 | 4 | 3µs | require B; | ||
| 1053 | 4 | 477µs | require Type::Tiny::Enum; | ||
| 1054 | 4 | 89µs | 22 | 330µs | return "Type::Tiny::Enum"->new( # spent 314µs making 4 calls to Type::Tiny::Enum::new, avg 78µs/call
# spent 16µs making 18 calls to B::perlstring, avg 889ns/call |
| 1055 | values => \@_, | ||||
| 1056 | display_name => sprintf( 'Enum[%s]', join q[,], map B::perlstring( $_ ), @_ ), | ||||
| 1057 | $coercion ? ( coercion => $coercion ) : (), | ||||
| 1058 | ); | ||||
| 1059 | }, | ||||
| 1060 | 1 | 5µs | 1 | 485µs | type_default => undef, # spent 485µs making 1 call to Type::Library::add_type |
| 1061 | } | ||||
| 1062 | ); | ||||
| 1063 | |||||
| 1064 | 1 | 13µs | 2 | 336µs | $meta->add_coercion( # spent 330µs making 1 call to Type::Library::add_coercion
# spent 6µs making 1 call to Type::Library::get_type |
| 1065 | { | ||||
| 1066 | name => "MkOpt", | ||||
| 1067 | type_constraint => $meta->get_type( "OptList" ), | ||||
| 1068 | type_coercion_map => [ | ||||
| 1069 | $_arr, q{ Exporter::Tiny::mkopt($_) }, | ||||
| 1070 | $_hash, q{ Exporter::Tiny::mkopt($_) }, | ||||
| 1071 | $_undef, q{ [] }, | ||||
| 1072 | ], | ||||
| 1073 | } | ||||
| 1074 | ); | ||||
| 1075 | |||||
| 1076 | $meta->add_coercion( | ||||
| 1077 | { | ||||
| 1078 | name => "Join", | ||||
| 1079 | type_constraint => $_str, | ||||
| 1080 | coercion_generator => sub { | ||||
| 1081 | my ( $self, $target, $sep ) = @_; | ||||
| 1082 | Types::TypeTiny::is_StringLike( $sep ) | ||||
| 1083 | or _croak( "Parameter to Join[`a] expected to be a string; got $sep" ); | ||||
| 1084 | require B; | ||||
| 1085 | $sep = B::perlstring( $sep ); | ||||
| 1086 | return ( ArrayRef(), qq{ join($sep, \@\$_) } ); | ||||
| 1087 | }, | ||||
| 1088 | } | ||||
| 1089 | 1 | 5µs | 1 | 169µs | ); # spent 169µs making 1 call to Type::Library::add_coercion |
| 1090 | |||||
| 1091 | $meta->add_coercion( | ||||
| 1092 | { | ||||
| 1093 | name => "Split", | ||||
| 1094 | type_constraint => $_arr, | ||||
| 1095 | coercion_generator => sub { | ||||
| 1096 | my ( $self, $target, $re ) = @_; | ||||
| 1097 | ref( $re ) eq q(Regexp) | ||||
| 1098 | or _croak( | ||||
| 1099 | "Parameter to Split[`a] expected to be a regular expresssion; got $re" ); | ||||
| 1100 | my $regexp_string = "$re"; | ||||
| 1101 | $regexp_string =~ s/\\\//\\\\\//g; # toothpicks | ||||
| 1102 | return ( Str(), qq{ [split /$regexp_string/, \$_] } ); | ||||
| 1103 | }, | ||||
| 1104 | } | ||||
| 1105 | 1 | 2µs | 1 | 158µs | ); # spent 158µs making 1 call to Type::Library::add_coercion |
| 1106 | |||||
| 1107 | 1 | 3µs | 2 | 1.63ms | __PACKAGE__->meta->make_immutable; # spent 1.63ms making 1 call to Type::Library::make_immutable
# spent 2µs making 1 call to Type::Library::meta |
| 1108 | |||||
| 1109 | 1 | 86µs | 1; | ||
| 1110 | |||||
| 1111 | __END__ | ||||
# spent 14µs within Types::Standard::CORE:sort which was called 4 times, avg 4µs/call:
# 4 times (14µs+0s) by Types::Standard::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Types/Standard.pm:826] at line 823, avg 4µs/call |