Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm |
Statements | Executed 10248 statements in 38.8ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
113 | 1 | 1 | 36.0ms | 41.3ms | _clean_eval | Sub::Quote::
134 | 7 | 3 | 4.78ms | 58.5ms | quote_sub | Sub::Quote::
1091 | 15 | 4 | 4.58ms | 6.04ms | quotify | Sub::Quote::
113 | 2 | 1 | 3.54ms | 53.2ms | unquote_sub | Sub::Quote::
113 | 1 | 1 | 3.24ms | 5.16ms | capture_unroll | Sub::Quote::
1 | 1 | 1 | 2.58ms | 2.96ms | BEGIN@8 | Sub::Quote::
113 | 1 | 1 | 1.34ms | 2.92ms | _context | Sub::Quote::
769 | 5 | 1 | 968µs | 968µs | CORE:match (opcode) | Sub::Quote::
107 | 2 | 2 | 639µs | 1.03ms | sanitize_identifier | Sub::Quote::
214 | 2 | 1 | 540µs | 540µs | CORE:subst (opcode) | Sub::Quote::
182 | 1 | 1 | 219µs | 219µs | CORE:substcont (opcode) | Sub::Quote::
34 | 1 | 1 | 147µs | 147µs | quoted_from_sub | Sub::Quote::
1 | 1 | 1 | 29µs | 30µs | BEGIN@14 | Sub::Quote::
1 | 1 | 1 | 23µs | 26µs | BEGIN@5 | Sub::Quote::
1 | 1 | 1 | 16µs | 30µs | BEGIN@348 | Sub::Quote::
6 | 1 | 1 | 16µs | 2.92ms | __ANON__[:232] | Sub::Quote::
1 | 1 | 1 | 8µs | 31µs | BEGIN@65 | Sub::Quote::
1 | 1 | 1 | 8µs | 22µs | BEGIN@9 | Sub::Quote::
1 | 1 | 1 | 7µs | 11µs | BEGIN@10 | Sub::Quote::
1 | 1 | 1 | 6µs | 28µs | BEGIN@6 | Sub::Quote::
1 | 1 | 1 | 5µs | 21µs | BEGIN@11 | Sub::Quote::
1 | 1 | 1 | 3µs | 3µs | BEGIN@12 | Sub::Quote::
1 | 1 | 1 | 3µs | 3µs | BEGIN@13 | Sub::Quote::
1 | 1 | 1 | 1µs | 1µs | __ANON__ (xsub) | Sub::Quote::
0 | 0 | 0 | 0s | 0s | CLONE | Sub::Quote::
0 | 0 | 0 | 0s | 0s | __ANON__[:35] | Sub::Quote::
0 | 0 | 0 | 0s | 0s | __ANON__[:36] | Sub::Quote::
0 | 0 | 0 | 0s | 0s | __ANON__[:37] | Sub::Quote::
0 | 0 | 0 | 0s | 0s | inlinify | Sub::Quote::
0 | 0 | 0 | 0s | 0s | qsub | Sub::Quote::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Sub::Quote; | ||||
2 | |||||
3 | 113 | 12.3ms | # spent 41.3ms (36.0+5.32) within Sub::Quote::_clean_eval which was called 113 times, avg 365µs/call:
# 113 times (36.0ms+5.32ms) by Sub::Quote::unquote_sub at line 353, avg 365µs/call # spent 2.12s executing statements in string eval # includes 2.03s spent executing 72045 calls to 8 subs defined therein. # spent 556ms executing statements in string eval # includes 306ms spent executing 372481 calls to 3 subs defined therein. # spent 450ms executing statements in string eval # includes 367ms spent executing 46915 calls to 3 subs defined therein. # spent 297ms executing statements in string eval # includes 270ms spent executing 39140 calls to 3 subs defined therein. # spent 213ms executing statements in string eval # includes 160ms spent executing 94453 calls to 3 subs defined therein. # spent 202ms executing statements in string eval # includes 225ms spent executing 25864 calls to 3 subs defined therein. # spent 174ms executing statements in string eval # includes 131ms spent executing 46958 calls to 4 subs defined therein. # spent 156ms executing statements in string eval # includes 150ms spent executing 4227 calls to 10 subs defined therein. # spent 136ms executing statements in string eval # includes 105ms spent executing 39233 calls to 4 subs defined therein. # spent 120ms executing statements in string eval # includes 92.0ms spent executing 47935 calls to 3 subs defined therein. # spent 97.8ms executing statements in string eval # includes 71.7ms spent executing 25865 calls to 4 subs defined therein. # spent 21.3ms executing statements in string eval # includes 22.0ms spent executing 2232 calls to 3 subs defined therein. # spent 17.8ms executing statements in string eval # includes 11.9ms spent executing 9247 calls to 3 subs defined therein. # spent 17.3ms executing statements in string eval # includes 10.9ms spent executing 9246 calls to 3 subs defined therein. # spent 10.5ms executing statements in string eval # includes 7.64ms spent executing 2234 calls to 4 subs defined therein. # spent 9.83ms executing statements in string eval # includes 7.58ms spent executing 760 calls to 3 subs defined therein. # spent 4.05ms executing statements in string eval # includes 2.74ms spent executing 2483 calls to 3 subs defined therein. # spent 3.59ms executing statements in string eval # includes 2.52ms spent executing 762 calls to 4 subs defined therein. # spent 2.95ms executing statements in string eval # includes 171µs spent executing 20 calls to 19 subs defined therein. # spent 2.49ms executing statements in string eval # includes 2.30ms spent executing 38 calls to 3 subs defined therein. # spent 2.21ms executing statements in string eval # includes 1.67ms spent executing 732 calls to 3 subs defined therein. # spent 2.19ms executing statements in string eval # includes 1.85ms spent executing 730 calls to 3 subs defined therein. # spent 2.12ms executing statements in string eval # includes 1.93ms spent executing 746 calls to 3 subs defined therein. # spent 1.54ms executing statements in string eval # includes 1.30ms spent executing 26 calls to 3 subs defined therein. # spent 1.51ms executing statements in string eval # includes 212µs spent executing 11 calls to 10 subs defined therein. # spent 1.23ms executing statements in string eval # includes 368µs spent executing 10 calls to 9 subs defined therein. # spent 1.15ms executing statements in string eval # includes 634µs spent executing 22 calls to 8 subs defined therein. # spent 676µs executing statements in string eval # includes 73µs spent executing 7 calls to 3 subs defined therein. # spent 647µs executing statements in string eval # includes 366µs spent executing 65 calls to 4 subs defined therein. # spent 555µs executing statements in string eval # includes 189µs spent executing 13 calls to 4 subs defined therein. # spent 553µs executing statements in string eval # includes 124µs spent executing 13 calls to 3 subs defined therein. # spent 527µs executing statements in string eval # includes 139µs spent executing 6 calls to 5 subs defined therein. # spent 502µs executing statements in string eval # includes 260µs spent executing 17 calls to 4 subs defined therein. # spent 479µs executing statements in string eval # includes 248µs spent executing 54 calls to 4 subs defined therein. # spent 436µs executing statements in string eval # includes 305µs spent executing 46 calls to 3 subs defined therein. # spent 411µs executing statements in string eval # includes 191µs spent executing 13 calls to 4 subs defined therein. # spent 390µs executing statements in string eval # includes 139µs spent executing 20 calls to 4 subs defined therein. # spent 360µs executing statements in string eval # includes 214µs spent executing 19 calls to 3 subs defined therein. # spent 343µs executing statements in string eval # includes 25µs spent executing 3 calls to 4 subs defined therein. # spent 335µs executing statements in string eval # includes 143µs spent executing 32 calls to 4 subs defined therein. # spent 314µs executing statements in string eval # includes 12µs spent executing 2 calls to 2 subs defined therein. # spent 302µs executing statements in string eval # includes 59µs spent executing 4 calls to 4 subs defined therein. # spent 292µs executing statements in string eval # includes 18µs spent executing 3 calls to 4 subs defined therein. # spent 291µs executing statements in string eval # includes 20µs spent executing 3 calls to 4 subs defined therein. # spent 290µs executing statements in string eval # includes 22µs spent executing 3 calls to 4 subs defined therein. # spent 283µs executing statements in string eval # includes 23µs spent executing 3 calls to 4 subs defined therein. # spent 261µs executing statements in string eval # includes 16µs spent executing 3 calls to 4 subs defined therein. # spent 252µs executing statements in string eval # includes 21µs spent executing 3 calls to 4 subs defined therein. # spent 250µs executing statements in string eval # includes 26µs spent executing 3 calls to 4 subs defined therein. # spent 239µs executing statements in string eval # includes 31µs spent executing 4 calls to 4 subs defined therein. # spent 229µs executing statements in string eval # includes 27µs spent executing 3 calls to 3 subs defined therein. # spent 226µs executing statements in string eval # includes 28µs spent executing 4 calls to 5 subs defined therein. # spent 222µs executing statements in string eval # includes 30µs spent executing 4 calls to 4 subs defined therein. # spent 214µs executing statements in string eval # includes 19µs spent executing 3 calls to 4 subs defined therein. # spent 209µs executing statements in string eval # includes 20µs spent executing 3 calls to 4 subs defined therein. # spent 209µs executing statements in string eval # includes 25µs spent executing 2 calls to 3 subs defined therein. # spent 201µs executing statements in string eval # includes 117µs spent executing 18 calls to 3 subs defined therein. # spent 189µs executing statements in string eval # includes 41µs spent executing 3 calls to 3 subs defined therein. # spent 185µs executing statements in string eval # includes 80µs spent executing 10 calls to 3 subs defined therein. # spent 185µs executing statements in string eval # includes 92µs spent executing 14 calls to 3 subs defined therein. # spent 183µs executing statements in string eval # includes 20µs spent executing 2 calls to 3 subs defined therein. # spent 179µs executing statements in string eval # includes 15µs spent executing 2 calls to 2 subs defined therein. # spent 178µs executing statements in string eval # includes 13µs spent executing 3 calls to 3 subs defined therein. # spent 174µs executing statements in string eval # includes 114µs spent executing 30 calls to 3 subs defined therein. # spent 163µs executing statements in string eval # includes 64µs spent executing 16 calls to 3 subs defined therein. # spent 158µs executing statements in string eval # includes 18µs spent executing 2 calls to 3 subs defined therein. # spent 152µs executing statements in string eval # includes 87µs spent executing 4 calls to 3 subs defined therein. # spent 152µs executing statements in string eval # includes 129µs spent executing 4 calls to 3 subs defined therein. # spent 148µs executing statements in string eval # includes 19µs spent executing 4 calls to 5 subs defined therein. # spent 139µs executing statements in string eval # includes 21µs spent executing 2 calls to 3 subs defined therein. # spent 138µs executing statements in string eval # includes 89µs spent executing 3 calls to 3 subs defined therein. # spent 137µs executing statements in string eval # includes 18µs spent executing 2 calls to 3 subs defined therein. # spent 136µs executing statements in string eval # includes 65µs spent executing 3 calls to 3 subs defined therein. # spent 134µs executing statements in string eval # includes 22µs spent executing 2 calls to 3 subs defined therein. # spent 130µs executing statements in string eval # includes 21µs spent executing 2 calls to 3 subs defined therein. # spent 129µs executing statements in string eval # includes 23µs spent executing 2 calls to 3 subs defined therein. # spent 129µs executing statements in string eval # includes 27µs spent executing 4 calls to 3 subs defined therein. # spent 129µs executing statements in string eval # includes 19µs spent executing 2 calls to 3 subs defined therein. # spent 125µs executing statements in string eval # includes 32µs spent executing 2 calls to 3 subs defined therein. # spent 125µs executing statements in string eval # includes 35µs spent executing 3 calls to 3 subs defined therein. # spent 123µs executing statements in string eval # includes 17µs spent executing 2 calls to 3 subs defined therein. # spent 123µs executing statements in string eval # includes 16µs spent executing 2 calls to 3 subs defined therein. # spent 122µs executing statements in string eval # includes 19µs spent executing 2 calls to 3 subs defined therein. # spent 119µs executing statements in string eval # includes 20µs spent executing 3 calls to 3 subs defined therein. # spent 117µs executing statements in string eval # includes 16µs spent executing 2 calls to 3 subs defined therein. # spent 115µs executing statements in string eval # includes 17µs spent executing 2 calls to 3 subs defined therein. # spent 114µs executing statements in string eval # includes 68µs spent executing 10 calls to 3 subs defined therein. # spent 112µs executing statements in string eval # includes 15µs spent executing 2 calls to 3 subs defined therein. # spent 111µs executing statements in string eval # includes 15µs spent executing 2 calls to 3 subs defined therein. # spent 111µs executing statements in string eval # includes 19µs spent executing 2 calls to 3 subs defined therein. # spent 108µs executing statements in string eval # includes 22µs spent executing 2 calls to 3 subs defined therein. # spent 107µs executing statements in string eval # includes 27µs spent executing 2 calls to 3 subs defined therein. # spent 107µs executing statements in string eval # includes 30µs spent executing 2 calls to 3 subs defined therein. # spent 105µs executing statements in string eval # includes 17µs spent executing 2 calls to 3 subs defined therein. # spent 104µs executing statements in string eval # includes 14µs spent executing 2 calls to 2 subs defined therein. # spent 103µs executing statements in string eval # includes 17µs spent executing 2 calls to 3 subs defined therein. # spent 102µs executing statements in string eval # includes 14µs spent executing 3 calls to 3 subs defined therein. # spent 101µs executing statements in string eval # includes 16µs spent executing 2 calls to 3 subs defined therein. # spent 99µs executing statements in string eval # includes 12µs spent executing 2 calls to 2 subs defined therein. # spent 99µs executing statements in string eval # includes 12µs spent executing 2 calls to 3 subs defined therein. # spent 99µs executing statements in string eval # includes 14µs spent executing 2 calls to 2 subs defined therein. # spent 95µs executing statements in string eval # includes 14µs spent executing 2 calls to 3 subs defined therein. # spent 93µs executing statements in string eval # includes 15µs spent executing 2 calls to 3 subs defined therein. # spent 91µs executing statements in string eval # includes 14µs spent executing 2 calls to 3 subs defined therein. # spent 89µs executing statements in string eval # includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 85µs executing statements in string eval # includes 12µs spent executing 2 calls to 3 subs defined therein. # spent 81µs executing statements in string eval # includes 12µs spent executing 2 calls to 3 subs defined therein. # spent 79µs executing statements in string eval # includes 10µs spent executing 2 calls to 3 subs defined therein. # spent 77µs executing statements in string eval # includes 14µs spent executing 2 calls to 3 subs defined therein. # spent 75µs executing statements in string eval # includes 20µs spent executing 3 calls to 3 subs defined therein. # spent 67µs executing statements in string eval # includes 16µs spent executing 2 calls to 3 subs defined therein. # spent 54µs executing statements in string eval # includes 8µs spent executing 2 calls to 3 subs defined therein. # spent 54µs executing statements in string eval # includes 10µs spent executing 2 calls to 3 subs defined therein. | ||
4 | |||||
5 | 2 | 27µs | 2 | 29µs | # spent 26µs (23+3) within Sub::Quote::BEGIN@5 which was called:
# once (23µs+3µs) by Method::Generate::Accessor::BEGIN@8 at line 5 # spent 26µs making 1 call to Sub::Quote::BEGIN@5
# spent 3µs making 1 call to strict::import |
6 | 2 | 17µs | 2 | 50µs | # spent 28µs (6+22) within Sub::Quote::BEGIN@6 which was called:
# once (6µs+22µs) by Method::Generate::Accessor::BEGIN@8 at line 6 # spent 28µs making 1 call to Sub::Quote::BEGIN@6
# spent 22µs making 1 call to warnings::import |
7 | |||||
8 | 2 | 536µs | 2 | 3.00ms | # spent 2.96ms (2.58+382µs) within Sub::Quote::BEGIN@8 which was called:
# once (2.58ms+382µs) by Method::Generate::Accessor::BEGIN@8 at line 8 # spent 2.96ms making 1 call to Sub::Quote::BEGIN@8
# spent 39µs making 1 call to Exporter::import |
9 | 2 | 22µs | 2 | 36µs | # spent 22µs (8+14) within Sub::Quote::BEGIN@9 which was called:
# once (8µs+14µs) by Method::Generate::Accessor::BEGIN@8 at line 9 # spent 22µs making 1 call to Sub::Quote::BEGIN@9
# spent 14µs making 1 call to Exporter::import |
10 | 2 | 18µs | 2 | 15µs | # spent 11µs (7+4) within Sub::Quote::BEGIN@10 which was called:
# once (7µs+4µs) by Method::Generate::Accessor::BEGIN@8 at line 10 # spent 11µs making 1 call to Sub::Quote::BEGIN@10
# spent 4µs making 1 call to Exporter::import |
11 | 2 | 32µs | 2 | 37µs | # spent 21µs (5+16) within Sub::Quote::BEGIN@11 which was called:
# once (5µs+16µs) by Method::Generate::Accessor::BEGIN@8 at line 11 # spent 21µs making 1 call to Sub::Quote::BEGIN@11
# spent 16µs making 1 call to Exporter::import |
12 | 1 | 13µs | 1 | 3µs | # spent 3µs within Sub::Quote::BEGIN@12 which was called:
# once (3µs+0s) by Method::Generate::Accessor::BEGIN@8 at line 12 # spent 3µs making 1 call to Sub::Quote::BEGIN@12 |
13 | 2 | 547µs | 1 | 3µs | # spent 3µs within Sub::Quote::BEGIN@13 which was called:
# once (3µs+0s) by Method::Generate::Accessor::BEGIN@8 at line 13 # spent 3µs making 1 call to Sub::Quote::BEGIN@13 |
14 | # spent 30µs (29+1) within Sub::Quote::BEGIN@14 which was called:
# once (29µs+1µs) by Method::Generate::Accessor::BEGIN@8 at line 38 | ||||
15 | 1 | 1µs | *_HAVE_IS_UTF8 = defined &utf8::is_utf8 ? sub(){1} : sub(){0}; | ||
16 | 1 | 1µs | *_HAVE_PERLSTRING = defined &B::perlstring ? sub(){1} : sub(){0}; | ||
17 | 1 | 8µs | 1 | 1µs | *_BAD_BACKSLASH_ESCAPE = _HAVE_PERLSTRING() && "$]" == 5.010_000 ? sub(){1} : sub(){0}; # spent 1µs making 1 call to Sub::Quote::__ANON__ |
18 | 1 | 1µs | *_HAVE_HEX_FLOAT = !$ENV{SUB_QUOTE_NO_HEX_FLOAT} && "$]" >= 5.022 ? sub(){1} : sub(){0}; | ||
19 | |||||
20 | # This may not be perfect, as we can't tell the format purely from the size | ||||
21 | # but it should cover the common cases, and other formats are more likely to | ||||
22 | # be less precise. | ||||
23 | 1 | 1µs | 1 | 9µs | my $nvsize = 8 * length pack 'F', 0; # spent 9µs making 1 call to main::CORE:pack |
24 | 1 | 0s | my $nvmantbits | ||
25 | = $nvsize == 16 ? 11 | ||||
26 | : $nvsize == 32 ? 24 | ||||
27 | : $nvsize == 64 ? 53 | ||||
28 | : $nvsize == 80 ? 64 | ||||
29 | : $nvsize == 128 ? 113 | ||||
30 | : $nvsize == 256 ? 237 | ||||
31 | : 237 # unknown float format | ||||
32 | ; | ||||
33 | 1 | 2µs | my $precision = int( log(2)/log(10)*$nvmantbits ); | ||
34 | |||||
35 | 1 | 5µs | *_NVSIZE = sub(){$nvsize}; | ||
36 | 1 | 5µs | *_NVMANTBITS = sub(){$nvmantbits}; | ||
37 | 1 | 5µs | *_FLOAT_PRECISION = sub(){$precision}; | ||
38 | 1 | 214µs | 1 | 30µs | } # spent 30µs making 1 call to Sub::Quote::BEGIN@14 |
39 | |||||
40 | 1 | 1µs | our $VERSION = '2.006006'; | ||
41 | 1 | 2µs | $VERSION =~ tr/_//d; | ||
42 | |||||
43 | 1 | 2µs | our @EXPORT = qw(quote_sub unquote_sub quoted_from_sub qsub); | ||
44 | 1 | 1µs | our @EXPORT_OK = qw(quotify capture_unroll inlinify sanitize_identifier); | ||
45 | |||||
46 | our %QUOTED; | ||||
47 | |||||
48 | 1 | 1µs | my %escape; | ||
49 | if (_BAD_BACKSLASH_ESCAPE) { | ||||
50 | %escape = ( | ||||
51 | (map +(chr($_) => sprintf '\x%02x', $_), 0 .. 0x31, 0x7f), | ||||
52 | "\t" => "\\t", | ||||
53 | "\n" => "\\n", | ||||
54 | "\r" => "\\r", | ||||
55 | "\f" => "\\f", | ||||
56 | "\b" => "\\b", | ||||
57 | "\a" => "\\a", | ||||
58 | "\e" => "\\e", | ||||
59 | (map +($_ => "\\$_"), qw(" \ $ @)), | ||||
60 | ); | ||||
61 | } | ||||
62 | |||||
63 | # spent 6.04ms (4.58+1.46) within Sub::Quote::quotify which was called 1091 times, avg 6µs/call:
# 333 times (1.29ms+481µs) by Sub::Quote::capture_unroll at line 142, avg 5µs/call
# 226 times (1.29ms+289µs) by Sub::Quote::_context at line 271, avg 7µs/call
# 82 times (344µs+144µs) by Method::Generate::Accessor::_generate_simple_get at line 395 of Method/Generate/Accessor.pm, avg 6µs/call
# 82 times (333µs+110µs) by Method::Generate::Accessor::_generate_simple_set at line 596 of Method/Generate/Accessor.pm, avg 5µs/call
# 82 times (230µs+67µs) by Method::Generate::Accessor::_generate_core_set at line 590 of Method/Generate/Accessor.pm, avg 4µs/call
# 73 times (232µs+103µs) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 19 of MooX/TypeTiny/Role/GenerateAccessor.pm, avg 5µs/call
# 55 times (151µs+55µs) by Method::Generate::Constructor::_assign_new at line 219 of Method/Generate/Constructor.pm, avg 4µs/call
# 51 times (158µs+39µs) by Method::Generate::Accessor::_wrap_attr_exception at line 478 of Method/Generate/Accessor.pm, avg 4µs/call
# 31 times (106µs+36µs) by Method::Generate::Accessor::_generate_simple_has at line 332 of Method/Generate/Accessor.pm, avg 5µs/call
# 17 times (56µs+26µs) by Method::Generate::Accessor::_attr_desc at line 441 of Method/Generate/Accessor.pm, avg 5µs/call
# 17 times (50µs+29µs) by Method::Generate::Accessor::_wrap_attr_exception at line 477 of Method/Generate/Accessor.pm, avg 5µs/call
# 14 times (74µs+29µs) by Method::Generate::Accessor::_generate_asserter at line 643 of Method/Generate/Accessor.pm, avg 7µs/call
# 13 times (29µs+10µs) by Method::Generate::Constructor::_check_required at line 238 of Method/Generate/Constructor.pm, avg 3µs/call
# 8 times (187µs+42µs) by Method::Generate::Constructor::_handle_subconstructor at line 167 of Method/Generate/Constructor.pm, avg 29µs/call
# 7 times (49µs+5µs) by Method::Generate::Accessor::_generate_get_default at line 376 of Method/Generate/Accessor.pm, avg 8µs/call | ||||
64 | 1091 | 184µs | my $value = $_[0]; | ||
65 | 2 | 2.72ms | 2 | 54µs | # spent 31µs (8+23) within Sub::Quote::BEGIN@65 which was called:
# once (8µs+23µs) by Method::Generate::Accessor::BEGIN@8 at line 65 # spent 31µs making 1 call to Sub::Quote::BEGIN@65
# spent 23µs making 1 call to warnings::unimport |
66 | ! defined $value ? 'undef()' | ||||
67 | # numeric detection | ||||
68 | : (!(_HAVE_IS_UTF8 && utf8::is_utf8($value)) | ||||
69 | && length( (my $dummy = '') & $value ) | ||||
70 | && 0 + $value eq $value | ||||
71 | ) ? ( | ||||
72 | $value != $value ? ( | ||||
73 | $value eq (9**9**9*0) | ||||
74 | ? '(9**9**9*0)' # nan | ||||
75 | : '(-(9**9**9*0))' # -nan | ||||
76 | ) | ||||
77 | : $value == 9**9**9 ? '(9**9**9)' # inf | ||||
78 | : $value == -9**9**9 ? '(-9**9**9)' # -inf | ||||
79 | : $value == 0 ? ( | ||||
80 | sprintf('%g', $value) eq '-0' ? '-0.0' : '0', | ||||
81 | ) | ||||
82 | : $value !~ /[e.]/i ? ( | ||||
83 | $value > 0 ? (sprintf '%u', $value) | ||||
84 | : (sprintf '%d', $value) | ||||
85 | ) | ||||
86 | : do { | ||||
87 | my $float = $value; | ||||
88 | my $max_factor = int( log( abs($value) ) / log(2) ) - _NVMANTBITS; | ||||
89 | my $ex_sign = $max_factor > 0 ? 1 : -1; | ||||
90 | FACTOR: for my $ex (0 .. abs($max_factor)) { | ||||
91 | my $num = $value / 2**($ex_sign * $ex); | ||||
92 | for my $precision (_FLOAT_PRECISION .. _FLOAT_PRECISION+2) { | ||||
93 | my $formatted = sprintf '%.'.$precision.'g', $num; | ||||
94 | $float = $formatted | ||||
95 | if $ex == 0; | ||||
96 | if ($formatted == $num) { | ||||
97 | if ($ex) { | ||||
98 | $float | ||||
99 | = $formatted | ||||
100 | . ($ex_sign == 1 ? '*' : '/') | ||||
101 | . ( | ||||
102 | $ex > _NVMANTBITS | ||||
103 | ? "2**$ex" | ||||
104 | : sprintf('%u', 2**$ex) | ||||
105 | ); | ||||
106 | } | ||||
107 | last FACTOR; | ||||
108 | } | ||||
109 | } | ||||
110 | if (_HAVE_HEX_FLOAT) { | ||||
111 | $float = sprintf '%a', $value; | ||||
112 | last FACTOR; | ||||
113 | } | ||||
114 | } | ||||
115 | "$float"; | ||||
116 | } | ||||
117 | ) | ||||
118 | : !length($value) && length( (my $dummy2 = '') & $value ) ? '(!1)' # false | ||||
119 | 1091 | 6.91ms | 2168 | 1.46ms | : _BAD_BACKSLASH_ESCAPE && _HAVE_IS_UTF8 && utf8::is_utf8($value) ? do { # spent 1.03ms making 968 calls to B::perlstring, avg 1µs/call
# spent 368µs making 1085 calls to utf8::is_utf8, avg 339ns/call
# spent 68µs making 115 calls to Sub::Quote::CORE:match, avg 591ns/call |
120 | $value =~ s/(["\$\@\\[:cntrl:]]|[^\x00-\x7f])/ | ||||
121 | $escape{$1} || sprintf('\x{%x}', ord($1)) | ||||
122 | /ge; | ||||
123 | qq["$value"]; | ||||
124 | } | ||||
125 | : _HAVE_PERLSTRING ? B::perlstring($value) | ||||
126 | : qq["\Q$value\E"]; | ||||
127 | } | ||||
128 | |||||
129 | # spent 1.03ms (639µs+388µs) within Sub::Quote::sanitize_identifier which was called 107 times, avg 10µs/call:
# 73 times (366µs+206µs) by MooX::TypeTiny::Role::GenerateAccessor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/MooX/TypeTiny/Role/GenerateAccessor.pm:33] at line 16 of MooX/TypeTiny/Role/GenerateAccessor.pm, avg 8µs/call
# 34 times (273µs+182µs) by Method::Generate::Accessor::_generate_call_code at line 529 of Method/Generate/Accessor.pm, avg 13µs/call | ||||
130 | 107 | 13µs | my $name = shift; | ||
131 | 107 | 876µs | 289 | 388µs | $name =~ s/([_\W])/sprintf('_%x', ord($1))/ge; # spent 219µs making 182 calls to Sub::Quote::CORE:substcont, avg 1µs/call
# spent 169µs making 107 calls to Sub::Quote::CORE:subst, avg 2µs/call |
132 | 107 | 208µs | $name; | ||
133 | } | ||||
134 | |||||
135 | # spent 5.16ms (3.24+1.93) within Sub::Quote::capture_unroll which was called 113 times, avg 46µs/call:
# 113 times (3.24ms+1.93ms) by Sub::Quote::unquote_sub at line 309, avg 46µs/call | ||||
136 | 113 | 66µs | my ($from, $captures, $indent) = @_; | ||
137 | join( | ||||
138 | '', | ||||
139 | map { | ||||
140 | 446 | 1.37ms | 333 | 159µs | /^([\@\%\$])/ # spent 159µs making 333 calls to Sub::Quote::CORE:match, avg 477ns/call |
141 | or croak "capture key should start with \@, \% or \$: $_"; | ||||
142 | 666 | 1.75ms | 333 | 1.77ms | (' ' x $indent).qq{my ${_} = ${1}{${from}->{${\quotify $_}}};\n}; # spent 1.77ms making 333 calls to Sub::Quote::quotify, avg 5µs/call |
143 | } keys %$captures | ||||
144 | ); | ||||
145 | } | ||||
146 | |||||
147 | sub inlinify { | ||||
148 | my ($code, $args, $extra, $local) = @_; | ||||
149 | $args = '()' | ||||
150 | if !defined $args; | ||||
151 | my $do = 'do { '.($extra||''); | ||||
152 | if ($code =~ s/^(\s*package\s+([a-zA-Z0-9:]+);)//) { | ||||
153 | $do .= $1; | ||||
154 | } | ||||
155 | if ($code =~ s{ | ||||
156 | \A((?:\#\ BEGIN\ quote_sub\ PRELUDE\n.*?\#\ END\ quote_sub\ PRELUDE\n)?\s*) | ||||
157 | (^\s*) my \s* \(([^)]+)\) \s* = \s* \@_; | ||||
158 | }{}xms) { | ||||
159 | my ($pre, $indent, $code_args) = ($1, $2, $3); | ||||
160 | $do .= $pre; | ||||
161 | if ($code_args ne $args) { | ||||
162 | $do .= $indent . 'my ('.$code_args.') = ('.$args.'); '; | ||||
163 | } | ||||
164 | } | ||||
165 | elsif ($local || $args ne '@_') { | ||||
166 | $do .= ($local ? 'local ' : '').'@_ = ('.$args.'); '; | ||||
167 | } | ||||
168 | $do.$code.' }'; | ||||
169 | } | ||||
170 | |||||
171 | # spent 58.5ms (4.78+53.7) within Sub::Quote::quote_sub which was called 134 times, avg 436µs/call:
# 41 times (1.40ms+13.1ms) by Method::Generate::Accessor::generate_method at line 238 of Method/Generate/Accessor.pm, avg 355µs/call
# 34 times (1.19ms+13.1ms) by Method::Generate::Accessor::generate_method at line 138 of Method/Generate/Accessor.pm, avg 420µs/call
# 27 times (831µs+524µs) by Type::Tiny::_overload_coderef at line 203 of Type/Tiny.pm, avg 50µs/call
# 14 times (488µs+9.09ms) by Method::Generate::Accessor::generate_method at line 250 of Method/Generate/Accessor.pm, avg 684µs/call
# 8 times (490µs+12.8ms) by Method::Generate::Constructor::generate_method at line 161 of Method/Generate/Constructor.pm, avg 1.66ms/call
# 7 times (227µs+3.50ms) by Method::Generate::Accessor::generate_method at line 179 of Method/Generate/Accessor.pm, avg 532µs/call
# 3 times (156µs+1.56ms) by Method::Generate::Accessor::generate_method at line 159 of Method/Generate/Accessor.pm, avg 573µs/call | ||||
172 | # HOLY DWIMMERY, BATMAN! | ||||
173 | # $name => $code => \%captures => \%options | ||||
174 | # $name => $code => \%captures | ||||
175 | # $name => $code | ||||
176 | # $code => \%captures => \%options | ||||
177 | # $code | ||||
178 | 134 | 146µs | my $options = | ||
179 | (ref($_[-1]) eq 'HASH' and ref($_[-2]) eq 'HASH') | ||||
180 | ? pop | ||||
181 | : {}; | ||||
182 | 134 | 70µs | my $captures = ref($_[-1]) eq 'HASH' ? pop : undef; | ||
183 | 134 | 86µs | undef($captures) if $captures && !keys %$captures; | ||
184 | 134 | 37µs | my $code = pop; | ||
185 | 134 | 37µs | my $name = $_[0]; | ||
186 | 134 | 63µs | if ($name) { | ||
187 | 107 | 32µs | my $subname = $name; | ||
188 | 107 | 767µs | 107 | 371µs | my $package = $subname =~ s/(.*)::// ? $1 : caller; # spent 371µs making 107 calls to Sub::Quote::CORE:subst, avg 3µs/call |
189 | 107 | 166µs | $name = join '::', $package, $subname; | ||
190 | 107 | 65µs | croak qq{package name "$package" too long!} | ||
191 | if length $package > 252; | ||||
192 | 107 | 600µs | 107 | 425µs | croak qq{package name "$package" is not valid!} # spent 425µs making 107 calls to Sub::Quote::CORE:match, avg 4µs/call |
193 | unless $package =~ /^[^\d\W]\w*(?:::\w+)*$/; | ||||
194 | 107 | 17µs | croak qq{sub name "$subname" too long!} | ||
195 | if length $subname > 252; | ||||
196 | 107 | 310µs | 107 | 141µs | croak qq{sub name "$subname" is not valid!} # spent 141µs making 107 calls to Sub::Quote::CORE:match, avg 1µs/call |
197 | unless $subname =~ /^[^\d\W]\w*$/; | ||||
198 | } | ||||
199 | 134 | 429µs | my @caller = caller(0); | ||
200 | 134 | 144µs | my ($attributes, $file, $line) = @{$options}{qw(attributes file line)}; | ||
201 | 134 | 49µs | if ($attributes) { | ||
202 | /\A\w+(?:\(.*\))?\z/s || croak "invalid attribute $_" | ||||
203 | for @$attributes; | ||||
204 | } | ||||
205 | my $quoted_info = { | ||||
206 | name => $name, | ||||
207 | code => $code, | ||||
208 | captures => $captures, | ||||
209 | package => (exists $options->{package} ? $options->{package} : $caller[0]), | ||||
210 | hints => (exists $options->{hints} ? $options->{hints} : $caller[8]), | ||||
211 | warning_bits => (exists $options->{warning_bits} ? $options->{warning_bits} : $caller[9]), | ||||
212 | 134 | 608µs | hintshash => (exists $options->{hintshash} ? $options->{hintshash} : $caller[10]), | ||
213 | ($attributes ? (attributes => $attributes) : ()), | ||||
214 | ($file ? (file => $file) : ()), | ||||
215 | ($line ? (line => $line) : ()), | ||||
216 | }; | ||||
217 | 134 | 23µs | my $unquoted; | ||
218 | 134 | 441µs | 134 | 154µs | weaken($quoted_info->{unquoted} = \$unquoted); # spent 154µs making 134 calls to Scalar::Util::weaken, avg 1µs/call |
219 | 134 | 52µs | if ($options->{no_defer}) { | ||
220 | 107 | 33µs | my $fake = \my $var; | ||
221 | 107 | 185µs | local $QUOTED{$fake} = $quoted_info; | ||
222 | 107 | 164µs | 107 | 50.3ms | my $sub = unquote_sub($fake); # spent 50.3ms making 107 calls to Sub::Quote::unquote_sub, avg 470µs/call |
223 | 107 | 204µs | 99 | 1.79ms | Sub::Defer::_install_coderef($name, $sub) if $name && !$options->{no_install}; # spent 1.79ms making 99 calls to Sub::Defer::_install_coderef, avg 18µs/call |
224 | 107 | 578µs | return $sub; | ||
225 | } | ||||
226 | else { | ||||
227 | my $deferred = defer_sub( | ||||
228 | ($options->{no_install} ? undef : $name), | ||||
229 | # spent 2.92ms (16µs+2.90) within Sub::Quote::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:232] which was called 6 times, avg 486µs/call:
# 6 times (16µs+2.90ms) by Sub::Defer::undefer_sub at line 85 of Sub/Defer.pm, avg 486µs/call | ||||
230 | $unquoted if 0; | ||||
231 | 6 | 17µs | 6 | 2.90ms | unquote_sub($quoted_info->{deferred}); # spent 2.90ms making 6 calls to Sub::Quote::unquote_sub, avg 484µs/call |
232 | }, | ||||
233 | { | ||||
234 | ($attributes ? ( attributes => $attributes ) : ()), | ||||
235 | 27 | 153µs | 27 | 465µs | ($name ? () : ( package => $quoted_info->{package} )), # spent 465µs making 27 calls to Sub::Defer::defer_sub, avg 17µs/call |
236 | }, | ||||
237 | ); | ||||
238 | 27 | 60µs | 27 | 14µs | weaken($quoted_info->{deferred} = $deferred); # spent 14µs making 27 calls to Scalar::Util::weaken, avg 519ns/call |
239 | 27 | 70µs | 27 | 11µs | weaken($QUOTED{$deferred} = $quoted_info); # spent 11µs making 27 calls to Scalar::Util::weaken, avg 407ns/call |
240 | 27 | 94µs | return $deferred; | ||
241 | } | ||||
242 | } | ||||
243 | |||||
244 | # spent 2.92ms (1.34+1.58) within Sub::Quote::_context which was called 113 times, avg 26µs/call:
# 113 times (1.34ms+1.58ms) by Sub::Quote::unquote_sub at line 309, avg 26µs/call | ||||
245 | 113 | 30µs | my $info = shift; | ||
246 | 113 | 294µs | $info->{context} ||= do { | ||
247 | my ($package, $hints, $warning_bits, $hintshash, $file, $line) | ||||
248 | 113 | 154µs | = @{$info}{qw(package hints warning_bits hintshash file line)}; | ||
249 | |||||
250 | 113 | 27µs | $line ||= 1 | ||
251 | if $file; | ||||
252 | |||||
253 | 113 | 39µs | my $line_mark = ''; | ||
254 | 113 | 20µs | if ($line) { | ||
255 | $line_mark = "#line ".($line-1); | ||||
256 | if ($file) { | ||||
257 | $line_mark .= qq{ "$file"}; | ||||
258 | } | ||||
259 | $line_mark .= "\n"; | ||||
260 | } | ||||
261 | |||||
262 | $info->{context} | ||||
263 | ="# BEGIN quote_sub PRELUDE\n" | ||||
264 | ."package $package;\n" | ||||
265 | ."BEGIN {\n" | ||||
266 | ." \$^H = ".quotify($hints).";\n" | ||||
267 | ." \${^WARNING_BITS} = ".quotify($warning_bits).";\n" | ||||
268 | ." \%^H = (\n" | ||||
269 | . join('', map | ||||
270 | " ".quotify($_)." => ".quotify($hintshash->{$_}).",\n", | ||||
271 | 113 | 605µs | 226 | 1.58ms | grep !(ref $hintshash->{$_} && $hintshash->{$_} =~ /\A(?:\w+(?:::\w+)*=)?[A-Z]+\(0x[[0-9a-fA-F]+\)\z/), # spent 1.58ms making 226 calls to Sub::Quote::quotify, avg 7µs/call |
272 | keys %$hintshash) | ||||
273 | ." );\n" | ||||
274 | ."}\n" | ||||
275 | .$line_mark | ||||
276 | ."# END quote_sub PRELUDE\n"; | ||||
277 | }; | ||||
278 | } | ||||
279 | |||||
280 | # spent 147µs within Sub::Quote::quoted_from_sub which was called 34 times, avg 4µs/call:
# 34 times (147µs+0s) by Method::Generate::Accessor::_generate_call_code at line 513 of Method/Generate/Accessor.pm, avg 4µs/call | ||||
281 | 34 | 11µs | my ($sub) = @_; | ||
282 | 34 | 116µs | my $quoted_info = $QUOTED{$sub||''} or return undef; | ||
283 | my ($name, $code, $captures, $unquoted, $deferred) | ||||
284 | = @{$quoted_info}{qw(name code captures unquoted deferred)}; | ||||
285 | $code = _context($quoted_info) . $code; | ||||
286 | $unquoted &&= $$unquoted; | ||||
287 | if (($deferred && $deferred eq $sub) | ||||
288 | || ($unquoted && $unquoted eq $sub)) { | ||||
289 | return [ $name, $code, $captures, $unquoted, $deferred ]; | ||||
290 | } | ||||
291 | return undef; | ||||
292 | } | ||||
293 | |||||
294 | # spent 53.2ms (3.54+49.7) within Sub::Quote::unquote_sub which was called 113 times, avg 471µs/call:
# 107 times (3.39ms+46.9ms) by Sub::Quote::quote_sub at line 222, avg 470µs/call
# 6 times (150µs+2.75ms) by Sub::Quote::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Sub/Quote.pm:232] at line 231, avg 484µs/call | ||||
295 | 113 | 30µs | my ($sub) = @_; | ||
296 | 113 | 83µs | my $quoted_info = $QUOTED{$sub} or return undef; | ||
297 | 113 | 72µs | my $unquoted = $quoted_info->{unquoted}; | ||
298 | 113 | 63µs | unless ($unquoted && $$unquoted) { | ||
299 | my ($name, $code, $captures, $package, $attributes) | ||||
300 | 113 | 148µs | = @{$quoted_info}{qw(name code captures package attributes)}; | ||
301 | |||||
302 | 113 | 405µs | 107 | 175µs | ($package, $name) = $name =~ /(.*)::(.*)/ # spent 175µs making 107 calls to Sub::Quote::CORE:match, avg 2µs/call |
303 | if $name; | ||||
304 | |||||
305 | 113 | 120µs | my %captures = $captures ? %$captures : (); | ||
306 | 113 | 65µs | $captures{'$_UNQUOTED'} = \$unquoted; | ||
307 | 113 | 44µs | $captures{'$_QUOTED'} = \$quoted_info; | ||
308 | |||||
309 | 113 | 604µs | 226 | 8.09ms | my $make_sub # spent 5.16ms making 113 calls to Sub::Quote::capture_unroll, avg 46µs/call
# spent 2.92ms making 113 calls to Sub::Quote::_context, avg 26µs/call |
310 | = "{\n" | ||||
311 | . capture_unroll("\$_[1]", \%captures, 2) | ||||
312 | . " package ${package};\n" | ||||
313 | . ( | ||||
314 | $name | ||||
315 | # disable the 'variable $x will not stay shared' warning since | ||||
316 | # we're not letting it escape from this scope anyway so there's | ||||
317 | # nothing trying to share it | ||||
318 | ? " no warnings 'closure';\n sub ${name} " | ||||
319 | : " \$\$_UNQUOTED = sub " | ||||
320 | ) | ||||
321 | . ($attributes ? join('', map ":$_ ", @$attributes) : '') . "{\n" | ||||
322 | . " (\$_QUOTED,\$_UNQUOTED) if 0;\n" | ||||
323 | . _context($quoted_info) | ||||
324 | . $code | ||||
325 | . " }".($name ? "\n \$\$_UNQUOTED = \\&${name}" : '') . ";\n" | ||||
326 | . "}\n" | ||||
327 | . "1;\n"; | ||||
328 | 113 | 67µs | if (my $debug = $ENV{SUB_QUOTE_DEBUG}) { | ||
329 | if ($debug =~ m{^([^\W\d]\w*(?:::\w+)*(?:::)?)$}) { | ||||
330 | my $filter = $1; | ||||
331 | my $match | ||||
332 | = $filter =~ /::$/ ? $package.'::' | ||||
333 | : $filter =~ /::/ ? $package.'::'.($name||'__ANON__') | ||||
334 | : ($name||'__ANON__'); | ||||
335 | warn $make_sub | ||||
336 | if $match eq $filter; | ||||
337 | } | ||||
338 | elsif ($debug =~ m{\A/(.*)/\z}s) { | ||||
339 | my $filter = $1; | ||||
340 | warn $make_sub | ||||
341 | if $code =~ $filter; | ||||
342 | } | ||||
343 | else { | ||||
344 | warn $make_sub; | ||||
345 | } | ||||
346 | } | ||||
347 | { | ||||
348 | 115 | 548µs | 2 | 44µs | # spent 30µs (16+14) within Sub::Quote::BEGIN@348 which was called:
# once (16µs+14µs) by Method::Generate::Accessor::BEGIN@8 at line 348 # spent 30µs making 1 call to Sub::Quote::BEGIN@348
# spent 14µs making 1 call to strict::unimport |
349 | 113 | 300µs | local *{"${package}::${name}"} if $name; | ||
350 | 113 | 32µs | my ($success, $e); | ||
351 | { | ||||
352 | 226 | 85µs | local $@; | ||
353 | 113 | 147µs | 113 | 41.3ms | $success = _clean_eval($make_sub, \%captures); # spent 41.3ms making 113 calls to Sub::Quote::_clean_eval, avg 365µs/call |
354 | 113 | 85µs | $e = $@; | ||
355 | } | ||||
356 | 113 | 57µs | unless ($success) { | ||
357 | my $space = length($make_sub =~ tr/\n//); | ||||
358 | my $line = 0; | ||||
359 | $make_sub =~ s/^/sprintf "%${space}d: ", ++$line/emg; | ||||
360 | croak "Eval went very, very wrong:\n\n${make_sub}\n\n$e"; | ||||
361 | } | ||||
362 | 113 | 651µs | 113 | 160µs | weaken($QUOTED{$$unquoted} = $quoted_info); # spent 160µs making 113 calls to Scalar::Util::weaken, avg 1µs/call |
363 | } | ||||
364 | } | ||||
365 | 113 | 354µs | $$unquoted; | ||
366 | } | ||||
367 | |||||
368 | sub qsub ($) { | ||||
369 | goto "e_sub; | ||||
370 | } | ||||
371 | |||||
372 | sub CLONE { | ||||
373 | my @quoted = map { defined $_ ? ( | ||||
374 | $_->{unquoted} && ${$_->{unquoted}} ? (${ $_->{unquoted} } => $_) : (), | ||||
375 | $_->{deferred} ? ($_->{deferred} => $_) : (), | ||||
376 | ) : () } values %QUOTED; | ||||
377 | %QUOTED = @quoted; | ||||
378 | weaken($_) for values %QUOTED; | ||||
379 | } | ||||
380 | |||||
381 | 1 | 7µs | 1; | ||
382 | __END__ | ||||
# spent 968µs within Sub::Quote::CORE:match which was called 769 times, avg 1µs/call:
# 333 times (159µs+0s) by Sub::Quote::capture_unroll at line 140, avg 477ns/call
# 115 times (68µs+0s) by Sub::Quote::quotify at line 119, avg 591ns/call
# 107 times (425µs+0s) by Sub::Quote::quote_sub at line 192, avg 4µs/call
# 107 times (175µs+0s) by Sub::Quote::unquote_sub at line 302, avg 2µs/call
# 107 times (141µs+0s) by Sub::Quote::quote_sub at line 196, avg 1µs/call | |||||
sub Sub::Quote::CORE:subst; # opcode | |||||
# spent 219µs within Sub::Quote::CORE:substcont which was called 182 times, avg 1µs/call:
# 182 times (219µs+0s) by Sub::Quote::sanitize_identifier at line 131, avg 1µs/call | |||||
# spent 1µs within Sub::Quote::__ANON__ which was called:
# once (1µs+0s) by Sub::Quote::BEGIN@14 at line 17 |