Filename | /usr/share/perl/5.18/AutoLoader.pm |
Statements | Executed 147 statements in 2.31ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
3 | 1 | 1 | 664µs | 964µs | autoload_sub | AutoLoader::
3 | 3 | 3 | 313µs | 374µs | import | AutoLoader::
3 | 1 | 1 | 69µs | 136µs | find_filename | AutoLoader::
6 | 2 | 1 | 43µs | 43µs | CORE:regcomp (opcode) | AutoLoader::
15 | 7 | 1 | 37µs | 37µs | CORE:subst (opcode) | AutoLoader::
3 | 1 | 1 | 26µs | 26µs | CORE:fteread (opcode) | AutoLoader::
3 | 3 | 2 | 24µs | 988µs | AUTOLOAD | AutoLoader::
9 | 4 | 1 | 22µs | 22µs | CORE:match (opcode) | AutoLoader::
1 | 1 | 1 | 12µs | 24µs | BEGIN@3 | AutoLoader::
1 | 1 | 1 | 10µs | 10µs | BEGIN@4 | AutoLoader::
1 | 1 | 1 | 7µs | 22µs | BEGIN@146 | AutoLoader::
1 | 1 | 1 | 7µs | 18µs | BEGIN@194 | AutoLoader::
12 | 2 | 1 | 7µs | 7µs | CORE:substcont (opcode) | AutoLoader::
1 | 1 | 1 | 6µs | 17µs | BEGIN@37 | AutoLoader::
1 | 1 | 1 | 6µs | 6µs | BEGIN@13 | 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 | 24µs | 2 | 35µs | # spent 24µs (12+12) within AutoLoader::BEGIN@3 which was called:
# once (12µs+12µs) by NetAddr::IP::InetBase::BEGIN@9 at line 3 # spent 24µs making 1 call to AutoLoader::BEGIN@3
# spent 12µs making 1 call to strict::import |
4 | 2 | 114µs | 1 | 10µs | # spent 10µs within AutoLoader::BEGIN@4 which was called:
# once (10µs+0s) by NetAddr::IP::InetBase::BEGIN@9 at line 4 # spent 10µs making 1 call to AutoLoader::BEGIN@4 |
5 | |||||
6 | 1 | 200ns | our($VERSION, $AUTOLOAD); | ||
7 | |||||
8 | 1 | 200ns | my $is_dosish; | ||
9 | 1 | 100ns | my $is_epoc; | ||
10 | 1 | 0s | my $is_vms; | ||
11 | 1 | 0s | my $is_macos; | ||
12 | |||||
13 | # spent 6µs within AutoLoader::BEGIN@13 which was called:
# once (6µs+0s) by NetAddr::IP::InetBase::BEGIN@9 at line 19 | ||||
14 | 1 | 2µs | $is_dosish = $^O eq 'dos' || $^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'NetWare'; | ||
15 | 1 | 300ns | $is_epoc = $^O eq 'epoc'; | ||
16 | 1 | 200ns | $is_vms = $^O eq 'VMS'; | ||
17 | 1 | 300ns | $is_macos = $^O eq 'MacOS'; | ||
18 | 1 | 4µs | $VERSION = '5.73'; | ||
19 | 1 | 105µs | 1 | 6µs | } # spent 6µs making 1 call to AutoLoader::BEGIN@13 |
20 | |||||
21 | # spent 988µs (24+964) within AutoLoader::AUTOLOAD which was called 3 times, avg 329µs/call:
# once (7µs+407µs) by NetAddr::IP::Lite::BEGIN@9 at line 81 of NetAddr/IP/InetBase.pm
# once (8µs+393µs) by NetAddr::IP::InetBase::inet_any2n at line 490 of NetAddr/IP/InetBase.pm
# once (9µs+164µs) by NetAddr::IP::BEGIN@8 at line 649 of NetAddr/IP/Lite.pm | ||||
22 | 3 | 1µs | my $sub = $AUTOLOAD; | ||
23 | 3 | 2µs | 3 | 964µs | autoload_sub($sub); # spent 964µs making 3 calls to AutoLoader::autoload_sub, avg 321µs/call |
24 | 2 | 12µs | 2 | 552µs | goto &$sub; # spent 483µs making 1 call to NetAddr::IP::InetBase::inet_any2n
# spent 70µs making 1 call to NetAddr::IP::InetBase::ipv6_aton |
25 | } | ||||
26 | |||||
27 | # spent 964µs (664+300) within AutoLoader::autoload_sub which was called 3 times, avg 321µs/call:
# 3 times (664µs+300µs) by AutoLoader::AUTOLOAD at line 23, avg 321µs/call | ||||
28 | 3 | 900ns | my $sub = shift; | ||
29 | |||||
30 | 3 | 3µs | 3 | 136µs | my $filename = AutoLoader::find_filename( $sub ); # spent 136µs making 3 calls to AutoLoader::find_filename, avg 45µs/call |
31 | |||||
32 | 3 | 600ns | my $save = $@; | ||
33 | 3 | 127µs | local $!; # Do not munge the value. | ||
34 | 9 | 500µs | eval { local $SIG{__DIE__}; require $filename }; | ||
35 | 3 | 700ns | if ($@) { | ||
36 | 1 | 10µs | 1 | 2µs | if (substr($sub,-9) eq '::DESTROY') { # spent 2µs making 1 call to AutoLoader::CORE:match |
37 | 2 | 535µs | 2 | 27µs | # spent 17µs (6+10) within AutoLoader::BEGIN@37 which was called:
# once (6µs+10µs) by NetAddr::IP::InetBase::BEGIN@9 at line 37 # spent 17µs making 1 call to AutoLoader::BEGIN@37
# spent 10µ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 | 7µs | 1 | 4µs | if ($filename =~ s/(\w{12,})\.al$/substr($1,0,11).".al"/e){ # spent 4µs making 1 call to AutoLoader::CORE:subst |
47 | eval { local $SIG{__DIE__}; require $filename }; | ||||
48 | } | ||||
49 | } | ||||
50 | 1 | 100ns | if ($@){ | ||
51 | 1 | 4µs | 1 | 2µs | $@ =~ s/ at .*\n//; # spent 2µs making 1 call to AutoLoader::CORE:subst |
52 | 1 | 500ns | my $error = $@; | ||
53 | 1 | 300ns | require Carp; | ||
54 | 1 | 2µs | 1 | 156µs | Carp::croak($error); # spent 156µs making 1 call to Carp::croak |
55 | } | ||||
56 | } | ||||
57 | 2 | 600ns | $@ = $save; | ||
58 | |||||
59 | 2 | 10µs | return 1; | ||
60 | } | ||||
61 | |||||
62 | # spent 136µs (69+67) within AutoLoader::find_filename which was called 3 times, avg 45µs/call:
# 3 times (69µs+67µs) by AutoLoader::autoload_sub at line 30, avg 45µs/call | ||||
63 | 3 | 700ns | my $sub = shift; | ||
64 | 3 | 300ns | 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 | 6 | 20µs | 3 | 10µs | my ($pkg,$func) = ($sub =~ /(.*)::([^:]+)$/); # spent 10µs making 3 calls to AutoLoader::CORE:match, avg 3µs/call |
81 | 3 | 12µs | 3 | 6µs | $pkg =~ s#::#/#g; # spent 6µs making 3 calls to AutoLoader::CORE:subst, avg 2µs/call |
82 | 3 | 4µs | if (defined($filename = $INC{"$pkg.pm"})) { | ||
83 | 3 | 1µ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 | 3 | 44µs | 12 | 20µs | $filename = undef # spent 12µs making 3 calls to AutoLoader::CORE:regcomp, avg 4µs/call
# spent 5µs making 3 calls to AutoLoader::CORE:subst, avg 2µs/call
# spent 3µs making 6 calls to AutoLoader::CORE:substcont, avg 533ns/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 | 3 | 35µs | 3 | 26µs | if (defined $filename and -r $filename) { # spent 26µs making 3 calls to AutoLoader::CORE:fteread, avg 9µs/call |
99 | 2 | 6µs | 2 | 2µs | unless ($filename =~ m|^/|s) { # spent 2µs making 2 calls to AutoLoader::CORE:match, avg 1µ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 | 400ns | $filename = undef; | ||
125 | } | ||||
126 | } | ||||
127 | 3 | 2µs | unless (defined $filename) { | ||
128 | # let C<require> do the searching | ||||
129 | 1 | 700ns | $filename = "auto/$sub.al"; | ||
130 | 1 | 5µs | 1 | 2µs | $filename =~ s#::#/#g; # spent 2µs making 1 call to AutoLoader::CORE:subst |
131 | } | ||||
132 | } | ||||
133 | 3 | 8µs | return $filename; | ||
134 | } | ||||
135 | |||||
136 | # spent 374µs (313+60) within AutoLoader::import which was called 3 times, avg 125µs/call:
# once (142µs+19µs) by NetAddr::IP::BEGIN@23 at line 23 of NetAddr/IP.pm
# once (112µs+23µs) by NetAddr::IP::InetBase::BEGIN@9 at line 9 of NetAddr/IP/InetBase.pm
# once (59µs+18µs) by NetAddr::IP::Util::BEGIN@9 at line 9 of NetAddr/IP/Util.pm | ||||
137 | 3 | 1µs | my $pkg = shift; | ||
138 | 3 | 2µs | my $callpkg = caller; | ||
139 | |||||
140 | # | ||||
141 | # Export symbols, but not by accident of inheritance. | ||||
142 | # | ||||
143 | |||||
144 | 3 | 2µs | if ($pkg eq 'AutoLoader') { | ||
145 | 3 | 20µs | 3 | 8µs | if ( @_ and $_[0] =~ /^&?AUTOLOAD$/ ) { # spent 8µs making 3 calls to AutoLoader::CORE:match, avg 3µs/call |
146 | 2 | 248µs | 2 | 38µs | # spent 22µs (7+15) within AutoLoader::BEGIN@146 which was called:
# once (7µs+15µs) by NetAddr::IP::InetBase::BEGIN@9 at line 146 # spent 22µs making 1 call to AutoLoader::BEGIN@146
# spent 15µs making 1 call to strict::unimport |
147 | 3 | 9µ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 | 3 | 14µs | 3 | 7µs | (my $calldir = $callpkg) =~ s#::#/#g; # spent 7µs making 3 calls to AutoLoader::CORE:subst, avg 2µs/call |
164 | 3 | 2µs | my $path = $INC{$calldir . '.pm'}; | ||
165 | 3 | 15µ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 | 3 | 300ns | my $replaced_okay; | ||
170 | 3 | 1µ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 | 3 | 74µs | 12 | 46µs | $replaced_okay = ($path =~ s#^(.*)$calldir\.pm\z#$1auto/$calldir/autosplit.ix#); # spent 31µs making 3 calls to AutoLoader::CORE:regcomp, avg 10µs/call
# spent 11µs making 3 calls to AutoLoader::CORE:subst, avg 4µs/call
# spent 4µs making 6 calls to AutoLoader::CORE:substcont, avg 683ns/call |
175 | } | ||||
176 | |||||
177 | 6 | 233µs | eval { require $path; } if $replaced_okay; | ||
178 | # If that failed, try relative path with normal @INC searching. | ||||
179 | 3 | 1µs | if (!$replaced_okay or $@) { | ||
180 | $path ="auto/$calldir/autosplit.ix"; | ||||
181 | eval { require $path; }; | ||||
182 | } | ||||
183 | 3 | 1µ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 | 80µs | 2 | 29µs | # spent 18µs (7+11) within AutoLoader::BEGIN@194 which was called:
# once (7µs+11µs) by NetAddr::IP::InetBase::BEGIN@9 at line 194 # spent 18µs making 1 call to AutoLoader::BEGIN@194
# spent 11µ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 | 4µs | 1; | ||
204 | |||||
205 | __END__ | ||||
# spent 26µs within AutoLoader::CORE:fteread which was called 3 times, avg 9µs/call:
# 3 times (26µs+0s) by AutoLoader::find_filename at line 98, avg 9µs/call | |||||
# spent 22µs within AutoLoader::CORE:match which was called 9 times, avg 2µs/call:
# 3 times (10µs+0s) by AutoLoader::find_filename at line 80, avg 3µs/call
# 3 times (8µs+0s) by AutoLoader::import at line 145, avg 3µs/call
# 2 times (2µs+0s) by AutoLoader::find_filename at line 99, avg 1µs/call
# once (2µs+0s) by AutoLoader::autoload_sub at line 36 | |||||
sub AutoLoader::CORE:regcomp; # opcode | |||||
# spent 37µs within AutoLoader::CORE:subst which was called 15 times, avg 2µs/call:
# 3 times (11µs+0s) by AutoLoader::import at line 174, avg 4µs/call
# 3 times (7µs+0s) by AutoLoader::import at line 163, avg 2µs/call
# 3 times (6µs+0s) by AutoLoader::find_filename at line 81, avg 2µs/call
# 3 times (5µs+0s) by AutoLoader::find_filename at line 88, avg 2µs/call
# once (4µs+0s) by AutoLoader::autoload_sub at line 46
# once (2µs+0s) by AutoLoader::find_filename at line 130
# once (2µs+0s) by AutoLoader::autoload_sub at line 51 | |||||
sub AutoLoader::CORE:substcont; # opcode |