Filename | /usr/share/perl5/Sub/Quote.pm |
Statements | Executed 0 statements in 0s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
539 | 13 | 6 | 13.2ms | 32.7ms | quote_sub | Sub::Quote::
16 | 1 | 1 | 5.32ms | 5.96ms | _clean_eval | Sub::Quote::
1 | 1 | 1 | 5.25ms | 6.07ms | BEGIN@10 | Sub::Quote::
1178 | 13 | 3 | 2.68ms | 3.89ms | quotify | Sub::Quote::
1 | 1 | 1 | 669µs | 818µs | BEGIN@3 | Sub::Quote::
1 | 1 | 1 | 659µs | 4.02ms | BEGIN@7 | Sub::Quote::
16 | 2 | 2 | 651µs | 7.20ms | unquote_sub | Sub::Quote::
16 | 1 | 1 | 339µs | 554µs | capture_unroll | Sub::Quote::
38 | 1 | 1 | 58µs | 58µs | CORE:match (opcode) | Sub::Quote::
14 | 1 | 1 | 57µs | 5.69ms | __ANON__[:100] | Sub::Quote::
4 | 1 | 1 | 39µs | 60µs | inlinify | Sub::Quote::
1 | 1 | 1 | 23µs | 36µs | BEGIN@9 | Sub::Quote::
4 | 1 | 1 | 22µs | 22µs | quoted_from_sub | Sub::Quote::
8 | 2 | 1 | 20µs | 20µs | CORE:subst (opcode) | Sub::Quote::
1 | 1 | 1 | 15µs | 27µs | BEGIN@152 | Sub::Quote::
1 | 1 | 1 | 11µs | 33µs | BEGIN@8 | Sub::Quote::
1 | 1 | 1 | 6µs | 6µs | BEGIN@11 | Sub::Quote::
0 | 0 | 0 | 0s | 0s | CLONE | 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 | 3 | 874µs | # spent 818µs (669+150) within Sub::Quote::BEGIN@3 which was called:
# once (669µs+150µs) by DBIx::Class::_Util::BEGIN@64 at line 3 # spent 818µs making 1 call to Sub::Quote::BEGIN@3
# spent 34µs making 1 call to strictures::VERSION
# spent 22µs making 1 call to strictures::import | ||
4 | |||||
5 | # spent 5.96ms (5.32+644µs) within Sub::Quote::_clean_eval which was called 16 times, avg 373µs/call:
# 16 times (5.32ms+644µs) by Sub::Quote::unquote_sub at line 157, avg 373µs/call # spent 2.86ms executing statements in string eval # includes 11.1ms spent executing 322 calls to 4 subs defined therein. # spent 774µs executing statements in string eval # includes 2.58ms spent executing 322 calls to 4 subs defined therein. # spent 716µs executing statements in string eval # includes 3.56ms spent executing 1273 calls to 3 subs defined therein. # spent 510µs executing statements in string eval # includes 14.5ms spent executing 633 calls to 3 subs defined therein. # spent 410µs executing statements in string eval # includes 2.04ms spent executing 638 calls to 3 subs defined therein. # spent 297µs executing statements in string eval # includes 817µs spent executing 321 calls to 3 subs defined therein. # spent 10µs executing statements in string eval # includes 117µs spent executing 7 calls to 3 subs defined therein. # spent 10µs executing statements in string eval # includes 42µs spent executing 5 calls to 3 subs defined therein. # spent 0s executing statements in string eval # includes 69µs spent executing 5 calls to 3 subs defined therein. # spent 0s executing statements in string eval # includes 33µs spent executing 5 calls to 3 subs defined therein. # spent 0s executing statements in string eval # includes 1.50ms spent executing 154 calls to 3 subs defined therein. # spent 0s executing statements in string eval # includes 2.20ms spent executing 422 calls to 3 subs defined therein. # spent 0s executing statements in string eval # includes 742µs spent executing 125 calls to 3 subs defined therein. # spent 0s executing statements in string eval # includes 1.01ms spent executing 136 calls to 3 subs defined therein. # spent 0s executing statements in string eval # includes 175µs spent executing 22 calls to 3 subs defined therein. # spent 0s executing statements in string eval # includes 42µs spent executing 4 calls to 3 subs defined therein. | ||||
6 | |||||
7 | 2 | 4.05ms | # spent 4.02ms (659µs+3.36) within Sub::Quote::BEGIN@7 which was called:
# once (659µs+3.36ms) by DBIx::Class::_Util::BEGIN@64 at line 7 # spent 4.02ms making 1 call to Sub::Quote::BEGIN@7
# spent 24µs making 1 call to Exporter::import | ||
8 | 2 | 55µs | # spent 33µs (11+22) within Sub::Quote::BEGIN@8 which was called:
# once (11µs+22µs) by DBIx::Class::_Util::BEGIN@64 at line 8 # spent 33µs making 1 call to Sub::Quote::BEGIN@8
# spent 22µs making 1 call to Exporter::import | ||
9 | 2 | 50µs | # spent 36µs (23+14) within Sub::Quote::BEGIN@9 which was called:
# once (23µs+14µs) by DBIx::Class::_Util::BEGIN@64 at line 9 # spent 36µs making 1 call to Sub::Quote::BEGIN@9
# spent 14µs making 1 call to Exporter::import | ||
10 | 1 | 6.07ms | # spent 6.07ms (5.25+819µs) within Sub::Quote::BEGIN@10 which was called:
# once (5.25ms+819µs) by DBIx::Class::_Util::BEGIN@64 at line 10 # spent 6.07ms making 1 call to Sub::Quote::BEGIN@10 | ||
11 | # spent 6µs within Sub::Quote::BEGIN@11 which was called:
# once (6µs+0s) by DBIx::Class::_Util::BEGIN@64 at line 13 | ||||
12 | *_HAVE_PERLSTRING = defined &B::perlstring ? sub(){1} : sub(){0}; | ||||
13 | 1 | 6µs | } # spent 6µs making 1 call to Sub::Quote::BEGIN@11 | ||
14 | |||||
15 | our $VERSION = '1.006001'; | ||||
16 | $VERSION = eval $VERSION; # spent 0s executing statements in string eval | ||||
17 | |||||
18 | our @EXPORT = qw(quote_sub unquote_sub quoted_from_sub qsub); | ||||
19 | our @EXPORT_OK = qw(quotify capture_unroll inlinify); | ||||
20 | |||||
21 | our %QUOTED; | ||||
22 | |||||
23 | # spent 3.89ms (2.68+1.21) within Sub::Quote::quotify which was called 1178 times, avg 3µs/call:
# 1078 times (2.44ms+1.11ms) by Sub::Quote::quote_sub at line 81, avg 3µs/call
# 38 times (107µs+49µs) by Sub::Quote::capture_unroll at line 36, avg 4µs/call
# 16 times (31µs+15µs) by Method::Generate::Accessor::_generate_simple_set at line 570 of Method/Generate/Accessor.pm, avg 3µs/call
# 16 times (25µs+12µs) by Method::Generate::Accessor::_generate_core_set at line 564 of Method/Generate/Accessor.pm, avg 2µs/call
# 11 times (24µs+10µs) by Method::Generate::Constructor::_assign_new at line 176 of Method/Generate/Constructor.pm, avg 3µs/call
# 6 times (13µs+6µs) by Method::Generate::Accessor::_generate_simple_get at line 334 of Method/Generate/Accessor.pm, avg 3µs/call
# 3 times (6µs+2µs) by Method::Generate::Accessor::_generate_simple_has at line 271 of Method/Generate/Accessor.pm, avg 3µs/call
# 3 times (5µs+2µs) by Method::Generate::Accessor::_wrap_attr_exception at line 419 of Method/Generate/Accessor.pm, avg 2µs/call
# 2 times (14µs+7µs) by Method::Generate::Constructor::_handle_subconstructor at line 121 of Method/Generate/Constructor.pm, avg 10µs/call
# 2 times (4µs+2µs) by Method::Generate::Accessor::_generate_get_default at line 315 of Method/Generate/Accessor.pm, avg 3µs/call
# once (2µs+1µs) by Method::Generate::Accessor::_generate_simple_clear at line 276 of Method/Generate/Accessor.pm
# once (2µs+2µs) by Method::Generate::Accessor::_wrap_attr_exception at line 418 of Method/Generate/Accessor.pm
# once (2µs+1µs) by Method::Generate::Accessor::_attr_desc at line 382 of Method/Generate/Accessor.pm | ||||
24 | 1178 | 1.21ms | ! defined $_[0] ? 'undef()' # spent 1.21ms making 1178 calls to B::perlstring, avg 1µs/call | ||
25 | : _HAVE_PERLSTRING ? B::perlstring($_[0]) | ||||
26 | : qq["\Q$_[0]\E"]; | ||||
27 | } | ||||
28 | |||||
29 | # spent 554µs (339+215) within Sub::Quote::capture_unroll which was called 16 times, avg 35µs/call:
# 16 times (339µs+215µs) by Sub::Quote::unquote_sub at line 132, avg 35µs/call | ||||
30 | my ($from, $captures, $indent) = @_; | ||||
31 | 38 | 58µs | join( # spent 58µs making 38 calls to Sub::Quote::CORE:match, avg 2µs/call | ||
32 | '', | ||||
33 | map { | ||||
34 | /^([\@\%\$])/ | ||||
35 | or die "capture key should start with \@, \% or \$: $_"; | ||||
36 | 38 | 156µs | (' ' x $indent).qq{my ${_} = ${1}{${from}->{${\quotify $_}}};\n}; # spent 156µs making 38 calls to Sub::Quote::quotify, avg 4µs/call | ||
37 | } keys %$captures | ||||
38 | ); | ||||
39 | } | ||||
40 | |||||
41 | # spent 60µs (39+20) within Sub::Quote::inlinify which was called 4 times, avg 15µs/call:
# 4 times (39µs+20µs) by Method::Generate::Accessor::_generate_call_code at line 473 of Method/Generate/Accessor.pm, avg 15µs/call | ||||
42 | my ($code, $args, $extra, $local) = @_; | ||||
43 | my $do = 'do { '.($extra||''); | ||||
44 | 4 | 16µs | if ($code =~ s/^(\s*package\s+([a-zA-Z0-9:]+);)//) { # spent 16µs making 4 calls to Sub::Quote::CORE:subst, avg 4µs/call | ||
45 | $do .= $1; | ||||
46 | } | ||||
47 | 4 | 4µs | if ($code =~ s{(\A\s*|\A# BEGIN quote_sub PRELUDE\n.*?# END quote_sub PRELUDE\n\s*)(^\s*)(my\s*\(([^)]+)\)\s*=\s*\@_;)$}{ # spent 4µs making 4 calls to Sub::Quote::CORE:subst, avg 1µs/call | ||
48 | my ($pre, $indent, $assign, $code_args) = ($1, $2, $3, $4); | ||||
49 | if ($code_args eq $args) { | ||||
50 | $pre . $indent . ($local ? 'local ' : '').'@_ = ('.$args.");\n" | ||||
51 | . $indent . $assign; | ||||
52 | } | ||||
53 | else { | ||||
54 | $pre . 'my ('.$code_args.') = ('.$args.'); '; | ||||
55 | } | ||||
56 | }mse) { | ||||
57 | #done | ||||
58 | } | ||||
59 | elsif ($local || $args ne '@_') { | ||||
60 | $do .= ($local ? 'local ' : '').'@_ = ('.$args.'); '; | ||||
61 | } | ||||
62 | $do.$code.' }'; | ||||
63 | } | ||||
64 | |||||
65 | # spent 32.7ms (13.2+19.5) within Sub::Quote::quote_sub which was called 539 times, avg 61µs/call:
# 144 times (3.78ms+5.92ms) by DBIx::Class::Relationship::Accessor::add_relationship_accessor at line 99 of DBIx/Class/Relationship/Accessor.pm, avg 67µs/call
# 144 times (2.85ms+4.65ms) by DBIx::Class::Relationship::Accessor::add_relationship_accessor at line 100 of DBIx/Class/Relationship/Accessor.pm, avg 52µs/call
# 144 times (2.86ms+4.57ms) by DBIx::Class::Relationship::Accessor::add_relationship_accessor at line 101 of DBIx/Class/Relationship/Accessor.pm, avg 52µs/call
# 53 times (2.45ms+2.62ms) by DBIx::Class::Relationship::Accessor::add_relationship_accessor at line 26 of DBIx/Class/Relationship/Accessor.pm, avg 96µs/call
# 22 times (469µs+752µs) by base::import at line 84 of DBIx/Class/ResultSourceProxy.pm, avg 55µs/call
# 18 times (449µs+594µs) by Class::C3::Componentised::ensure_class_loaded at line 124 of DBIx/Class/Storage/DBI.pm, avg 58µs/call
# 4 times (103µs+83µs) by DBIx::Class::Storage::BEGIN@16 at line 76 of DBIx/Class/_Util.pm, avg 46µs/call
# 3 times (56µs+88µs) by Class::C3::Componentised::ensure_class_loaded at line 1625 of DBIx/Class/Storage/DBI.pm, avg 48µs/call
# 2 times (72µs+58µs) by Method::Generate::Constructor::generate_method at line 114 of Method/Generate/Constructor.pm, avg 65µs/call
# 2 times (45µs+78µs) by Method::Generate::Accessor::generate_method at line 116 of Method/Generate/Accessor.pm, avg 62µs/call
# once (22µs+41µs) by Method::Generate::Accessor::generate_method at line 137 of Method/Generate/Accessor.pm
# once (22µs+35µs) by Method::Generate::Accessor::generate_method at line 156 of Method/Generate/Accessor.pm
# once (18µs+33µs) by Method::Generate::Accessor::generate_method at line 183 of Method/Generate/Accessor.pm | ||||
66 | # HOLY DWIMMERY, BATMAN! | ||||
67 | # $name => $code => \%captures => \%options | ||||
68 | # $name => $code => \%captures | ||||
69 | # $name => $code | ||||
70 | # $code => \%captures => \%options | ||||
71 | # $code | ||||
72 | my $options = | ||||
73 | (ref($_[-1]) eq 'HASH' and ref($_[-2]) eq 'HASH') | ||||
74 | ? pop | ||||
75 | : {}; | ||||
76 | my $captures = ref($_[-1]) eq 'HASH' ? pop : undef; | ||||
77 | undef($captures) if $captures && !keys %$captures; | ||||
78 | my $code = pop; | ||||
79 | my $name = $_[0]; | ||||
80 | my ($package, $hints, $bitmask, $hintshash) = (caller(0))[0,8,9,10]; | ||||
81 | 1078 | 3.55ms | my $context # spent 3.55ms making 1078 calls to Sub::Quote::quotify, avg 3µs/call | ||
82 | ="# BEGIN quote_sub PRELUDE\n" | ||||
83 | ."package $package;\n" | ||||
84 | ."BEGIN {\n" | ||||
85 | ." \$^H = ".quotify($hints).";\n" | ||||
86 | ." \${^WARNING_BITS} = ".quotify($bitmask).";\n" | ||||
87 | ." \%^H = (\n" | ||||
88 | . join('', map | ||||
89 | " ".quotify($_)." => ".quotify($hintshash->{$_}).",", | ||||
90 | keys %$hintshash) | ||||
91 | ." );\n" | ||||
92 | ."}\n" | ||||
93 | ."# END quote_sub PRELUDE\n"; | ||||
94 | $code = "$context$code"; | ||||
95 | my $quoted_info; | ||||
96 | my $unquoted; | ||||
97 | # spent 5.69ms (57µs+5.63) within Sub::Quote::__ANON__[/usr/share/perl5/Sub/Quote.pm:100] which was called 14 times, avg 406µs/call:
# 14 times (57µs+5.63ms) by Sub::Defer::undefer_sub at line 22 of Sub/Defer.pm, avg 406µs/call | ||||
98 | $unquoted if 0; | ||||
99 | 14 | 5.63ms | unquote_sub($quoted_info->[4]); # spent 5.63ms making 14 calls to Sub::Quote::unquote_sub, avg 402µs/call | ||
100 | 539 | 14.8ms | }; # spent 14.8ms making 539 calls to Sub::Defer::defer_sub, avg 27µs/call | ||
101 | $quoted_info = [ $name, $code, $captures, \$unquoted, $deferred ]; | ||||
102 | 539 | 557µs | weaken($quoted_info->[3]); # spent 557µs making 539 calls to Scalar::Util::weaken, avg 1µs/call | ||
103 | 539 | 349µs | weaken($quoted_info->[4]); # spent 349µs making 539 calls to Scalar::Util::weaken, avg 647ns/call | ||
104 | 539 | 258µs | weaken($QUOTED{$deferred} = $quoted_info); # spent 258µs making 539 calls to Scalar::Util::weaken, avg 479ns/call | ||
105 | return $deferred; | ||||
106 | } | ||||
107 | |||||
108 | # spent 22µs within Sub::Quote::quoted_from_sub which was called 4 times, avg 6µs/call:
# 4 times (22µs+0s) by Method::Generate::Accessor::_generate_call_code at line 460 of Method/Generate/Accessor.pm, avg 6µs/call | ||||
109 | my ($sub) = @_; | ||||
110 | my $quoted_info = $QUOTED{$sub||''} or return undef; | ||||
111 | my ($name, $code, $captured, $unquoted, $deferred) = @{$quoted_info}; | ||||
112 | $unquoted &&= $$unquoted; | ||||
113 | if (($deferred && $deferred eq $sub) | ||||
114 | || ($unquoted && $unquoted eq $sub)) { | ||||
115 | return [ $name, $code, $captured, $unquoted, $deferred ]; | ||||
116 | } | ||||
117 | return undef; | ||||
118 | } | ||||
119 | |||||
120 | # spent 7.20ms (651µs+6.55) within Sub::Quote::unquote_sub which was called 16 times, avg 450µs/call:
# 14 times (583µs+5.05ms) by Sub::Quote::__ANON__[/usr/share/perl5/Sub/Quote.pm:100] at line 99, avg 402µs/call
# 2 times (67µs+1.50ms) by Method::Generate::Constructor::__ANON__[/usr/share/perl5/Method/Generate/Constructor.pm:81] at line 78 of Method/Generate/Constructor.pm, avg 786µs/call | ||||
121 | my ($sub) = @_; | ||||
122 | my $quoted = $QUOTED{$sub} or return undef; | ||||
123 | my $unquoted = $quoted->[3]; | ||||
124 | unless ($unquoted && $$unquoted) { | ||||
125 | my ($name, $code, $captures) = @$quoted; | ||||
126 | |||||
127 | my $make_sub = "{\n"; | ||||
128 | |||||
129 | my %captures = $captures ? %$captures : (); | ||||
130 | $captures{'$_UNQUOTED'} = \$unquoted; | ||||
131 | $captures{'$_QUOTED'} = \$quoted; | ||||
132 | 16 | 554µs | $make_sub .= capture_unroll("\$_[1]", \%captures, 2); # spent 554µs making 16 calls to Sub::Quote::capture_unroll, avg 35µs/call | ||
133 | |||||
134 | $make_sub .= ( | ||||
135 | $name | ||||
136 | # disable the 'variable $x will not stay shared' warning since | ||||
137 | # we're not letting it escape from this scope anyway so there's | ||||
138 | # nothing trying to share it | ||||
139 | ? " no warnings 'closure';\n sub ${name} {\n" | ||||
140 | : " \$\$_UNQUOTED = sub {\n" | ||||
141 | ); | ||||
142 | $make_sub .= " \$_QUOTED if 0;\n"; | ||||
143 | $make_sub .= " \$_UNQUOTED if 0;\n"; | ||||
144 | $make_sub .= $code; | ||||
145 | $make_sub .= " }".($name ? '' : ';')."\n"; | ||||
146 | if ($name) { | ||||
147 | $make_sub .= " \$\$_UNQUOTED = \\&${name}\n"; | ||||
148 | } | ||||
149 | $make_sub .= "}\n1;\n"; | ||||
150 | $ENV{SUB_QUOTE_DEBUG} && warn $make_sub; | ||||
151 | { | ||||
152 | 2 | 39µs | # spent 27µs (15+12) within Sub::Quote::BEGIN@152 which was called:
# once (15µs+12µs) by DBIx::Class::_Util::BEGIN@64 at line 152 # spent 27µs making 1 call to Sub::Quote::BEGIN@152
# spent 12µs making 1 call to strict::unimport | ||
153 | local *{$name} if $name; | ||||
154 | my ($success, $e); | ||||
155 | { | ||||
156 | local $@; | ||||
157 | 16 | 5.96ms | $success = _clean_eval($make_sub, \%captures); # spent 5.96ms making 16 calls to Sub::Quote::_clean_eval, avg 373µs/call | ||
158 | $e = $@; | ||||
159 | } | ||||
160 | unless ($success) { | ||||
161 | die "Eval went very, very wrong:\n\n${make_sub}\n\n$e"; | ||||
162 | } | ||||
163 | 16 | 32µs | weaken($QUOTED{$$unquoted} = $quoted); # spent 32µs making 16 calls to Scalar::Util::weaken, avg 2µs/call | ||
164 | } | ||||
165 | } | ||||
166 | $$unquoted; | ||||
167 | } | ||||
168 | |||||
169 | sub qsub ($) { | ||||
170 | goto "e_sub; | ||||
171 | } | ||||
172 | |||||
173 | sub CLONE { | ||||
174 | %QUOTED = map { defined $_ ? ( | ||||
175 | $_->[3] && ${$_->[3]} ? (${ $_->[3] } => $_) : (), | ||||
176 | $_->[4] ? ($_->[4] => $_) : (), | ||||
177 | ) : () } values %QUOTED; | ||||
178 | weaken($_) for values %QUOTED; | ||||
179 | } | ||||
180 | |||||
181 | 1; | ||||
182 | __END__ | ||||
# spent 58µs within Sub::Quote::CORE:match which was called 38 times, avg 2µs/call:
# 38 times (58µs+0s) by Sub::Quote::capture_unroll at line 31, avg 2µs/call | |||||
sub Sub::Quote::CORE:subst; # opcode |