← Index
NYTProf Performance Profile   « line view »
For webmerge/scripts/webmerge.pl
  Run on Mon Oct 7 02:42:42 2013
Reported on Mon Oct 7 03:03:20 2013

Filename/usr/lib64/perl5/vendor_perl/5.16.0/File/Which.pm
StatementsExecuted 22 statements in 4.92ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1116.50ms92.6msFile::Which::::BEGIN@16File::Which::BEGIN@16
11199µs99µsFile::Which::::BEGIN@3File::Which::BEGIN@3
11181µs81µsFile::Which::::BEGIN@9File::Which::BEGIN@9
11165µs264µsFile::Which::::BEGIN@17File::Which::BEGIN@17
11165µs268µsFile::Which::::BEGIN@18File::Which::BEGIN@18
11153µs144µsFile::Which::::BEGIN@4File::Which::BEGIN@4
11147µs430µsFile::Which::::BEGIN@8File::Which::BEGIN@8
11122µs22µsFile::Which::::BEGIN@5File::Which::BEGIN@5
11121µs21µsFile::Which::::BEGIN@6File::Which::BEGIN@6
0000s0sFile::Which::::whereFile::Which::where
0000s0sFile::Which::::whichFile::Which::which
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package File::Which;
2
32305µs199µs
# spent 99µs within File::Which::BEGIN@3 which was called: # once (99µs+0s) by RTP::Webmerge::BEGIN@15 at line 3
use 5.004;
# spent 99µs making 1 call to File::Which::BEGIN@3
42136µs2236µs
# spent 144µs (53+92) within File::Which::BEGIN@4 which was called: # once (53µs+92µs) by RTP::Webmerge::BEGIN@15 at line 4
use strict;
# spent 144µs making 1 call to File::Which::BEGIN@4 # spent 92µs making 1 call to strict::import
52117µs122µs
# spent 22µs within File::Which::BEGIN@5 which was called: # once (22µs+0s) by RTP::Webmerge::BEGIN@15 at line 5
use Exporter ();
# spent 22µs making 1 call to File::Which::BEGIN@5
62140µs121µs
# spent 21µs within File::Which::BEGIN@6 which was called: # once (21µs+0s) by RTP::Webmerge::BEGIN@15 at line 6
use File::Spec ();
# spent 21µs making 1 call to File::Which::BEGIN@6
7
82288µs2814µs
# spent 430µs (47+383) within File::Which::BEGIN@8 which was called: # once (47µs+383µs) by RTP::Webmerge::BEGIN@15 at line 8
use vars qw{$VERSION @ISA @EXPORT @EXPORT_OK};
# spent 430µs making 1 call to File::Which::BEGIN@8 # spent 383µs making 1 call to vars::import
9
# spent 81µs within File::Which::BEGIN@9 which was called: # once (81µs+0s) by RTP::Webmerge::BEGIN@15 at line 14
BEGIN {
1013µs $VERSION = '1.09';
11146µs @ISA = 'Exporter';
1216µs @EXPORT = 'which';
13185µs @EXPORT_OK = 'where';
141168µs181µs}
# spent 81µs making 1 call to File::Which::BEGIN@9
15
162835µs292.9ms
# spent 92.6ms (6.50+86.1) within File::Which::BEGIN@16 which was called: # once (6.50ms+86.1ms) by RTP::Webmerge::BEGIN@15 at line 16
use constant IS_VMS => ($^O eq 'VMS');
# spent 92.6ms making 1 call to File::Which::BEGIN@16 # spent 278µs making 1 call to constant::import
172327µs2463µs
# spent 264µs (65+199) within File::Which::BEGIN@17 which was called: # once (65µs+199µs) by RTP::Webmerge::BEGIN@15 at line 17
use constant IS_MAC => ($^O eq 'MacOS');
# spent 264µs making 1 call to File::Which::BEGIN@17 # spent 199µs making 1 call to constant::import
1822.44ms2472µs
# spent 268µs (65+203) within File::Which::BEGIN@18 which was called: # once (65µs+203µs) by RTP::Webmerge::BEGIN@15 at line 18
use constant IS_DOS => ($^O eq 'MSWin32' or $^O eq 'dos' or $^O eq 'os2');
# spent 268µs making 1 call to File::Which::BEGIN@18 # spent 203µs making 1 call to constant::import
19
20# For Win32 systems, stores the extensions used for
21# executable files
22# For others, the empty string is used
23# because 'perl' . '' eq 'perl' => easier
2417µsmy @PATHEXT = ('');
25if ( IS_DOS ) {
26 # WinNT. PATHEXT might be set on Cygwin, but not used.
27 if ( $ENV{PATHEXT} ) {
28 push @PATHEXT, split ';', $ENV{PATHEXT};
29 } else {
30 # Win9X or other: doesn't have PATHEXT, so needs hardcoded.
31 push @PATHEXT, qw{.com .exe .bat};
32 }
33} elsif ( IS_VMS ) {
34 push @PATHEXT, qw{.exe .com};
35}
36
37sub which {
38 my ($exec) = @_;
39
40 return undef unless $exec;
41
42 my $all = wantarray;
43 my @results = ();
44
45 # check for aliases first
46 if ( IS_VMS ) {
47 my $symbol = `SHOW SYMBOL $exec`;
48 chomp($symbol);
49 unless ( $? ) {
50 return $symbol unless $all;
51 push @results, $symbol;
52 }
53 }
54 if ( IS_MAC ) {
55 my @aliases = split /\,/, $ENV{Aliases};
56 foreach my $alias ( @aliases ) {
57 # This has not been tested!!
58 # PPT which says MPW-Perl cannot resolve `Alias $alias`,
59 # let's just hope it's fixed
60 if ( lc($alias) eq lc($exec) ) {
61 chomp(my $file = `Alias $alias`);
62 last unless $file; # if it failed, just go on the normal way
63 return $file unless $all;
64 push @results, $file;
65 # we can stop this loop as if it finds more aliases matching,
66 # it'll just be the same result anyway
67 last;
68 }
69 }
70 }
71
72 my @path = File::Spec->path;
73 if ( IS_DOS or IS_VMS or IS_MAC ) {
74 unshift @path, File::Spec->curdir;
75 }
76
77 foreach my $base ( map { File::Spec->catfile($_, $exec) } @path ) {
78 for my $ext ( @PATHEXT ) {
79 my $file = $base.$ext;
80
81 # We don't want dirs (as they are -x)
82 next if -d $file;
83
84 if (
85 # Executable, normal case
86 -x _
87 or (
88 # MacOS doesn't mark as executable so we check -e
89 IS_MAC
90 ||
91 (
92 IS_DOS
93 and
94 grep {
95 $file =~ /$_\z/i
96 } @PATHEXT[1..$#PATHEXT]
97 )
98 # DOSish systems don't pass -x on
99 # non-exe/bat/com files. so we check -e.
100 # However, we don't want to pass -e on files
101 # that aren't in PATHEXT, like README.
102 and -e _
103 )
104 ) {
105 return $file unless $all;
106 push @results, $file;
107 }
108 }
109 }
110
111 if ( $all ) {
112 return @results;
113 } else {
114 return undef;
115 }
116}
117
118sub where {
119 # force wantarray
120 my @res = which($_[0]);
121 return @res;
122}
123
124116µs1;
125
126__END__