Profile of AutoLoader.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For bin/dpath
Run on Tue Jun 5 15:31:33 2012
Reported on Tue Jun 5 15:31:43 2012

Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/AutoLoader.pm
Statements | Executed 73 statements in 10.3ms

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
3 | 3 | 1 | 2.88ms | 3.01ms | AutoLoader::::importAutoLoader::import
1 | 1 | 1 | 2.53ms | 2.86ms | AutoLoader::::AUTOLOADAutoLoader::AUTOLOAD
1 | 1 | 1 | 145µs | 328µs | AutoLoader::::find_filenameAutoLoader::find_filename
2 | 2 | 1 | 128µs | 128µs | AutoLoader::::CORE:regcompAutoLoader::CORE:regcomp (opcode)
1 | 1 | 1 | 68µs | 106µs | AutoLoader::::BEGIN@186AutoLoader::BEGIN@186
1 | 1 | 1 | 66µs | 66µs | AutoLoader::::BEGIN@4AutoLoader::BEGIN@4
6 | 4 | 1 | 65µs | 65µs | AutoLoader::::CORE:substAutoLoader::CORE:subst (opcode)
1 | 1 | 1 | 53µs | 53µs | AutoLoader::::CORE:ftereadAutoLoader::CORE:fteread (opcode)
4 | 3 | 1 | 47µs | 47µs | AutoLoader::::CORE:matchAutoLoader::CORE:match (opcode)
1 | 1 | 1 | 46µs | 57µs | AutoLoader::::BEGIN@3AutoLoader::BEGIN@3
1 | 1 | 1 | 39µs | 39µs | AutoLoader::::BEGIN@13AutoLoader::BEGIN@13
1 | 1 | 1 | 32µs | 82µs | AutoLoader::::BEGIN@138AutoLoader::BEGIN@138
1 | 1 | 1 | 28µs | 79µs | AutoLoader::::BEGIN@30AutoLoader::BEGIN@30
4 | 2 | 1 | 15µs | 15µs | AutoLoader::::CORE:substcontAutoLoader::CORE:substcont (opcode)
0 | 0 | 0 | 0s | 0s | AutoLoader::::__ANON__[:31]AutoLoader::__ANON__[:31]
0 | 0 | 0 | 0s | 0s | AutoLoader::::unimportAutoLoader::unimport

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package AutoLoader;
2 |  |  |  |  |
3 | 2 | 97µs | 2 | 68µs | # spent 57µs (46+11) within AutoLoader::BEGIN@3 which was called: # once (46µs+11µs) by POSIX::BEGIN@9 at line 3 use strict; # spent 57µs making 1 call to AutoLoader::BEGIN@3 # spent 11µs making 1 call to strict::import
4 | 2 | 529µs | 1 | 66µs | # spent 66µs within AutoLoader::BEGIN@4 which was called: # once (66µs+0s) by POSIX::BEGIN@9 at line 4 use 5.006_001; # spent 66µs making 1 call to AutoLoader::BEGIN@4
5 |  |  |  |  |
6 | 1 | 1µs |  |  | our($VERSION, $AUTOLOAD);
7 |  |  |  |  |
8 | 1 | 600ns |  |  | my $is_dosish;
9 | 1 | 300ns |  |  | my $is_epoc;
10 | 1 | 300ns |  |  | my $is_vms;
11 | 1 | 300ns |  |  | my $is_macos;
12 |  |  |  |  |
13 |  |  |  |  | # spent 39µs within AutoLoader::BEGIN@13 which was called: # once (39µs+0s) by POSIX::BEGIN@9 at line 19 BEGIN {
14 | 5 | 42µs |  |  | $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.71';
19 | 1 | 334µs | 1 | 39µs | } # spent 39µs making 1 call to AutoLoader::BEGIN@13
20 |  |  |  |  |
21 |  |  |  |  | # spent 2.86ms (2.53+328µs) within AutoLoader::AUTOLOAD which was called: # once (2.53ms+328µs) by POSIX::import at line 43 of POSIX.pm AUTOLOAD {
22 | 8 | 82µs |  |  | my $sub = $AUTOLOAD;
23 |  |  | 1 | 328µs | my $filename = AutoLoader::find_filename( $sub ); # spent 328µs making 1 call to AutoLoader::find_filename
24 |  |  |  |  |
25 |  |  |  |  | my $save = $@;
26 |  |  |  |  | local $!; # Do not munge the value.
27 | 2 | 2.46ms |  |  | eval { local $SIG{__DIE__}; require $filename };
28 |  |  |  |  | if ($@) {
29 |  |  |  |  | if (substr($sub,-9) eq '::DESTROY') {
30 | 2 | 2.21ms | 2 | 131µs | # spent 79µs (28+52) within AutoLoader::BEGIN@30 which was called: # once (28µs+52µs) by POSIX::BEGIN@9 at line 30 no strict 'refs'; # spent 79µs making 1 call to AutoLoader::BEGIN@30 # spent 52µs making 1 call to strict::unimport
31 |  |  |  |  | *$sub = sub {};
32 |  |  |  |  | $@ = undef;
33 |  |  |  |  | } elsif ($@ =~ /^Can't locate/) {
34 |  |  |  |  | # The load might just have failed because the filename was too
35 |  |  |  |  | # long for some old SVR3 systems which treat long names as errors.
36 |  |  |  |  | # If we can successfully truncate a long name then it's worth a go.
37 |  |  |  |  | # There is a slight risk that we could pick up the wrong file here
38 |  |  |  |  | # but autosplit should have warned about that when splitting.
39 |  |  |  |  | if ($filename =~ s/(\w{12,})\.al$/substr($1,0,11).".al"/e){
40 |  |  |  |  | eval { local $SIG{__DIE__}; require $filename };
41 |  |  |  |  | }
42 |  |  |  |  | }
43 |  |  |  |  | if ($@){
44 |  |  |  |  | $@ =~ s/ at .*\n//;
45 |  |  |  |  | my $error = $@;
46 |  |  |  |  | require Carp;
47 |  |  |  |  | Carp::croak($error);
48 |  |  |  |  | }
49 |  |  |  |  | }
50 |  |  |  |  | $@ = $save;
51 |  |  | 1 | 1.88ms | goto &$sub; # spent 1.88ms making 1 call to POSIX::load_imports
52 |  |  |  |  | }
53 |  |  |  |  |
54 |  |  |  |  | # spent 328µs (145+183) within AutoLoader::find_filename which was called: # once (145µs+183µs) by AutoLoader::AUTOLOAD at line 23 sub find_filename {
55 | 4 | 23µs |  |  | my $sub = shift;
56 |  |  |  |  | my $filename;
57 |  |  |  |  | # Braces used to preserve $1 et al.
58 |  |  |  |  | {
59 |  |  |  |  | # Try to find the autoloaded file from the package-qualified
60 |  |  |  |  | # name of the sub. e.g., if the sub needed is
61 |  |  |  |  | # Getopt::Long::GetOptions(), then $INC{Getopt/Long.pm} is
62 |  |  |  |  | # something like '/usr/lib/perl5/Getopt/Long.pm', and the
63 |  |  |  |  | # autoload file is '/usr/lib/perl5/auto/Getopt/Long/GetOptions.al'.
64 |  |  |  |  | #
65 |  |  |  |  | # However, if @INC is a relative path, this might not work. If,
66 |  |  |  |  | # for example, @INC = ('lib'), then $INC{Getopt/Long.pm} is
67 |  |  |  |  | # 'lib/Getopt/Long.pm', and we want to require
68 |  |  |  |  | # 'auto/Getopt/Long/GetOptions.al' (without the leading 'lib').
69 |  |  |  |  | # In this case, we simple prepend the 'auto/' and let the
70 |  |  |  |  | # C<require> take care of the searching for us.
71 |  |  |  |  |
72 | 4 | 56µs | 1 | 15µs | my ($pkg,$func) = ($sub =~ /(.*)::([^:]+)$/); # spent 15µs making 1 call to AutoLoader::CORE:match
73 |  |  | 1 | 3µs | $pkg =~ s#::#/#g; # spent 3µs making 1 call to AutoLoader::CORE:subst
74 | 2 | 78µs |  |  | if (defined($filename = $INC{"$pkg.pm"})) {
75 | 1 | 161µs |  |  | if ($is_macos) {
76 |  |  |  |  | $pkg =~ tr#/#:#;
77 |  |  |  |  | $filename = undef
78 |  |  |  |  | unless $filename =~ s#^(.*)$pkg\.pm\z#$1auto:$pkg:$func.al#s;
79 |  |  |  |  | } else {
80 |  |  | 4 | 105µs | $filename = undef # spent 85µs making 1 call to AutoLoader::CORE:regcomp # spent 12µs making 1 call to AutoLoader::CORE:subst # spent 8µs making 2 calls to AutoLoader::CORE:substcont, avg 4µs/call
81 |  |  |  |  | unless $filename =~ s#^(.*)$pkg\.pm\z#$1auto/$pkg/$func.al#s;
82 |  |  |  |  | }
83 |  |  |  |  |
84 |  |  |  |  | # if the file exists, then make sure that it is a
85 |  |  |  |  | # a fully anchored path (i.e either '/usr/lib/auto/foo/bar.al',
86 |  |  |  |  | # or './lib/auto/foo/bar.al'. This avoids C<require> searching
87 |  |  |  |  | # (and failing) to find the 'lib/auto/foo/bar.al' because it
88 |  |  |  |  | # looked for 'lib/lib/auto/foo/bar.al', given @INC = ('lib').
89 |  |  |  |  |
90 | 1 | 17µs | 1 | 53µs | if (defined $filename and -r $filename) { # spent 53µs making 1 call to AutoLoader::CORE:fteread
91 |  |  | 1 | 6µs | unless ($filename =~ m|^/|s) { # spent 6µs making 1 call to AutoLoader::CORE:match
92 |  |  |  |  | if ($is_dosish) {
93 |  |  |  |  | unless ($filename =~ m{^([a-z]:)?[\\/]}is) {
94 |  |  |  |  | if ($^O ne 'NetWare') {
95 |  |  |  |  | $filename = "./$filename";
96 |  |  |  |  | } else {
97 |  |  |  |  | $filename = "$filename";
98 |  |  |  |  | }
99 |  |  |  |  | }
100 |  |  |  |  | }
101 |  |  |  |  | elsif ($is_epoc) {
102 |  |  |  |  | unless ($filename =~ m{^([a-z?]:)?[\\/]}is) {
103 |  |  |  |  | $filename = "./$filename";
104 |  |  |  |  | }
105 |  |  |  |  | }
106 |  |  |  |  | elsif ($is_vms) {
107 |  |  |  |  | # XXX todo by VMSmiths
108 |  |  |  |  | $filename = "./$filename";
109 |  |  |  |  | }
110 |  |  |  |  | elsif (!$is_macos) {
111 |  |  |  |  | $filename = "./$filename";
112 |  |  |  |  | }
113 |  |  |  |  | }
114 |  |  |  |  | }
115 |  |  |  |  | else {
116 |  |  |  |  | $filename = undef;
117 |  |  |  |  | }
118 |  |  |  |  | }
119 |  |  |  |  | unless (defined $filename) {
120 |  |  |  |  | # let C<require> do the searching
121 |  |  |  |  | $filename = "auto/$sub.al";
122 |  |  |  |  | $filename =~ s#::#/#g;
123 |  |  |  |  | }
124 |  |  |  |  | }
125 |  |  |  |  | return $filename;
126 |  |  |  |  | }
127 |  |  |  |  |
128 |  |  |  |  | # spent 3.01ms (2.88+126µs) within AutoLoader::import which was called 3 times, avg 1.00ms/call: # once (2.75ms+81µs) by POSIX::BEGIN@9 at line 9 of POSIX.pm # once (92µs+32µs) by POSIX::SigAction::BEGIN@52 at line 52 of POSIX.pm # once (43µs+14µs) by POSIX::SigRt::BEGIN@56 at line 56 of POSIX.pm sub import {
129 | 18 | 147µs |  |  | my $pkg = shift;
130 |  |  |  |  | my $callpkg = caller;
131 |  |  |  |  |
132 |  |  |  |  | #
133 |  |  |  |  | # Export symbols, but not by accident of inheritance.
134 |  |  |  |  | #
135 |  |  |  |  |
136 | 3 | 80µs |  |  | if ($pkg eq 'AutoLoader') {
137 | 2 | 28µs | 2 | 27µs | if ( @_ and $_[0] =~ /^&?AUTOLOAD$/ ) { # spent 27µs making 2 calls to AutoLoader::CORE:match, avg 13µs/call
138 | 2 | 881µs | 2 | 131µs | # spent 82µs (32+50) within AutoLoader::BEGIN@138 which was called: # once (32µs+50µs) by POSIX::BEGIN@9 at line 138 no strict 'refs'; # spent 82µs making 1 call to AutoLoader::BEGIN@138 # spent 50µs making 1 call to strict::unimport
139 |  |  |  |  | *{ $callpkg . '::AUTOLOAD' } = \&AUTOLOAD;
140 |  |  |  |  | }
141 |  |  |  |  | }
142 |  |  |  |  |
143 |  |  |  |  | #
144 |  |  |  |  | # Try to find the autosplit index file. Eg., if the call package
145 |  |  |  |  | # is POSIX, then $INC{POSIX.pm} is something like
146 |  |  |  |  | # '/usr/local/lib/perl5/POSIX.pm', and the autosplit index file is in
147 |  |  |  |  | # '/usr/local/lib/perl5/auto/POSIX/autosplit.ix', so we require that.
148 |  |  |  |  | #
149 |  |  |  |  | # However, if @INC is a relative path, this might not work. If,
150 |  |  |  |  | # for example, @INC = ('lib'), then
151 |  |  |  |  | # $INC{POSIX.pm} is 'lib/POSIX.pm', and we want to require
152 |  |  |  |  | # 'auto/POSIX/autosplit.ix' (without the leading 'lib').
153 |  |  |  |  | #
154 |  |  |  |  |
155 |  |  | 3 | 26µs | (my $calldir = $callpkg) =~ s#::#/#g; # spent 26µs making 3 calls to AutoLoader::CORE:subst, avg 9µs/call
156 |  |  |  |  | my $path = $INC{$calldir . '.pm'};
157 | 5 | 11µs |  |  | if (defined($path)) {
158 |  |  |  |  | # Try absolute path name, but only eval it if the
159 |  |  |  |  | # transformation from module path to autosplit.ix path
160 |  |  |  |  | # succeeded!
161 |  |  |  |  | my $replaced_okay;
162 | 1 | 129µs |  |  | if ($is_macos) {
163 |  |  |  |  | (my $malldir = $calldir) =~ tr#/#:#;
164 |  |  |  |  | $replaced_okay = ($path =~ s#^(.*)$malldir\.pm\z#$1auto:$malldir:autosplit.ix#s);
165 |  |  |  |  | } else {
166 |  |  | 4 | 74µs | $replaced_okay = ($path =~ s#^(.*)$calldir\.pm\z#$1auto/$calldir/autosplit.ix#); # spent 43µs making 1 call to AutoLoader::CORE:regcomp # spent 24µs making 1 call to AutoLoader::CORE:subst # spent 7µs making 2 calls to AutoLoader::CORE:substcont, avg 4µs/call
167 |  |  |  |  | }
168 |  |  |  |  |
169 | 1 | 2.62ms |  |  | eval { require $path; } if $replaced_okay;
170 |  |  |  |  | # If that failed, try relative path with normal @INC searching.
171 |  |  |  |  | if (!$replaced_okay or $@) {
172 |  |  |  |  | $path ="auto/$calldir/autosplit.ix";
173 |  |  |  |  | eval { require $path; };
174 |  |  |  |  | }
175 |  |  |  |  | if ($@) {
176 |  |  |  |  | my $error = $@;
177 |  |  |  |  | require Carp;
178 |  |  |  |  | Carp::carp($error);
179 |  |  |  |  | }
180 |  |  |  |  | }
181 |  |  |  |  | }
182 |  |  |  |  |
183 |  |  |  |  | sub unimport {
184 |  |  |  |  | my $callpkg = caller;
185 |  |  |  |  |
186 | 2 | 320µs | 2 | 145µs | # spent 106µs (68+38) within AutoLoader::BEGIN@186 which was called: # once (68µs+38µs) by POSIX::BEGIN@9 at line 186 no strict 'refs'; # spent 106µs making 1 call to AutoLoader::BEGIN@186 # spent 38µs making 1 call to strict::unimport
187 |  |  |  |  |
188 |  |  |  |  | for my $exported (qw( AUTOLOAD )) {
189 |  |  |  |  | my $symname = $callpkg . '::' . $exported;
190 |  |  |  |  | undef *{ $symname } if \&{ $symname } == \&{ $exported };
191 |  |  |  |  | *{ $symname } = \&{ $symname };
192 |  |  |  |  | }
193 |  |  |  |  | }
194 |  |  |  |  |
195 | 1 | 14µs |  |  | 1;
196 |  |  |  |  |
197 |  |  |  |  | __END__
|  |  |  |  | # spent 53µs within AutoLoader::CORE:fteread which was called: # once (53µs+0s) by AutoLoader::find_filename at line 90 sub AutoLoader::CORE:fteread; # opcode
|  |  |  |  | # spent 47µs within AutoLoader::CORE:match which was called 4 times, avg 12µs/call: # 2 times (27µs+0s) by AutoLoader::import at line 137, avg 13µs/call # once (15µs+0s) by AutoLoader::find_filename at line 72 # once (6µs+0s) by AutoLoader::find_filename at line 91 sub AutoLoader::CORE:match; # opcode
|  |  |  |  | # spent 128µs within AutoLoader::CORE:regcomp which was called 2 times, avg 64µs/call: # once (85µs+0s) by AutoLoader::find_filename at line 80 # once (43µs+0s) by AutoLoader::import at line 166 sub AutoLoader::CORE:regcomp; # opcode
|  |  |  |  | # spent 65µs within AutoLoader::CORE:subst which was called 6 times, avg 11µs/call: # 3 times (26µs+0s) by AutoLoader::import at line 155, avg 9µs/call # once (24µs+0s) by AutoLoader::import at line 166 # once (12µs+0s) by AutoLoader::find_filename at line 80 # once (3µs+0s) by AutoLoader::find_filename at line 73 sub AutoLoader::CORE:subst; # opcode
|  |  |  |  | # spent 15µs within AutoLoader::CORE:substcont which was called 4 times, avg 4µs/call: # 2 times (8µs+0s) by AutoLoader::find_filename at line 80, avg 4µs/call # 2 times (7µs+0s) by AutoLoader::import at line 166, avg 4µs/call sub AutoLoader::CORE:substcont; # opcode