Filename | /usr/share/perl/5.10/AutoLoader.pm |
Statements | Executed 121 statements in 4.11ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
4 | 4 | 2 | 1.61ms | 1.70ms | import | AutoLoader::
2 | 2 | 2 | 917µs | 1.16ms | AUTOLOAD | AutoLoader::
2 | 1 | 1 | 113µs | 245µs | find_filename | AutoLoader::
4 | 2 | 1 | 77µs | 77µs | CORE:regcomp (opcode) | AutoLoader::
11 | 5 | 1 | 61µs | 61µs | CORE:subst (opcode) | AutoLoader::
2 | 1 | 1 | 39µs | 39µs | CORE:fteread (opcode) | AutoLoader::
5 | 3 | 1 | 39µs | 39µs | CORE:match (opcode) | AutoLoader::
1 | 1 | 1 | 25µs | 25µs | BEGIN@4 | AutoLoader::
1 | 1 | 1 | 24µs | 32µs | BEGIN@3 | AutoLoader::
8 | 2 | 1 | 12µs | 12µs | CORE:substcont (opcode) | AutoLoader::
1 | 1 | 1 | 11µs | 31µs | BEGIN@138 | AutoLoader::
1 | 1 | 1 | 10µs | 24µs | BEGIN@186 | AutoLoader::
1 | 1 | 1 | 9µs | 29µs | BEGIN@30 | AutoLoader::
1 | 1 | 1 | 9µs | 9µs | BEGIN@13 | AutoLoader::
1 | 1 | 1 | 2µs | 2µs | __ANON__[:31] | AutoLoader::
0 | 0 | 0 | 0s | 0s | unimport | AutoLoader::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package AutoLoader; | ||||
2 | |||||
3 | 3 | 32µs | 2 | 41µs | # spent 32µs (24+8) within AutoLoader::BEGIN@3 which was called:
# once (24µs+8µs) by DBI::BEGIN@157 at line 3 # spent 32µs making 1 call to AutoLoader::BEGIN@3
# spent 8µs making 1 call to strict::import |
4 | 3 | 112µs | 1 | 25µs | # spent 25µs within AutoLoader::BEGIN@4 which was called:
# once (25µs+0s) by DBI::BEGIN@157 at line 4 # spent 25µs making 1 call to AutoLoader::BEGIN@4 |
5 | |||||
6 | 1 | 500ns | our($VERSION, $AUTOLOAD); | ||
7 | |||||
8 | 1 | 200ns | my $is_dosish; | ||
9 | 1 | 200ns | my $is_epoc; | ||
10 | 1 | 100ns | my $is_vms; | ||
11 | 1 | 100ns | my $is_macos; | ||
12 | |||||
13 | # spent 9µs within AutoLoader::BEGIN@13 which was called:
# once (9µs+0s) by DBI::BEGIN@157 at line 19 | ||||
14 | 1 | 3µs | $is_dosish = $^O eq 'dos' || $^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'NetWare'; | ||
15 | 1 | 400ns | $is_epoc = $^O eq 'epoc'; | ||
16 | 1 | 400ns | $is_vms = $^O eq 'VMS'; | ||
17 | 1 | 500ns | $is_macos = $^O eq 'MacOS'; | ||
18 | 1 | 5µs | $VERSION = '5.68'; | ||
19 | 1 | 75µs | 1 | 9µs | } # spent 9µs making 1 call to AutoLoader::BEGIN@13 |
20 | |||||
21 | # spent 1.16ms (917µs+245µs) within AutoLoader::AUTOLOAD which was called 2 times, avg 581µs/call:
# once (798µs+100µs) by POSIX::import at line 44 of POSIX.pm
# once (119µs+146µs) by C4::XSLT::XSLTParse4Display at line 228 of /usr/share/koha/lib/C4/XSLT.pm | ||||
22 | 2 | 4µs | my $sub = $AUTOLOAD; | ||
23 | 2 | 9µs | 2 | 245µs | my $filename = AutoLoader::find_filename( $sub ); # spent 245µs making 2 calls to AutoLoader::find_filename, avg 123µs/call |
24 | |||||
25 | 2 | 1µs | my $save = $@; | ||
26 | 2 | 118µs | local $!; # Do not munge the value. | ||
27 | 6 | 744µs | eval { local $SIG{__DIE__}; require $filename }; | ||
28 | 2 | 2µs | if ($@) { | ||
29 | 1 | 4µs | if (substr($sub,-9) eq '::DESTROY') { | ||
30 | 3 | 680µs | 2 | 49µs | # spent 29µs (9+20) within AutoLoader::BEGIN@30 which was called:
# once (9µs+20µs) by DBI::BEGIN@157 at line 30 # spent 29µs making 1 call to AutoLoader::BEGIN@30
# spent 20µs making 1 call to strict::unimport |
31 | 2 | 14µs | # spent 2µs within AutoLoader::__ANON__[/usr/share/perl/5.10/AutoLoader.pm:31] which was called:
# once (2µs+0s) by C4::XSLT::XSLTParse4Display at line 51 | ||
32 | 1 | 500ns | $@ = 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 | 1 | 500ns | if ($@){ | ||
44 | $@ =~ s/ at .*\n//; | ||||
45 | my $error = $@; | ||||
46 | require Carp; | ||||
47 | Carp::croak($error); | ||||
48 | } | ||||
49 | } | ||||
50 | 2 | 1µs | $@ = $save; | ||
51 | 2 | 27µs | 2 | 662µs | goto &$sub; # spent 660µs making 1 call to POSIX::load_imports
# spent 2µs making 1 call to AutoLoader::__ANON__[AutoLoader.pm:31] |
52 | } | ||||
53 | |||||
54 | # spent 245µs (113+133) within AutoLoader::find_filename which was called 2 times, avg 123µs/call:
# 2 times (113µs+133µs) by AutoLoader::AUTOLOAD at line 23, avg 123µs/call | ||||
55 | 2 | 3µs | my $sub = shift; | ||
56 | 2 | 2µs | 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 | 42µs | 2 | 23µs | my ($pkg,$func) = ($sub =~ /(.*)::([^:]+)$/); # spent 23µs making 2 calls to AutoLoader::CORE:match, avg 11µs/call |
73 | 2 | 18µs | 2 | 8µs | $pkg =~ s#::#/#g; # spent 8µs making 2 calls to AutoLoader::CORE:subst, avg 4µs/call |
74 | 2 | 8µs | if (defined($filename = $INC{"$pkg.pm"})) { | ||
75 | 2 | 3µ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 | 2 | 93µs | 8 | 58µs | $filename = undef # spent 44µs making 2 calls to AutoLoader::CORE:regcomp, avg 22µs/call
# spent 8µs making 2 calls to AutoLoader::CORE:subst, avg 4µs/call
# spent 5µs making 4 calls to AutoLoader::CORE:substcont, avg 1µ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 | 2 | 51µs | 2 | 39µs | if (defined $filename and -r $filename) { # spent 39µs making 2 calls to AutoLoader::CORE:fteread, avg 20µs/call |
91 | 1 | 5µs | 1 | 2µs | unless ($filename =~ m|^/|s) { # spent 2µ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 | 1 | 1µs | $filename = undef; | ||
117 | } | ||||
118 | } | ||||
119 | 2 | 2µs | unless (defined $filename) { | ||
120 | # let C<require> do the searching | ||||
121 | 1 | 2µs | $filename = "auto/$sub.al"; | ||
122 | 1 | 8µs | 1 | 3µs | $filename =~ s#::#/#g; # spent 3µs making 1 call to AutoLoader::CORE:subst |
123 | } | ||||
124 | } | ||||
125 | 2 | 10µs | return $filename; | ||
126 | } | ||||
127 | |||||
128 | # spent 1.70ms (1.61+95µs) within AutoLoader::import which was called 4 times, avg 426µs/call:
# once (1.26ms+32µs) by POSIX::BEGIN@9 at line 9 of POSIX.pm
# once (268µs+34µs) by Storable::BEGIN@22 at line 22 of Storable.pm
# once (52µs+21µs) by POSIX::SigAction::BEGIN@58 at line 58 of POSIX.pm
# once (30µs+8µs) by POSIX::SigRt::BEGIN@62 at line 62 of POSIX.pm | ||||
129 | 4 | 7µs | my $pkg = shift; | ||
130 | 4 | 6µs | my $callpkg = caller; | ||
131 | |||||
132 | # | ||||
133 | # Export symbols, but not by accident of inheritance. | ||||
134 | # | ||||
135 | |||||
136 | 4 | 10µs | if ($pkg eq 'AutoLoader') { | ||
137 | 4 | 45µs | 2 | 14µs | if ( @_ and $_[0] =~ /^&?AUTOLOAD$/ ) { # spent 14µs making 2 calls to AutoLoader::CORE:match, avg 7µs/call |
138 | 3 | 229µs | 2 | 51µs | # spent 31µs (11+20) within AutoLoader::BEGIN@138 which was called:
# once (11µs+20µs) by DBI::BEGIN@157 at line 138 # spent 31µs making 1 call to AutoLoader::BEGIN@138
# spent 20µs making 1 call to strict::unimport |
139 | 2 | 17µs | *{ $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 | 4 | 56µs | 4 | 21µs | (my $calldir = $callpkg) =~ s#::#/#g; # spent 21µs making 4 calls to AutoLoader::CORE:subst, avg 5µs/call |
156 | 4 | 9µs | my $path = $INC{$calldir . '.pm'}; | ||
157 | 4 | 43µ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 | 2 | 1µs | my $replaced_okay; | ||
162 | 2 | 3µ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 | 2 | 102µs | 8 | 60µs | $replaced_okay = ($path =~ s#^(.*)$calldir\.pm\z#$1auto/$calldir/autosplit.ix#); # spent 33µs making 2 calls to AutoLoader::CORE:regcomp, avg 16µs/call
# spent 21µs making 2 calls to AutoLoader::CORE:subst, avg 11µs/call
# spent 6µs making 4 calls to AutoLoader::CORE:substcont, avg 2µs/call |
167 | } | ||||
168 | |||||
169 | 4 | 1.41ms | eval { require $path; } if $replaced_okay; | ||
170 | # If that failed, try relative path with normal @INC searching. | ||||
171 | 2 | 2µs | if (!$replaced_okay or $@) { | ||
172 | $path ="auto/$calldir/autosplit.ix"; | ||||
173 | eval { require $path; }; | ||||
174 | } | ||||
175 | 2 | 2µs | if ($@) { | ||
176 | my $error = $@; | ||||
177 | require Carp; | ||||
178 | Carp::carp($error); | ||||
179 | } | ||||
180 | } | ||||
181 | } | ||||
182 | |||||
183 | sub unimport { | ||||
184 | my $callpkg = caller; | ||||
185 | |||||
186 | 3 | 80µs | 2 | 38µs | # spent 24µs (10+14) within AutoLoader::BEGIN@186 which was called:
# once (10µs+14µs) by DBI::BEGIN@157 at line 186 # spent 24µs making 1 call to AutoLoader::BEGIN@186
# spent 14µ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 | 4µs | 1; | ||
196 | |||||
197 | __END__ | ||||
# spent 39µs within AutoLoader::CORE:fteread which was called 2 times, avg 20µs/call:
# 2 times (39µs+0s) by AutoLoader::find_filename at line 90, avg 20µs/call | |||||
sub AutoLoader::CORE:match; # opcode | |||||
sub AutoLoader::CORE:regcomp; # opcode | |||||
# spent 61µs within AutoLoader::CORE:subst which was called 11 times, avg 6µs/call:
# 4 times (21µs+0s) by AutoLoader::import at line 155, avg 5µs/call
# 2 times (21µs+0s) by AutoLoader::import at line 166, avg 11µs/call
# 2 times (8µs+0s) by AutoLoader::find_filename at line 80, avg 4µs/call
# 2 times (8µs+0s) by AutoLoader::find_filename at line 73, avg 4µs/call
# once (3µs+0s) by AutoLoader::find_filename at line 122 | |||||
sub AutoLoader::CORE:substcont; # opcode |