Filename | /usr/local/lib/perl5/5.24/AutoLoader.pm |
Statements | Executed 224 statements in 9.35ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
5 | 1 | 1 | 2.87ms | 4.86ms | autoload_sub | AutoLoader::
5 | 5 | 5 | 2.51ms | 2.85ms | import | AutoLoader::
5 | 1 | 1 | 486µs | 1.01ms | find_filename | AutoLoader::
10 | 2 | 1 | 288µs | 288µs | CORE:regcomp (opcode) | AutoLoader::
5 | 1 | 1 | 252µs | 252µs | CORE:fteread (opcode) | AutoLoader::
23 | 7 | 1 | 171µs | 171µs | CORE:subst (opcode) | AutoLoader::
5 | 5 | 3 | 156µs | 5.01ms | AUTOLOAD | AutoLoader::
13 | 4 | 1 | 106µs | 106µs | CORE:match (opcode) | AutoLoader::
20 | 2 | 1 | 73µs | 73µs | CORE:substcont (opcode) | AutoLoader::
1 | 1 | 1 | 51µs | 58µs | BEGIN@3 | AutoLoader::
1 | 1 | 1 | 32µs | 32µs | BEGIN@13 | AutoLoader::
1 | 1 | 1 | 32µs | 71µs | BEGIN@194 | AutoLoader::
1 | 1 | 1 | 30µs | 84µs | BEGIN@37 | AutoLoader::
1 | 1 | 1 | 27µs | 90µs | BEGIN@146 | AutoLoader::
1 | 1 | 1 | 25µs | 25µs | BEGIN@4 | AutoLoader::
0 | 0 | 0 | 0s | 0s | __ANON__[:38] | AutoLoader::
0 | 0 | 0 | 0s | 0s | unimport | AutoLoader::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package AutoLoader; | ||||
2 | |||||
3 | 2 | 64µs | 2 | 65µs | # spent 58µs (51+7) within AutoLoader::BEGIN@3 which was called:
# once (51µs+7µs) by NetAddr::IP::InetBase::BEGIN@9 at line 3 # spent 58µs making 1 call to AutoLoader::BEGIN@3
# spent 7µs making 1 call to strict::import |
4 | 2 | 259µs | 1 | 25µs | # spent 25µs within AutoLoader::BEGIN@4 which was called:
# once (25µs+0s) by NetAddr::IP::InetBase::BEGIN@9 at line 4 # spent 25µs making 1 call to AutoLoader::BEGIN@4 |
5 | |||||
6 | our($VERSION, $AUTOLOAD); | ||||
7 | |||||
8 | 1 | 2µs | my $is_dosish; | ||
9 | my $is_epoc; | ||||
10 | my $is_vms; | ||||
11 | my $is_macos; | ||||
12 | |||||
13 | # spent 32µs within AutoLoader::BEGIN@13 which was called:
# once (32µs+0s) by NetAddr::IP::InetBase::BEGIN@9 at line 19 | ||||
14 | 1 | 9µs | $is_dosish = $^O eq 'dos' || $^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'NetWare'; | ||
15 | 1 | 2µs | $is_epoc = $^O eq 'epoc'; | ||
16 | 1 | 2µs | $is_vms = $^O eq 'VMS'; | ||
17 | 1 | 8µs | $is_macos = $^O eq 'MacOS'; | ||
18 | 1 | 16µs | $VERSION = '5.74'; | ||
19 | 1 | 213µs | 1 | 32µs | } # spent 32µs making 1 call to AutoLoader::BEGIN@13 |
20 | |||||
21 | # spent 5.01ms (156µs+4.86) within AutoLoader::AUTOLOAD which was called 5 times, avg 1.00ms/call:
# once (27µs+1.52ms) by NetAddr::IP::Lite::BEGIN@9 at line 81 of NetAddr/IP/InetBase.pm
# once (40µs+1.07ms) by NetAddr::IP::InetBase::inet_any2n at line 490 of NetAddr/IP/InetBase.pm
# once (30µs+842µs) by NetAddr::IP::Lite::addr at line 1105 of NetAddr/IP/Lite.pm
# once (24µs+818µs) by IO::Socket::SSL::init at line 389 of Net/SSLeay.pm
# once (35µs+609µs) by NetAddr::IP::BEGIN@8 at line 644 of NetAddr/IP/Lite.pm | ||||
22 | 5 | 12µs | my $sub = $AUTOLOAD; | ||
23 | 5 | 35µs | 5 | 4.86ms | autoload_sub($sub); # spent 4.86ms making 5 calls to AutoLoader::autoload_sub, avg 971µs/call |
24 | 4 | 83µs | 4 | 2.21ms | goto &$sub; # spent 1.45ms making 1 call to NetAddr::IP::InetBase::inet_any2n
# spent 314µs making 1 call to Net::SSLeay::randomize
# spent 295µs making 1 call to NetAddr::IP::InetBase::ipv6_aton
# spent 157µs making 1 call to NetAddr::IP::InetBase::inet_n2dx |
25 | } | ||||
26 | |||||
27 | # spent 4.86ms (2.87+1.99) within AutoLoader::autoload_sub which was called 5 times, avg 971µs/call:
# 5 times (2.87ms+1.99ms) by AutoLoader::AUTOLOAD at line 23, avg 971µs/call | ||||
28 | 5 | 12µs | my $sub = shift; | ||
29 | |||||
30 | 5 | 41µs | 5 | 1.01ms | my $filename = AutoLoader::find_filename( $sub ); # spent 1.01ms making 5 calls to AutoLoader::find_filename, avg 202µs/call |
31 | |||||
32 | 5 | 12µs | my $save = $@; | ||
33 | 5 | 162µs | local $!; # Do not munge the value. | ||
34 | 15 | 2.48ms | eval { local $SIG{__DIE__}; require $filename }; | ||
35 | 5 | 9µs | if ($@) { | ||
36 | 1 | 26µs | 1 | 4µs | if (substr($sub,-9) eq '::DESTROY') { # spent 4µs making 1 call to AutoLoader::CORE:match |
37 | 2 | 1.22ms | 2 | 138µs | # spent 84µs (30+54) within AutoLoader::BEGIN@37 which was called:
# once (30µs+54µs) by NetAddr::IP::InetBase::BEGIN@9 at line 37 # spent 84µs making 1 call to AutoLoader::BEGIN@37
# spent 54µs making 1 call to strict::unimport |
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 | 1 | 23µs | 1 | 9µs | if ($filename =~ s/(\w{12,})\.al$/substr($1,0,11).".al"/e){ # spent 9µs making 1 call to AutoLoader::CORE:subst |
47 | eval { local $SIG{__DIE__}; require $filename }; | ||||
48 | } | ||||
49 | } | ||||
50 | 1 | 2µs | if ($@){ | ||
51 | 1 | 22µs | 1 | 9µs | $@ =~ s/ at .*\n//; # spent 9µs making 1 call to AutoLoader::CORE:subst |
52 | 1 | 2µs | my $error = $@; | ||
53 | 1 | 2µs | require Carp; | ||
54 | 1 | 6µs | 1 | 956µs | Carp::croak($error); # spent 956µs making 1 call to Carp::croak |
55 | } | ||||
56 | } | ||||
57 | 4 | 10µs | $@ = $save; | ||
58 | |||||
59 | 4 | 57µs | return 1; | ||
60 | } | ||||
61 | |||||
62 | # spent 1.01ms (486µs+524µs) within AutoLoader::find_filename which was called 5 times, avg 202µs/call:
# 5 times (486µs+524µs) by AutoLoader::autoload_sub at line 30, avg 202µs/call | ||||
63 | 5 | 11µs | my $sub = shift; | ||
64 | 5 | 9µs | 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 | |||||
80 | 10 | 126µs | 5 | 58µs | my ($pkg,$func) = ($sub =~ /(.*)::([^:]+)$/); # spent 58µs making 5 calls to AutoLoader::CORE:match, avg 12µs/call |
81 | 5 | 81µs | 5 | 36µs | $pkg =~ s#::#/#g; # spent 36µs making 5 calls to AutoLoader::CORE:subst, avg 7µs/call |
82 | 5 | 33µs | if (defined($filename = $INC{"$pkg.pm"})) { | ||
83 | 5 | 22µs | if ($is_macos) { | ||
84 | $pkg =~ tr#/#:#; | ||||
85 | $filename = undef | ||||
86 | unless $filename =~ s#^(.*)$pkg\.pm\z#$1auto:$pkg:$func.al#s; | ||||
87 | } else { | ||||
88 | 5 | 281µs | 20 | 152µs | $filename = undef # spent 85µs making 5 calls to AutoLoader::CORE:regcomp, avg 17µs/call
# spent 36µs making 10 calls to AutoLoader::CORE:substcont, avg 4µs/call
# spent 31µs making 5 calls to AutoLoader::CORE:subst, avg 6µs/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 | |||||
98 | 5 | 311µs | 5 | 252µs | if (defined $filename and -r $filename) { # spent 252µs making 5 calls to AutoLoader::CORE:fteread, avg 50µs/call |
99 | 4 | 53µs | 4 | 19µs | unless ($filename =~ m|^/|s) { # spent 19µs making 4 calls to AutoLoader::CORE:match, avg 5µs/call |
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 | 1 | 2µs | $filename = undef; | ||
125 | } | ||||
126 | } | ||||
127 | 5 | 16µs | unless (defined $filename) { | ||
128 | # let C<require> do the searching | ||||
129 | 1 | 3µs | $filename = "auto/$sub.al"; | ||
130 | 1 | 20µs | 1 | 8µs | $filename =~ s#::#/#g; # spent 8µs making 1 call to AutoLoader::CORE:subst |
131 | } | ||||
132 | } | ||||
133 | 5 | 53µs | return $filename; | ||
134 | } | ||||
135 | |||||
136 | # spent 2.85ms (2.51+344µs) within AutoLoader::import which was called 5 times, avg 571µs/call:
# once (1.04ms+59µs) by Net::SSLeay::BEGIN@24 at line 24 of Net/SSLeay.pm
# once (512µs+58µs) by NetAddr::IP::BEGIN@23 at line 23 of NetAddr/IP.pm
# once (450µs+78µs) by NetAddr::IP::InetBase::BEGIN@9 at line 9 of NetAddr/IP/InetBase.pm
# once (267µs+77µs) by Net::LibIDN::BEGIN@11 at line 11 of Net/LibIDN.pm
# once (243µs+71µs) by NetAddr::IP::Util::BEGIN@9 at line 9 of NetAddr/IP/Util.pm | ||||
137 | 5 | 12µs | my $pkg = shift; | ||
138 | 5 | 14µs | my $callpkg = caller; | ||
139 | |||||
140 | # | ||||
141 | # Export symbols, but not by accident of inheritance. | ||||
142 | # | ||||
143 | |||||
144 | 5 | 21µs | if ($pkg eq 'AutoLoader') { | ||
145 | 5 | 76µs | 3 | 25µs | if ( @_ and $_[0] =~ /^&?AUTOLOAD$/ ) { # spent 25µs making 3 calls to AutoLoader::CORE:match, avg 8µs/call |
146 | 2 | 482µs | 2 | 154µs | # spent 90µs (27+64) within AutoLoader::BEGIN@146 which was called:
# once (27µs+64µs) by NetAddr::IP::InetBase::BEGIN@9 at line 146 # spent 90µs making 1 call to AutoLoader::BEGIN@146
# spent 64µs making 1 call to strict::unimport |
147 | 6 | 45µs | *{ $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 | 5 | 84µs | 5 | 40µs | (my $calldir = $callpkg) =~ s#::#/#g; # spent 40µs making 5 calls to AutoLoader::CORE:subst, avg 8µs/call |
164 | 5 | 20µs | my $path = $INC{$calldir . '.pm'}; | ||
165 | 5 | 67µs | 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 | 5 | 9µs | my $replaced_okay; | ||
170 | 5 | 21µs | if ($is_macos) { | ||
171 | (my $malldir = $calldir) =~ tr#/#:#; | ||||
172 | $replaced_okay = ($path =~ s#^(.*)$malldir\.pm\z#$1auto:$malldir:autosplit.ix#s); | ||||
173 | } else { | ||||
174 | 5 | 417µs | 20 | 279µs | $replaced_okay = ($path =~ s#^(.*)$calldir\.pm\z#$1auto/$calldir/autosplit.ix#); # spent 204µs making 5 calls to AutoLoader::CORE:regcomp, avg 41µs/call
# spent 38µs making 5 calls to AutoLoader::CORE:subst, avg 8µs/call
# spent 37µs making 10 calls to AutoLoader::CORE:substcont, avg 4µs/call |
175 | } | ||||
176 | |||||
177 | 10 | 2.04ms | eval { require $path; } if $replaced_okay; | ||
178 | # If that failed, try relative path with normal @INC searching. | ||||
179 | 5 | 16µs | if (!$replaced_okay or $@) { | ||
180 | $path ="auto/$calldir/autosplit.ix"; | ||||
181 | eval { require $path; }; | ||||
182 | } | ||||
183 | 5 | 10µs | if ($@) { | ||
184 | my $error = $@; | ||||
185 | require Carp; | ||||
186 | Carp::carp($error); | ||||
187 | } | ||||
188 | } | ||||
189 | } | ||||
190 | |||||
191 | sub unimport { | ||||
192 | my $callpkg = caller; | ||||
193 | |||||
194 | 2 | 201µs | 2 | 111µs | # spent 71µs (32+40) within AutoLoader::BEGIN@194 which was called:
# once (32µs+40µs) by NetAddr::IP::InetBase::BEGIN@9 at line 194 # spent 71µs making 1 call to AutoLoader::BEGIN@194
# spent 40µs making 1 call to strict::unimport |
195 | |||||
196 | for my $exported (qw( AUTOLOAD )) { | ||||
197 | my $symname = $callpkg . '::' . $exported; | ||||
198 | undef *{ $symname } if \&{ $symname } == \&{ $exported }; | ||||
199 | *{ $symname } = \&{ $symname }; | ||||
200 | } | ||||
201 | } | ||||
202 | |||||
203 | 1 | 8µs | 1; | ||
204 | |||||
205 | __END__ | ||||
# spent 252µs within AutoLoader::CORE:fteread which was called 5 times, avg 50µs/call:
# 5 times (252µs+0s) by AutoLoader::find_filename at line 98, avg 50µs/call | |||||
# spent 106µs within AutoLoader::CORE:match which was called 13 times, avg 8µs/call:
# 5 times (58µs+0s) by AutoLoader::find_filename at line 80, avg 12µs/call
# 4 times (19µs+0s) by AutoLoader::find_filename at line 99, avg 5µs/call
# 3 times (25µs+0s) by AutoLoader::import at line 145, avg 8µs/call
# once (4µs+0s) by AutoLoader::autoload_sub at line 36 | |||||
sub AutoLoader::CORE:regcomp; # opcode | |||||
# spent 171µs within AutoLoader::CORE:subst which was called 23 times, avg 7µs/call:
# 5 times (40µs+0s) by AutoLoader::import at line 163, avg 8µs/call
# 5 times (38µs+0s) by AutoLoader::import at line 174, avg 8µs/call
# 5 times (36µs+0s) by AutoLoader::find_filename at line 81, avg 7µs/call
# 5 times (31µs+0s) by AutoLoader::find_filename at line 88, avg 6µs/call
# once (9µs+0s) by AutoLoader::autoload_sub at line 46
# once (9µs+0s) by AutoLoader::autoload_sub at line 51
# once (8µs+0s) by AutoLoader::find_filename at line 130 | |||||
sub AutoLoader::CORE:substcont; # opcode |