← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:12:26 2013

Filename/usr/share/perl/5.10/File/Basename.pm
StatementsExecuted 97 statements in 2.03ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.14ms1.21msFile::Basename::::BEGIN@43File::Basename::BEGIN@43
33291µs114µsFile::Basename::::fileparseFile::Basename::fileparse
11164µs113µsFile::Basename::::fileparse_set_fstypeFile::Basename::fileparse_set_fstype
101139µs39µsFile::Basename::::CORE:regcompFile::Basename::CORE:regcomp (opcode)
11138µs149µsFile::Basename::::dirnameFile::Basename::dirname
132134µs34µsFile::Basename::::CORE:matchFile::Basename::CORE:match (opcode)
11132µs49µsFile::Basename::::_strip_trailing_sepFile::Basename::_strip_trailing_sep
11132µs32µsFile::Basename::::BEGIN@51File::Basename::BEGIN@51
11116µs16µsFile::Basename::::BEGIN@371File::Basename::BEGIN@371
11111µs14µsFile::Basename::::BEGIN@50File::Basename::BEGIN@50
11110µs10µsFile::Basename::::CORE:substFile::Basename::CORE:subst (opcode)
1119µs22µsFile::Basename::::BEGIN@52File::Basename::BEGIN@52
2117µs7µsFile::Basename::::CORE:substcontFile::Basename::CORE:substcont (opcode)
0000s0sFile::Basename::::basenameFile::Basename::basename
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1=head1 NAME
2
- -
38package File::Basename;
39
40# A bit of juggling to insure that C<use re 'taint';> always works, since
41# File::Basename is used during the Perl build, when the re extension may
42# not be available.
43
# spent 1.21ms (1.14+70µs) within File::Basename::BEGIN@43 which was called: # once (1.14ms+70µs) by Template::Provider::BEGIN@47 at line 47
BEGIN {
44281µs unless (eval { require re; })
45 { eval ' sub re::import { $^H |= 0x00100000; } ' } # HINT_RE_TAINT
4619µs121µs import re 'taint';
# spent 21µs making 1 call to re::import
47131µs11.21ms}
# spent 1.21ms making 1 call to File::Basename::BEGIN@43
48
49
50325µs217µs
# spent 14µs (11+3) within File::Basename::BEGIN@50 which was called: # once (11µs+3µs) by Template::Provider::BEGIN@47 at line 50
use strict;
# spent 14µs making 1 call to File::Basename::BEGIN@50 # spent 3µs making 1 call to strict::import
51351µs132µs
# spent 32µs within File::Basename::BEGIN@51 which was called: # once (32µs+0s) by Template::Provider::BEGIN@47 at line 51
use 5.006;
# spent 32µs making 1 call to File::Basename::BEGIN@51
5231.42ms234µs
# spent 22µs (9+12) within File::Basename::BEGIN@52 which was called: # once (9µs+12µs) by Template::Provider::BEGIN@47 at line 52
use warnings;
# spent 22µs making 1 call to File::Basename::BEGIN@52 # spent 12µs making 1 call to warnings::import
5311µsour(@ISA, @EXPORT, $VERSION, $Fileparse_fstype, $Fileparse_igncase);
5411µsrequire Exporter;
55117µs@ISA = qw(Exporter);
5613µs@EXPORT = qw(fileparse fileparse_set_fstype basename dirname);
571600ns$VERSION = "2.77";
58
5914µs1113µsfileparse_set_fstype($^O);
# spent 113µs making 1 call to File::Basename::fileparse_set_fstype
60
61
62=over 4
63
- -
104
# spent 114µs (91+23) within File::Basename::fileparse which was called 3 times, avg 38µs/call: # once (48µs+13µs) by File::Basename::dirname at line 294 # once (31µs+7µs) by FindBin::init at line 179 of FindBin.pm # once (12µs+3µs) by FindBin::init at line 186 of FindBin.pm
sub fileparse {
10535µs my($fullname,@suffices) = @_;
106
10732µs unless (defined $fullname) {
108 require Carp;
109 Carp::croak("fileparse(): need a valid pathname");
110 }
111
11233µs my $orig_type = '';
11334µs my($type,$igncase) = ($Fileparse_fstype, $Fileparse_igncase);
114
11534µs my($taint) = substr($fullname,0,0); # Is $fullname tainted?
116
11732µs if ($type eq "VMS" and $fullname =~ m{/} ) {
118 # We're doing Unix emulation
119 $orig_type = $type;
120 $type = 'Unix';
121 }
122
12332µs my($dirpath, $basename);
124
125316µs if (grep { $type eq $_ } qw(MSDOS DOS MSWin32 Epoc)) {
126 ($dirpath,$basename) = ($fullname =~ /^((?:.*[:\\\/])?)(.*)/s);
127 $dirpath .= '.\\' unless $dirpath =~ /[\\\/]\z/;
128 }
129 elsif ($type eq "OS2") {
130 ($dirpath,$basename) = ($fullname =~ m#^((?:.*[:\\/])?)(.*)#s);
131 $dirpath = './' unless $dirpath; # Can't be 0
132 $dirpath .= '/' unless $dirpath =~ m#[\\/]\z#;
133 }
134 elsif ($type eq "MacOS") {
135 ($dirpath,$basename) = ($fullname =~ /^(.*:)?(.*)/s);
136 $dirpath = ':' unless $dirpath;
137 }
138 elsif ($type eq "AmigaOS") {
139 ($dirpath,$basename) = ($fullname =~ /(.*[:\/])?(.*)/s);
140 $dirpath = './' unless $dirpath;
141 }
142 elsif ($type eq 'VMS' ) {
143 ($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/s);
144 $dirpath ||= ''; # should always be defined
145 }
146 else { # Default to Unix semantics.
147348µs323µs ($dirpath,$basename) = ($fullname =~ m{^(.*/)?(.*)}s);
# spent 23µs making 3 calls to File::Basename::CORE:match, avg 8µs/call
14833µs if ($orig_type eq 'VMS' and $fullname =~ m{^(/[^/]+/000000(/|$))(.*)}) {
149 # dev:[000000] is top of VMS tree, similar to Unix '/'
150 # so strip it off and treat the rest as "normal"
151 my $devspec = $1;
152 my $remainder = $3;
153 ($dirpath,$basename) = ($remainder =~ m{^(.*/)?(.*)}s);
154 $dirpath ||= ''; # should always be defined
155 $dirpath = $devspec.$dirpath;
156 }
15733µs $dirpath = './' unless $dirpath;
158 }
159
160
16133µs my $tail = '';
16232µs my $suffix = '';
16332µs if (@suffices) {
164 foreach $suffix (@suffices) {
165 my $pat = ($igncase ? '(?i)' : '') . "($suffix)\$";
166 if ($basename =~ s/$pat//s) {
167 $taint .= substr($suffix,0,0);
168 $tail = $1 . $tail;
169 }
170 }
171 }
172
173 # Ensure taint is propgated from the path to its pieces.
17432µs $tail .= $taint;
175324µs wantarray ? ($basename .= $taint, $dirpath .= $taint, $tail)
176 : ($basename .= $taint);
177}
178
- -
181=item C<basename>
182
- -
214sub basename {
215 my($path) = shift;
216
217 # From BSD basename(1)
218 # The basename utility deletes any prefix ending with the last slash `/'
219 # character present in string (after first stripping trailing slashes)
220 _strip_trailing_sep($path);
221
222 my($basename, $dirname, $suffix) = fileparse( $path, map("\Q$_\E",@_) );
223
224 # From BSD basename(1)
225 # The suffix is not stripped if it is identical to the remaining
226 # characters in string.
227 if( length $suffix and !length $basename ) {
228 $basename = $suffix;
229 }
230
231 # Ensure that basename '/' == '/'
232 if( !length $basename ) {
233 $basename = $dirname;
234 }
235
236 return $basename;
237}
238
- -
241=item C<dirname>
242
- -
283
# spent 149µs (38+111) within File::Basename::dirname which was called: # once (38µs+111µs) by XML::SAX::load_parsers at line 57 of XML/SAX.pm
sub dirname {
2841800ns my $path = shift;
285
28612µs my($type) = $Fileparse_fstype;
287
28812µs if( $type eq 'VMS' and $path =~ m{/} ) {
289 # Parse as Unix
290 local($File::Basename::Fileparse_fstype) = '';
291 return dirname($path);
292 }
293
29416µs162µs my($basename, $dirname) = fileparse($path);
# spent 62µs making 1 call to File::Basename::fileparse
295
29617µs if ($type eq 'VMS') {
297 $dirname ||= $ENV{DEFAULT};
298 }
299 elsif ($type eq 'MacOS') {
300 if( !length($basename) && $dirname !~ /^[^:]+:\z/) {
301 _strip_trailing_sep($dirname);
302 ($basename,$dirname) = fileparse $dirname;
303 }
304 $dirname .= ":" unless $dirname =~ /:\z/;
305 }
306 elsif (grep { $type eq $_ } qw(MSDOS DOS MSWin32 OS2)) {
307 _strip_trailing_sep($dirname);
308 unless( length($basename) ) {
309 ($basename,$dirname) = fileparse $dirname;
310 _strip_trailing_sep($dirname);
311 }
312 }
313 elsif ($type eq 'AmigaOS') {
314 if ( $dirname =~ /:\z/) { return $dirname }
315 chop $dirname;
316 $dirname =~ s{[^:/]+\z}{} unless length($basename);
317 }
318 else {
31917µs149µs _strip_trailing_sep($dirname);
# spent 49µs making 1 call to File::Basename::_strip_trailing_sep
32012µs unless( length($basename) ) {
321 ($basename,$dirname) = fileparse $dirname;
322 _strip_trailing_sep($dirname);
323 }
324 }
325
326111µs $dirname;
327}
328
329
330# Strip the trailing path separator.
331
# spent 49µs (32+17) within File::Basename::_strip_trailing_sep which was called: # once (32µs+17µs) by File::Basename::dirname at line 319
sub _strip_trailing_sep {
33211µs my $type = $Fileparse_fstype;
333
33417µs if ($type eq 'MacOS') {
335 $_[0] =~ s/([^:]):\z/$1/s;
336 }
337 elsif (grep { $type eq $_ } qw(MSDOS DOS MSWin32 OS2)) {
338 $_[0] =~ s/([^:])[\\\/]*\z/$1/;
339 }
340 else {
341140µs317µs $_[0] =~ s{(.)/*\z}{$1}s;
# spent 10µs making 1 call to File::Basename::CORE:subst # spent 7µs making 2 calls to File::Basename::CORE:substcont, avg 4µs/call
342 }
343}
344
345
346=item C<fileparse_set_fstype>
347
- -
371
# spent 16µs within File::Basename::BEGIN@371 which was called: # once (16µs+0s) by Template::Provider::BEGIN@47 at line 394
BEGIN {
372
37314µsmy @Ignore_Case = qw(MacOS VMS AmigaOS OS2 RISCOS MSWin32 MSDOS DOS Epoc);
374112µsmy @Types = (@Ignore_Case, qw(Unix));
375
376
# spent 113µs (64+49) within File::Basename::fileparse_set_fstype which was called: # once (64µs+49µs) by Template::Provider::BEGIN@47 at line 59
sub fileparse_set_fstype {
3771600ns my $old = $Fileparse_fstype;
378
37911µs if (@_) {
38013µs my $new_type = shift;
381
3821600ns $Fileparse_fstype = 'Unix'; # default
38312µs foreach my $type (@Types) {
38410100µs2049µs $Fileparse_fstype = $type if $new_type =~ /^$type/i;
# spent 39µs making 10 calls to File::Basename::CORE:regcomp, avg 4µs/call # spent 10µs making 10 calls to File::Basename::CORE:match, avg 1µs/call
385 }
386
387 $Fileparse_igncase =
38813µs (grep $Fileparse_fstype eq $_, @Ignore_Case) ? 1 : 0;
389 }
390
39114µs return $old;
392}
393
394143µs116µs}
# spent 16µs making 1 call to File::Basename::BEGIN@371
395
396
39717µs1;
398
399
400=head1 SEE ALSO
 
# spent 34µs within File::Basename::CORE:match which was called 13 times, avg 3µs/call: # 10 times (10µs+0s) by File::Basename::fileparse_set_fstype at line 384, avg 1µs/call # 3 times (23µs+0s) by File::Basename::fileparse at line 147, avg 8µs/call
sub File::Basename::CORE:match; # opcode
# spent 39µs within File::Basename::CORE:regcomp which was called 10 times, avg 4µs/call: # 10 times (39µs+0s) by File::Basename::fileparse_set_fstype at line 384, avg 4µs/call
sub File::Basename::CORE:regcomp; # opcode
# spent 10µs within File::Basename::CORE:subst which was called: # once (10µs+0s) by File::Basename::_strip_trailing_sep at line 341
sub File::Basename::CORE:subst; # opcode
# spent 7µs within File::Basename::CORE:substcont which was called 2 times, avg 4µs/call: # 2 times (7µs+0s) by File::Basename::_strip_trailing_sep at line 341, avg 4µs/call
sub File::Basename::CORE:substcont; # opcode