← Index
NYTProf Performance Profile   « line view »
For nd2: #2 manager: init
  Run on Thu May 2 17:38:58 2019
Reported on Thu May 2 17:40:49 2019

Filename/usr/lib/perl5/5.18.2/AutoLoader.pm
StatementsExecuted 25 statements in 344µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111206µs320µsAutoLoader::::autoload_subAutoLoader::autoload_sub
11152µs115µsAutoLoader::::find_filenameAutoLoader::find_filename
11131µs352µsAutoLoader::::AUTOLOADAutoLoader::AUTOLOAD
11125µs25µsAutoLoader::::CORE:ftereadAutoLoader::CORE:fteread (opcode)
22122µs22µsAutoLoader::::CORE:matchAutoLoader::CORE:match (opcode)
22112µs12µsAutoLoader::::CORE:substAutoLoader::CORE:subst (opcode)
1112µs2µsAutoLoader::::CORE:regcompAutoLoader::CORE:regcomp (opcode)
2112µs2µsAutoLoader::::CORE:substcontAutoLoader::CORE:substcont (opcode)
0000s0sAutoLoader::::BEGINAutoLoader::BEGIN
0000s0sAutoLoader::::__ANON__[:38]AutoLoader::__ANON__[:38]
0000s0sAutoLoader::::importAutoLoader::import
0000s0sAutoLoader::::unimportAutoLoader::unimport
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package AutoLoader;
2
3use strict;
4use 5.006_001;
5
6our($VERSION, $AUTOLOAD);
7
8my $is_dosish;
9my $is_epoc;
10my $is_vms;
11my $is_macos;
12
13BEGIN {
14 $is_dosish = $^O eq 'dos' || $^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'NetWare';
15 $is_epoc = $^O eq 'epoc';
16 $is_vms = $^O eq 'VMS';
17 $is_macos = $^O eq 'MacOS';
18 $VERSION = '5.73';
19}
20
21
# spent 352µs (31+320) within AutoLoader::AUTOLOAD which was called: # once (31µs+320µs) by NetAddr::IP::Lite::addr at line 1112 of NetAddr/IP/Lite.pm
AUTOLOAD {
2214µs my $sub = $AUTOLOAD;
23111µs1320µs autoload_sub($sub);
# spent 320µs making 1 call to AutoLoader::autoload_sub
24113µs152µs goto &$sub;
# spent 52µs making 1 call to NetAddr::IP::InetBase::inet_n2dx
25}
26
27
# spent 320µs (206+115) within AutoLoader::autoload_sub which was called: # once (206µs+115µs) by AutoLoader::AUTOLOAD at line 23
sub autoload_sub {
281500ns my $sub = shift;
29
3017µs1115µs my $filename = AutoLoader::find_filename( $sub );
# spent 115µs making 1 call to AutoLoader::find_filename
31
321500ns my $save = $@;
3312µs local $!; # Do not munge the value.
343179µs eval { local $SIG{__DIE__}; require $filename };
351300ns if ($@) {
36 if (substr($sub,-9) eq '::DESTROY') {
37 no strict 'refs';
38 *$sub = sub {};
39 $@ = undef;
40 } elsif ($@ =~ /^Can't locate/) {
41 # The load might just have failed because the filename was too
42 # long for some old SVR3 systems which treat long names as errors.
43 # If we can successfully truncate a long name then it's worth a go.
44 # There is a slight risk that we could pick up the wrong file here
45 # but autosplit should have warned about that when splitting.
46 if ($filename =~ s/(\w{12,})\.al$/substr($1,0,11).".al"/e){
47 eval { local $SIG{__DIE__}; require $filename };
48 }
49 }
50 if ($@){
51 $@ =~ s/ at .*\n//;
52 my $error = $@;
53 require Carp;
54 Carp::croak($error);
55 }
56 }
571800ns $@ = $save;
58
59110µs return 1;
60}
61
62
# spent 115µs (52+63) within AutoLoader::find_filename which was called: # once (52µs+63µs) by AutoLoader::autoload_sub at line 30
sub find_filename {
6313µs my $sub = shift;
641600ns my $filename;
65 # Braces used to preserve $1 et al.
66 {
67 # Try to find the autoloaded file from the package-qualified
68 # name of the sub. e.g., if the sub needed is
69 # Getopt::Long::GetOptions(), then $INC{Getopt/Long.pm} is
70 # something like '/usr/lib/perl5/Getopt/Long.pm', and the
71 # autoload file is '/usr/lib/perl5/auto/Getopt/Long/GetOptions.al'.
72 #
73 # However, if @INC is a relative path, this might not work. If,
74 # for example, @INC = ('lib'), then $INC{Getopt/Long.pm} is
75 # 'lib/Getopt/Long.pm', and we want to require
76 # 'auto/Getopt/Long/GetOptions.al' (without the leading 'lib').
77 # In this case, we simple prepend the 'auto/' and let the
78 # C<require> take care of the searching for us.
79
80226µs116µs my ($pkg,$func) = ($sub =~ /(.*)::([^:]+)$/);
# spent 16µs making 1 call to AutoLoader::CORE:match
81110µs16µs $pkg =~ s#::#/#g;
# spent 6µs making 1 call to AutoLoader::CORE:subst
82110µs if (defined($filename = $INC{"$pkg.pm"})) {
8311µs if ($is_macos) {
84 $pkg =~ tr#/#:#;
85 $filename = undef
86 unless $filename =~ s#^(.*)$pkg\.pm\z#$1auto:$pkg:$func.al#s;
87 } else {
88121µs410µs $filename = undef
# spent 6µs making 1 call to AutoLoader::CORE:subst # spent 2µs making 1 call to AutoLoader::CORE:regcomp # spent 2µs making 2 calls to AutoLoader::CORE:substcont, avg 900ns/call
89 unless $filename =~ s#^(.*)$pkg\.pm\z#$1auto/$pkg/$func.al#s;
90 }
91
92 # if the file exists, then make sure that it is a
93 # a fully anchored path (i.e either '/usr/lib/auto/foo/bar.al',
94 # or './lib/auto/foo/bar.al'. This avoids C<require> searching
95 # (and failing) to find the 'lib/auto/foo/bar.al' because it
96 # looked for 'lib/lib/auto/foo/bar.al', given @INC = ('lib').
97
98130µs125µs if (defined $filename and -r $filename) {
# spent 25µs making 1 call to AutoLoader::CORE:fteread
9919µs16µs unless ($filename =~ m|^/|s) {
# spent 6µs making 1 call to AutoLoader::CORE:match
100 if ($is_dosish) {
101 unless ($filename =~ m{^([a-z]:)?[\\/]}is) {
102 if ($^O ne 'NetWare') {
103 $filename = "./$filename";
104 } else {
105 $filename = "$filename";
106 }
107 }
108 }
109 elsif ($is_epoc) {
110 unless ($filename =~ m{^([a-z?]:)?[\\/]}is) {
111 $filename = "./$filename";
112 }
113 }
114 elsif ($is_vms) {
115 # XXX todo by VMSmiths
116 $filename = "./$filename";
117 }
118 elsif (!$is_macos) {
119 $filename = "./$filename";
120 }
121 }
122 }
123 else {
124 $filename = undef;
125 }
126 }
1271600ns unless (defined $filename) {
128 # let C<require> do the searching
129 $filename = "auto/$sub.al";
130 $filename =~ s#::#/#g;
131 }
132 }
13314µs return $filename;
134}
135
136sub import {
137 my $pkg = shift;
138 my $callpkg = caller;
139
140 #
141 # Export symbols, but not by accident of inheritance.
142 #
143
144 if ($pkg eq 'AutoLoader') {
145 if ( @_ and $_[0] =~ /^&?AUTOLOAD$/ ) {
146 no strict 'refs';
147 *{ $callpkg . '::AUTOLOAD' } = \&AUTOLOAD;
148 }
149 }
150
151 #
152 # Try to find the autosplit index file. Eg., if the call package
153 # is POSIX, then $INC{POSIX.pm} is something like
154 # '/usr/local/lib/perl5/POSIX.pm', and the autosplit index file is in
155 # '/usr/local/lib/perl5/auto/POSIX/autosplit.ix', so we require that.
156 #
157 # However, if @INC is a relative path, this might not work. If,
158 # for example, @INC = ('lib'), then
159 # $INC{POSIX.pm} is 'lib/POSIX.pm', and we want to require
160 # 'auto/POSIX/autosplit.ix' (without the leading 'lib').
161 #
162
163 (my $calldir = $callpkg) =~ s#::#/#g;
164 my $path = $INC{$calldir . '.pm'};
165 if (defined($path)) {
166 # Try absolute path name, but only eval it if the
167 # transformation from module path to autosplit.ix path
168 # succeeded!
169 my $replaced_okay;
170 if ($is_macos) {
171 (my $malldir = $calldir) =~ tr#/#:#;
172 $replaced_okay = ($path =~ s#^(.*)$malldir\.pm\z#$1auto:$malldir:autosplit.ix#s);
173 } else {
174 $replaced_okay = ($path =~ s#^(.*)$calldir\.pm\z#$1auto/$calldir/autosplit.ix#);
175 }
176
177 eval { require $path; } if $replaced_okay;
178 # If that failed, try relative path with normal @INC searching.
179 if (!$replaced_okay or $@) {
180 $path ="auto/$calldir/autosplit.ix";
181 eval { require $path; };
182 }
183 if ($@) {
184 my $error = $@;
185 require Carp;
186 Carp::carp($error);
187 }
188 }
189}
190
191sub unimport {
192 my $callpkg = caller;
193
194 no strict 'refs';
195
196 for my $exported (qw( AUTOLOAD )) {
197 my $symname = $callpkg . '::' . $exported;
198 undef *{ $symname } if \&{ $symname } == \&{ $exported };
199 *{ $symname } = \&{ $symname };
200 }
201}
202
2031;
204
205__END__
 
# spent 25µs within AutoLoader::CORE:fteread which was called: # once (25µs+0s) by AutoLoader::find_filename at line 98
sub AutoLoader::CORE:fteread; # opcode
# spent 22µs within AutoLoader::CORE:match which was called 2 times, avg 11µs/call: # once (16µs+0s) by AutoLoader::find_filename at line 80 # once (6µs+0s) by AutoLoader::find_filename at line 99
sub AutoLoader::CORE:match; # opcode
# spent 2µs within AutoLoader::CORE:regcomp which was called: # once (2µs+0s) by AutoLoader::find_filename at line 88
sub AutoLoader::CORE:regcomp; # opcode
# spent 12µs within AutoLoader::CORE:subst which was called 2 times, avg 6µs/call: # once (6µs+0s) by AutoLoader::find_filename at line 81 # once (6µs+0s) by AutoLoader::find_filename at line 88
sub AutoLoader::CORE:subst; # opcode
# spent 2µs within AutoLoader::CORE:substcont which was called 2 times, avg 900ns/call: # 2 times (2µs+0s) by AutoLoader::find_filename at line 88, avg 900ns/call
sub AutoLoader::CORE:substcont; # opcode