← Index
NYTProf Performance Profile   « line view »
For bin/benchmark-perlformance
  Run on Fri Apr 17 15:31:48 2015
Reported on Fri Apr 17 15:32:02 2015

Filename/home/ss5/perl5/perlbrew/perls/tapper-perl/lib/5.16.3/SelfLoader.pm
StatementsExecuted 25 statements in 1.04ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.57ms2.91msSelfLoader::::BEGIN@4SelfLoader::BEGIN@4
11184µs100µsSelfLoader::::BEGIN@10SelfLoader::BEGIN@10
11112µs12µsSelfLoader::::BEGIN@2SelfLoader::BEGIN@2
1118µs30µsSelfLoader::::BEGIN@9SelfLoader::BEGIN@9
1117µs17µsSelfLoader::::BEGIN@158SelfLoader::BEGIN@158
1117µs20µsSelfLoader::::BEGIN@42SelfLoader::BEGIN@42
1117µs18µsSelfLoader::::BEGIN@73SelfLoader::BEGIN@73
1117µs15µsSelfLoader::::BEGIN@91SelfLoader::BEGIN@91
1116µs15µsSelfLoader::::BEGIN@93SelfLoader::BEGIN@93
1116µs15µsSelfLoader::::BEGIN@3SelfLoader::BEGIN@3
1115µs5µsSelfLoader::::CORE:qrSelfLoader::CORE:qr (opcode)
0000s0sSelfLoader::::AUTOLOADSelfLoader::AUTOLOAD
0000s0sSelfLoader::::VersionSelfLoader::Version
0000s0sSelfLoader::::_add_to_cacheSelfLoader::_add_to_cache
0000s0sSelfLoader::::_load_stubsSelfLoader::_load_stubs
0000s0sSelfLoader::::_package_definedSelfLoader::_package_defined
0000s0sSelfLoader::::carpSelfLoader::carp
0000s0sSelfLoader::::croakSelfLoader::croak
0000s0sSelfLoader::::load_stubsSelfLoader::load_stubs
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package SelfLoader;
2235µs112µs
# spent 12µs within SelfLoader::BEGIN@2 which was called: # once (12µs+0s) by Text::Balanced::BEGIN@9 at line 2
use 5.008;
# spent 12µs making 1 call to SelfLoader::BEGIN@2
3217µs225µs
# spent 15µs (6+9) within SelfLoader::BEGIN@3 which was called: # once (6µs+9µs) by Text::Balanced::BEGIN@9 at line 3
use strict;
# spent 15µs making 1 call to SelfLoader::BEGIN@3 # spent 10µs making 1 call to strict::import
42142µs22.93ms
# spent 2.91ms (1.57+1.35) within SelfLoader::BEGIN@4 which was called: # once (1.57ms+1.35ms) by Text::Balanced::BEGIN@9 at line 4
use IO::Handle;
# spent 2.91ms making 1 call to SelfLoader::BEGIN@4 # spent 14µs making 1 call to Exporter::import
51400nsour $VERSION = "1.20";
6
7# The following bit of eval-magic is necessary to make this work on
8# perls < 5.009005.
9240µs253µs
# spent 30µs (8+22) within SelfLoader::BEGIN@9 which was called: # once (8µs+22µs) by Text::Balanced::BEGIN@9 at line 9
use vars qw/$AttrList/;
# spent 30µs making 1 call to SelfLoader::BEGIN@9 # spent 22µs making 1 call to vars::import
10
# spent 100µs (84+16) within SelfLoader::BEGIN@10 which was called: # once (84µs+16µs) by Text::Balanced::BEGIN@9 at line 41
BEGIN {
1113µs if ($] > 5.009004) {
12121µs eval <<'NEWERPERL';
# spent 75µs executing statements in string eval
# includes 11µs spent executing 1 call to 1 sub defined therein.
13use 5.009005; # due to new regexp features
14# allow checking for valid ': attrlist' attachments
15# see also AutoSplit
16$AttrList = qr{
17 \s* : \s*
18 (?:
19 # one attribute
20 (?> # no backtrack
21 (?! \d) \w+
22 (?<nested> \( (?: [^()]++ | (?&nested)++ )*+ \) ) ?
23 )
24 (?: \s* : \s* | \s+ (?! :) )
25 )*
26}x;
27
28NEWERPERL
29 }
30 else {
31 eval <<'OLDERPERL';
32# allow checking for valid ': attrlist' attachments
33# (we use 'our' rather than 'my' here, due to the rather complex and buggy
34# behaviour of lexicals with qr// and (??{$lex}) )
35our $nested;
36$nested = qr{ \( (?: (?> [^()]+ ) | (??{ $nested }) )* \) }x;
37our $one_attr = qr{ (?> (?! \d) \w+ (?:$nested)? ) (?:\s*\:\s*|\s+(?!\:)) }x;
38$AttrList = qr{ \s* : \s* (?: $one_attr )* }x;
39OLDERPERL
40 }
41117µs1100µs}
# spent 100µs making 1 call to SelfLoader::BEGIN@10
422182µs233µs
# spent 20µs (7+13) within SelfLoader::BEGIN@42 which was called: # once (7µs+13µs) by Text::Balanced::BEGIN@9 at line 42
use Exporter;
# spent 20µs making 1 call to SelfLoader::BEGIN@42 # spent 13µs making 1 call to Exporter::import
4314µsour @ISA = qw(Exporter);
441400nsour @EXPORT = qw(AUTOLOAD);
45sub Version {$VERSION}
46sub DEBUG () { 0 }
47
481200nsmy %Cache; # private cache for all SelfLoader's client packages
49
50# in croak and carp, protect $@ from "require Carp;" RT #40216
51
52sub croak { { local $@; require Carp; } goto &Carp::croak }
53sub carp { { local $@; require Carp; } goto &Carp::carp }
54
55AUTOLOAD {
56 our $AUTOLOAD;
57 print STDERR "SelfLoader::AUTOLOAD for $AUTOLOAD\n" if DEBUG;
58 my $SL_code = $Cache{$AUTOLOAD};
59 my $save = $@; # evals in both AUTOLOAD and _load_stubs can corrupt $@
60 unless ($SL_code) {
61 # Maybe this pack had stubs before __DATA__, and never initialized.
62 # Or, this maybe an automatic DESTROY method call when none exists.
63 $AUTOLOAD =~ m/^(.*)::/;
64 SelfLoader->_load_stubs($1) unless exists $Cache{"${1}::<DATA"};
65 $SL_code = $Cache{$AUTOLOAD};
66 $SL_code = "sub $AUTOLOAD { }"
67 if (!$SL_code and $AUTOLOAD =~ m/::DESTROY$/);
68 croak "Undefined subroutine $AUTOLOAD" unless $SL_code;
69 }
70 print STDERR "SelfLoader::AUTOLOAD eval: $SL_code\n" if DEBUG;
71
72 {
732101µs229µs
# spent 18µs (7+11) within SelfLoader::BEGIN@73 which was called: # once (7µs+11µs) by Text::Balanced::BEGIN@9 at line 73
no strict;
# spent 18µs making 1 call to SelfLoader::BEGIN@73 # spent 11µs making 1 call to strict::unimport
74 eval $SL_code;
75 }
76 if ($@) {
77 $@ =~ s/ at .*\n//;
78 croak $@;
79 }
80 $@ = $save;
81 defined(&$AUTOLOAD) || die "SelfLoader inconsistency error";
82 delete $Cache{$AUTOLOAD};
83 goto &$AUTOLOAD
84}
85
86sub load_stubs { shift->_load_stubs((caller)[0]) }
87
88sub _load_stubs {
89 # $endlines is used by Devel::SelfStubber to capture lines after __END__
90 my($self, $callpack, $endlines) = @_;
91229µs224µs
# spent 15µs (7+9) within SelfLoader::BEGIN@91 which was called: # once (7µs+9µs) by Text::Balanced::BEGIN@9 at line 91
no strict "refs";
# spent 15µs making 1 call to SelfLoader::BEGIN@91 # spent 9µs making 1 call to strict::unimport
92 my $fh = \*{"${callpack}::DATA"};
932320µs224µs
# spent 15µs (6+9) within SelfLoader::BEGIN@93 which was called: # once (6µs+9µs) by Text::Balanced::BEGIN@9 at line 93
use strict;
# spent 15µs making 1 call to SelfLoader::BEGIN@93 # spent 9µs making 1 call to strict::import
94 my $currpack = $callpack;
95 my($line,$name,@lines, @stubs, $protoype);
96
97 print STDERR "SelfLoader::load_stubs($callpack)\n" if DEBUG;
98 croak("$callpack doesn't contain an __DATA__ token")
99 unless defined fileno($fh);
100 # Protect: fork() shares the file pointer between the parent and the kid
101 if(sysseek($fh, tell($fh), 0)) {
102 open my $nfh, '<&', $fh or croak "reopen: $!";# dup() the fd
103 close $fh or die "close: $!"; # autocloses, but be paranoid
104 open $fh, '<&', $nfh or croak "reopen2: $!"; # dup() the fd "back"
105 close $nfh or die "close after reopen: $!"; # autocloses, but be paranoid
106 $fh->untaint;
107 }
108 $Cache{"${currpack}::<DATA"} = 1; # indicate package is cached
109
110 local($/) = "\n";
111 while(defined($line = <$fh>) and $line !~ m/^__END__/) {
112 if ($line =~ m/^\s*sub\s+([\w:]+)\s*((?:\([\\\$\@\%\&\*\;]*\))?(?:$AttrList)?)/) {
113 push(@stubs, $self->_add_to_cache($name, $currpack, \@lines, $protoype));
114 $protoype = $2;
115 @lines = ($line);
116 if (index($1,'::') == -1) { # simple sub name
117 $name = "${currpack}::$1";
118 } else { # sub name with package
119 $name = $1;
120 $name =~ m/^(.*)::/;
121 if (defined(&{"${1}::AUTOLOAD"})) {
122 \&{"${1}::AUTOLOAD"} == \&SelfLoader::AUTOLOAD ||
123 die 'SelfLoader Error: attempt to specify Selfloading',
124 " sub $name in non-selfloading module $1";
125 } else {
126 $self->export($1,'AUTOLOAD');
127 }
128 }
129 } elsif ($line =~ m/^package\s+([\w:]+)/) { # A package declared
130 push(@stubs, $self->_add_to_cache($name, $currpack, \@lines, $protoype));
131 $self->_package_defined($line);
132 $name = '';
133 @lines = ();
134 $currpack = $1;
135 $Cache{"${currpack}::<DATA"} = 1; # indicate package is cached
136 if (defined(&{"${1}::AUTOLOAD"})) {
137 \&{"${1}::AUTOLOAD"} == \&SelfLoader::AUTOLOAD ||
138 die 'SelfLoader Error: attempt to specify Selfloading',
139 " package $currpack which already has AUTOLOAD";
140 } else {
141 $self->export($currpack,'AUTOLOAD');
142 }
143 } else {
144 push(@lines,$line);
145 }
146 }
147 if (defined($line) && $line =~ /^__END__/) { # __END__
148 unless ($line =~ /^__END__\s*DATA/) {
149 if ($endlines) {
150 # Devel::SelfStubber would like us to capture the lines after
151 # __END__ so it can write out the entire file
152 @$endlines = <$fh>;
153 }
154 close($fh);
155 }
156 }
157 push(@stubs, $self->_add_to_cache($name, $currpack, \@lines, $protoype));
1582128µs227µs
# spent 17µs (7+10) within SelfLoader::BEGIN@158 which was called: # once (7µs+10µs) by Text::Balanced::BEGIN@9 at line 158
no strict;
# spent 17µs making 1 call to SelfLoader::BEGIN@158 # spent 10µs making 1 call to strict::unimport
159 eval join('', @stubs) if @stubs;
160}
161
162
163sub _add_to_cache {
164 my($self,$fullname,$pack,$lines, $protoype) = @_;
165 return () unless $fullname;
166 carp("Redefining sub $fullname")
167 if exists $Cache{$fullname};
168 $Cache{$fullname} = join('', "\n\#line 1 \"sub $fullname\"\npackage $pack; ", @$lines);
169 #$Cache{$fullname} = join('', "package $pack; ",@$lines);
170 print STDERR "SelfLoader cached $fullname: $Cache{$fullname}" if DEBUG;
171 # return stub to be eval'd
172 defined($protoype) ? "sub $fullname $protoype;" : "sub $fullname;"
173}
174
175sub _package_defined {}
176
17713µs1;
178__END__
 
# spent 5µs within SelfLoader::CORE:qr which was called: # once (5µs+0s) by SelfLoader::BEGIN@10 at line 4 of (eval 32)[SelfLoader.pm:12]
sub SelfLoader::CORE:qr; # opcode