← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Quote.pm
StatementsExecuted 1808 statements in 4.55ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
17114.00ms4.43msSub::Quote::::_clean_evalSub::Quote::_clean_eval
4452707µs1.49msSub::Quote::::quote_subSub::Quote::quote_sub
469113456µs695µsSub::Quote::::quotifySub::Quote::quotify
111429µs543µsSub::Quote::::BEGIN@7Sub::Quote::BEGIN@7
1722417µs5.21msSub::Quote::::unquote_subSub::Quote::unquote_sub
1711234µs345µsSub::Quote::::capture_unrollSub::Quote::capture_unroll
391129µs29µsSub::Quote::::CORE:matchSub::Quote::CORE:match (opcode)
71125µs1.63msSub::Quote::::__ANON__[:98]Sub::Quote::__ANON__[:98]
51111µs11µsSub::Quote::::quoted_from_subSub::Quote::quoted_from_sub
1116µs14µsSub::Quote::::BEGIN@5Sub::Quote::BEGIN@5
1116µs16µsSub::Quote::::BEGIN@150Sub::Quote::BEGIN@150
1116µs11µsSub::Quote::::BEGIN@9Sub::Quote::BEGIN@9
1116µs26µsSub::Quote::::BEGIN@8Sub::Quote::BEGIN@8
1113µs3µsSub::Quote::::BEGIN@11Sub::Quote::BEGIN@11
1113µs3µsSub::Quote::::BEGIN@10Sub::Quote::BEGIN@10
0000s0sSub::Quote::::CLONESub::Quote::CLONE
0000s0sSub::Quote::::inlinifySub::Quote::inlinify
0000s0sSub::Quote::::qsubSub::Quote::qsub
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Sub::Quote;
2
3171.18ms
# spent 4.43ms (4.00+434µs) within Sub::Quote::_clean_eval which was called 17 times, avg 261µs/call: # 17 times (4.00ms+434µs) by Sub::Quote::unquote_sub at line 155, avg 261µs/call
sub _clean_eval { eval $_[0] }
# spent 45.0ms executing statements in string eval
# includes 44.6ms spent executing 1004 calls to 3 subs defined therein. # spent 29.2ms executing statements in string eval
# includes 65.3ms spent executing 4006 calls to 3 subs defined therein. # spent 25.5ms executing statements in string eval
# includes 68.4ms spent executing 8010 calls to 3 subs defined therein. # spent 25.0ms executing statements in string eval
# includes 36.4ms spent executing 1004 calls to 3 subs defined therein. # spent 23.1ms executing statements in string eval
# includes 18.7ms spent executing 10012 calls to 3 subs defined therein. # spent 19.2ms executing statements in string eval
# includes 24.4ms spent executing 1004 calls to 3 subs defined therein. # spent 18.8ms executing statements in string eval
# includes 17.8ms spent executing 1004 calls to 3 subs defined therein. # spent 18.4ms executing statements in string eval
# includes 17.3ms spent executing 1004 calls to 3 subs defined therein. # spent 18.1ms executing statements in string eval
# includes 13.8ms spent executing 4006 calls to 3 subs defined therein. # spent 16.3ms executing statements in string eval
# includes 21.9ms spent executing 1003 calls to 3 subs defined therein. # spent 15.8ms executing statements in string eval
# includes 14.8ms spent executing 1004 calls to 3 subs defined therein. # spent 8.35ms executing statements in string eval
# includes 11.1ms spent executing 4006 calls to 3 subs defined therein. # spent 4.34ms executing statements in string eval
# includes 16.5ms spent executing 2004 calls to 3 subs defined therein. # spent 410µs executing statements in string eval
# includes 182µs spent executing 14 calls to 3 subs defined therein. # spent 255µs executing statements in string eval
# includes 29µs spent executing 4 calls to 3 subs defined therein. # spent 240µs executing statements in string eval
# includes 32µs spent executing 4 calls to 3 subs defined therein. # spent 138µs executing statements in string eval
# includes 38µs spent executing 4 calls to 3 subs defined therein.
4
5214µs222µs
# spent 14µs (6+8) within Sub::Quote::BEGIN@5 which was called: # once (6µs+8µs) by Moo::HandleMoose::BEGIN@5 at line 5
use Moo::_strictures;
# spent 14µs making 1 call to Sub::Quote::BEGIN@5 # spent 8µs making 1 call to Moo::_strictures::import
6
7260µs2565µs
# spent 543µs (429+114) within Sub::Quote::BEGIN@7 which was called: # once (429µs+114µs) by Moo::HandleMoose::BEGIN@5 at line 7
use Sub::Defer qw(defer_sub);
# spent 543µs making 1 call to Sub::Quote::BEGIN@7 # spent 22µs making 1 call to Exporter::import
8232µs248µs
# spent 26µs (6+21) within Sub::Quote::BEGIN@8 which was called: # once (6µs+21µs) by Moo::HandleMoose::BEGIN@5 at line 8
use Scalar::Util qw(weaken);
# spent 26µs making 1 call to Sub::Quote::BEGIN@8 # spent 21µs making 1 call to Exporter::import
9222µs215µs
# spent 11µs (6+5) within Sub::Quote::BEGIN@9 which was called: # once (6µs+5µs) by Moo::HandleMoose::BEGIN@5 at line 9
use Exporter qw(import);
# spent 11µs making 1 call to Sub::Quote::BEGIN@9 # spent 5µs making 1 call to Exporter::import
10258µs13µs
# spent 3µs within Sub::Quote::BEGIN@10 which was called: # once (3µs+0s) by Moo::HandleMoose::BEGIN@5 at line 10
use B ();
# spent 3µs making 1 call to Sub::Quote::BEGIN@10
11
# spent 3µs within Sub::Quote::BEGIN@11 which was called: # once (3µs+0s) by Moo::HandleMoose::BEGIN@5 at line 13
BEGIN {
1213µs *_HAVE_PERLSTRING = defined &B::perlstring ? sub(){1} : sub(){0};
131699µs13µs}
# spent 3µs making 1 call to Sub::Quote::BEGIN@11
14
151300nsour $VERSION = '2.000002';
1619µs$VERSION = eval $VERSION;
# spent 2µs executing statements in string eval
17
181800nsour @EXPORT = qw(quote_sub unquote_sub quoted_from_sub qsub);
191400nsour @EXPORT_OK = qw(quotify capture_unroll inlinify);
20
21our %QUOTED;
22
23
# spent 695µs (456+239) within Sub::Quote::quotify which was called 469 times, avg 1µs/call: # 88 times (82µs+66µs) by Sub::Quote::quote_sub at line 87, avg 2µs/call # 86 times (72µs+31µs) by Method::Generate::Accessor::_generate_simple_set at line 575 of Method/Generate/Accessor.pm, avg 1µs/call # 86 times (68µs+29µs) by Method::Generate::Accessor::_generate_core_set at line 569 of Method/Generate/Accessor.pm, avg 1µs/call # 71 times (63µs+29µs) by Method::Generate::Constructor::_assign_new at line 214 of Method/Generate/Constructor.pm, avg 1µs/call # 39 times (53µs+28µs) by Sub::Quote::capture_unroll at line 36, avg 2µs/call # 30 times (36µs+16µs) by Method::Generate::Accessor::_generate_simple_get at line 339 of Method/Generate/Accessor.pm, avg 2µs/call # 22 times (20µs+9µs) by Method::Generate::Accessor::_generate_get_default at line 320 of Method/Generate/Accessor.pm, avg 1µs/call # 19 times (18µs+8µs) by Method::Generate::Constructor::_check_required at line 233 of Method/Generate/Constructor.pm, avg 1µs/call # 17 times (16µs+7µs) by Method::Generate::Accessor::_generate_simple_has at line 276 of Method/Generate/Accessor.pm, avg 1µs/call # 10 times (28µs+16µs) by Method::Generate::Constructor::_handle_subconstructor at line 158 of Method/Generate/Constructor.pm, avg 4µs/call # once (1µs+400ns) by Method::Generate::Accessor::_generate_simple_clear at line 281 of Method/Generate/Accessor.pm
sub quotify {
24469954µs469239µs ! defined $_[0] ? 'undef()'
# spent 239µs making 469 calls to B::perlstring, avg 509ns/call
25 : _HAVE_PERLSTRING ? B::perlstring($_[0])
26 : qq["\Q$_[0]\E"];
27}
28
29
# spent 345µs (234+110) within Sub::Quote::capture_unroll which was called 17 times, avg 20µs/call: # 17 times (234µs+110µs) by Sub::Quote::unquote_sub at line 130, avg 20µs/call
sub capture_unroll {
30178µs my ($from, $captures, $indent) = @_;
31 join(
32 '',
33 map {
3456138µs3929µs /^([\@\%\$])/
# spent 29µs making 39 calls to Sub::Quote::CORE:match, avg 751ns/call
35 or die "capture key should start with \@, \% or \$: $_";
3678108µs3981µs (' ' x $indent).qq{my ${_} = ${1}{${from}->{${\quotify $_}}};\n};
# spent 81µs making 39 calls to Sub::Quote::quotify, avg 2µs/call
37 } keys %$captures
38 );
39}
40
41sub inlinify {
42 my ($code, $args, $extra, $local) = @_;
43 my $do = 'do { '.($extra||'');
44 if ($code =~ s/^(\s*package\s+([a-zA-Z0-9:]+);)//) {
45 $do .= $1;
46 }
47 if ($code =~ s{
48 \A((?:\#\ BEGIN\ quote_sub\ PRELUDE\n.*?\#\ END\ quote_sub\ PRELUDE\n)?\s*)
49 (^\s*) my \s* \(([^)]+)\) \s* = \s* \@_;
50 }{}xms) {
51 my ($pre, $indent, $code_args) = ($1, $2, $3);
52 $do .= $pre;
53 if ($code_args ne $args) {
54 $do .= $indent . 'my ('.$code_args.') = ('.$args.'); ';
55 }
56 }
57 elsif ($local || $args ne '@_') {
58 $do .= ($local ? 'local ' : '').'@_ = ('.$args.'); ';
59 }
60 $do.$code.' }';
61}
62
63
# spent 1.49ms (707µs+783µs) within Sub::Quote::quote_sub which was called 44 times, avg 34µs/call: # 18 times (204µs+320µs) by Method::Generate::Accessor::generate_method at line 211 of Method/Generate/Accessor.pm, avg 29µs/call # 13 times (216µs+281µs) by Method::Generate::Accessor::generate_method at line 121 of Method/Generate/Accessor.pm, avg 38µs/call # 10 times (246µs+124µs) by Method::Generate::Constructor::generate_method at line 152 of Method/Generate/Constructor.pm, avg 37µs/call # 2 times (30µs+37µs) by Method::Generate::Accessor::generate_method at line 221 of Method/Generate/Accessor.pm, avg 34µs/call # once (12µs+20µs) by Method::Generate::Accessor::generate_method at line 183 of Method/Generate/Accessor.pm
sub quote_sub {
64 # HOLY DWIMMERY, BATMAN!
65 # $name => $code => \%captures => \%options
66 # $name => $code => \%captures
67 # $name => $code
68 # $code => \%captures => \%options
69 # $code
704426µs my $options =
71 (ref($_[-1]) eq 'HASH' and ref($_[-2]) eq 'HASH')
72 ? pop
73 : {};
744411µs my $captures = ref($_[-1]) eq 'HASH' ? pop : undef;
754419µs undef($captures) if $captures && !keys %$captures;
764419µs my $code = pop;
77447µs my $name = $_[0];
7844102µs my ($package, $hints, $bitmask, $hintshash) = (caller(0))[0,8,9,10];
79 my $context
80 ="# BEGIN quote_sub PRELUDE\n"
81 ."package $package;\n"
82 ."BEGIN {\n"
83 ." \$^H = ".quotify($hints).";\n"
84 ." \${^WARNING_BITS} = ".quotify($bitmask).";\n"
85 ." \%^H = (\n"
86 . join('', map
874498µs88147µs " ".quotify($_)." => ".quotify($hintshash->{$_}).",",
# spent 147µs making 88 calls to Sub::Quote::quotify, avg 2µs/call
88 keys %$hintshash)
89 ." );\n"
90 ."}\n"
91 ."# END quote_sub PRELUDE\n";
924440µs $code = "$context$code";
93447µs my $quoted_info;
94 my $unquoted;
95
# spent 1.63ms (25µs+1.61) within Sub::Quote::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Quote.pm:98] which was called 7 times, avg 233µs/call: # 7 times (25µs+1.61ms) by Sub::Defer::undefer_sub at line 23 of Sub/Defer.pm, avg 233µs/call
my $deferred = defer_sub +($options->{no_install} ? undef : $name) => sub {
96 $unquoted if 0;
97722µs71.61ms unquote_sub($quoted_info->[4]);
# spent 1.61ms making 7 calls to Sub::Quote::unquote_sub, avg 230µs/call
984471µs44596µs };
# spent 596µs making 44 calls to Sub::Defer::defer_sub, avg 14µs/call
994427µs $quoted_info = [ $name, $code, $captures, \$unquoted, $deferred ];
1004462µs4417µs weaken($quoted_info->[3]);
# spent 17µs making 44 calls to Scalar::Util::weaken, avg 377ns/call
1014451µs4413µs weaken($quoted_info->[4]);
# spent 13µs making 44 calls to Scalar::Util::weaken, avg 300ns/call
1024473µs4410µs weaken($QUOTED{$deferred} = $quoted_info);
# spent 10µs making 44 calls to Scalar::Util::weaken, avg 223ns/call
1034474µs return $deferred;
104}
105
106
# spent 11µs within Sub::Quote::quoted_from_sub which was called 5 times, avg 2µs/call: # 5 times (11µs+0s) by Method::Generate::Accessor::_generate_call_code at line 465 of Method/Generate/Accessor.pm, avg 2µs/call
sub quoted_from_sub {
10751µs my ($sub) = @_;
108511µs my $quoted_info = $QUOTED{$sub||''} or return undef;
109 my ($name, $code, $captured, $unquoted, $deferred) = @{$quoted_info};
110 $unquoted &&= $$unquoted;
111 if (($deferred && $deferred eq $sub)
112 || ($unquoted && $unquoted eq $sub)) {
113 return [ $name, $code, $captured, $unquoted, $deferred ];
114 }
115 return undef;
116}
117
118
# spent 5.21ms (417µs+4.79) within Sub::Quote::unquote_sub which was called 17 times, avg 306µs/call: # 10 times (242µs+3.36ms) by Method::Generate::Constructor::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Method/Generate/Constructor.pm:97] at line 95 of Method/Generate/Constructor.pm, avg 360µs/call # 7 times (175µs+1.43ms) by Sub::Quote::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Sub/Quote.pm:98] at line 97, avg 230µs/call
sub unquote_sub {
119174µs my ($sub) = @_;
1201716µs my $quoted = $QUOTED{$sub} or return undef;
121178µs my $unquoted = $quoted->[3];
1221711µs unless ($unquoted && $$unquoted) {
1231712µs my ($name, $code, $captures) = @$quoted;
124
125176µs my $make_sub = "{\n";
126
1271716µs my %captures = $captures ? %$captures : ();
1281710µs $captures{'$_UNQUOTED'} = \$unquoted;
129177µs $captures{'$_QUOTED'} = \$quoted;
1301726µs17345µs $make_sub .= capture_unroll("\$_[1]", \%captures, 2);
# spent 345µs making 17 calls to Sub::Quote::capture_unroll, avg 20µs/call
131
1321712µs $make_sub .= (
133 $name
134 # disable the 'variable $x will not stay shared' warning since
135 # we're not letting it escape from this scope anyway so there's
136 # nothing trying to share it
137 ? " no warnings 'closure';\n sub ${name} {\n"
138 : " \$\$_UNQUOTED = sub {\n"
139 );
140176µs $make_sub .= " \$_QUOTED if 0;\n";
141174µs $make_sub .= " \$_UNQUOTED if 0;\n";
142179µs $make_sub .= $code;
143179µs $make_sub .= " }".($name ? '' : ';')."\n";
1441719µs if ($name) {
145 $make_sub .= " \$\$_UNQUOTED = \\&${name}\n";
146 }
147173µs $make_sub .= "}\n1;\n";
148179µs $ENV{SUB_QUOTE_DEBUG} && warn $make_sub;
149 {
15019150µs226µs
# spent 16µs (6+10) within Sub::Quote::BEGIN@150 which was called: # once (6µs+10µs) by Moo::HandleMoose::BEGIN@5 at line 150
no strict 'refs';
# spent 16µs making 1 call to Sub::Quote::BEGIN@150 # spent 10µs making 1 call to strict::unimport
1511742µs local *{$name} if $name;
152174µs my ($success, $e);
153 {
1543410µs local $@;
1551724µs174.43ms $success = _clean_eval($make_sub, \%captures);
# spent 4.43ms making 17 calls to Sub::Quote::_clean_eval, avg 261µs/call
156179µs $e = $@;
157 }
158174µs unless ($success) {
159 die "Eval went very, very wrong:\n\n${make_sub}\n\n$e";
160 }
1611773µs1718µs weaken($QUOTED{$$unquoted} = $quoted);
# spent 18µs making 17 calls to Scalar::Util::weaken, avg 1µs/call
162 }
163 }
1641735µs $$unquoted;
165}
166
167sub qsub ($) {
168 goto &quote_sub;
169}
170
171sub CLONE {
172 %QUOTED = map { defined $_ ? (
173 $_->[3] && ${$_->[3]} ? (${ $_->[3] } => $_) : (),
174 $_->[4] ? ($_->[4] => $_) : (),
175 ) : () } values %QUOTED;
176 weaken($_) for values %QUOTED;
177}
178
17913µs1;
180__END__
 
# spent 29µs within Sub::Quote::CORE:match which was called 39 times, avg 751ns/call: # 39 times (29µs+0s) by Sub::Quote::capture_unroll at line 34, avg 751ns/call
sub Sub::Quote::CORE:match; # opcode