← Index
NYTProf Performance Profile   « line view »
For Makefile.PL
  Run on Sun Mar 1 16:04:44 2015
Reported on Sun Mar 1 16:09:02 2015

FilenameC:/tmp64ng/perl/vendor/lib/Portable/FileSpec.pm
StatementsExecuted 1189 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1110s0sPortable::FileSpec::::BEGIN@5Portable::FileSpec::BEGIN@5
1110s0sPortable::FileSpec::::BEGIN@6Portable::FileSpec::BEGIN@6
1110s0sPortable::FileSpec::::BEGIN@7Portable::FileSpec::BEGIN@7
158910s0sPortable::FileSpec::::CORE:matchPortable::FileSpec::CORE:match (opcode)
63310s0sPortable::FileSpec::::CORE:regcompPortable::FileSpec::CORE:regcomp (opcode)
470710s0sPortable::FileSpec::::CORE:substPortable::FileSpec::CORE:subst (opcode)
66310s0sPortable::FileSpec::::_canon_catPortable::FileSpec::_canon_cat
63550s0sPortable::FileSpec::::catdirPortable::FileSpec::catdir
3220s0sPortable::FileSpec::::catfilePortable::FileSpec::catfile
6310s0sPortable::FileSpec::::catpathPortable::FileSpec::catpath
1110s0sPortable::FileSpec::::splitdirPortable::FileSpec::splitdir
1110s0sPortable::FileSpec::::splitpathPortable::FileSpec::splitpath
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Portable::FileSpec;
2
3### UGLY HACK: these functions where completely copied from File::Spec::Win32
4
520s10s
# spent 0s within Portable::FileSpec::BEGIN@5 which was called: # once (0s+0s) by Portable::BEGIN@55 at line 5
use 5.008;
# spent 0s making 1 call to Portable::FileSpec::BEGIN@5
620s20s
# spent 0s within Portable::FileSpec::BEGIN@6 which was called: # once (0s+0s) by Portable::BEGIN@55 at line 6
use strict;
# spent 0s making 1 call to Portable::FileSpec::BEGIN@6 # spent 0s making 1 call to strict::import
720s20s
# spent 0s within Portable::FileSpec::BEGIN@7 which was called: # once (0s+0s) by Portable::BEGIN@55 at line 7
use warnings;
# spent 0s making 1 call to Portable::FileSpec::BEGIN@7 # spent 0s making 1 call to warnings::import
8
910sour $VERSION = '1.22';
10
11# Some regexes we use for path splitting
1210smy $DRIVE_RX = '[a-zA-Z]:';
1310smy $UNC_RX = '(?:\\\\\\\\|//)[^\\\\/]+[\\\\/][^\\\\/]+';
1410smy $VOL_RX = "(?:$DRIVE_RX|$UNC_RX)";
15
16
# spent 0s within Portable::FileSpec::splitpath which was called: # once (0s+0s) by Portable::default at line 187 of Portable.pm
sub splitpath {
1710s my ($path, $nofile) = @_;
1810s my ($volume,$directory,$file) = ('','','');
1910s if ( $nofile ) {
20 $path =~
21 m{^ ( $VOL_RX ? ) (.*) }sox;
22 $volume = $1;
23 $directory = $2;
24 }
25 else {
2610s20s $path =~
# spent 0s making 1 call to Portable::FileSpec::CORE:match # spent 0s making 1 call to Portable::FileSpec::CORE:regcomp
27 m{^ ( $VOL_RX ? )
28 ( (?:.*[\\/](?:\.\.?\Z(?!\n))?)? )
29 (.*)
30 }sox;
3110s $volume = $1;
3210s $directory = $2;
3310s $file = $3;
34 }
35
3610s return ($volume,$directory,$file);
37}
38
39
# spent 0s within Portable::FileSpec::splitdir which was called: # once (0s+0s) by Portable::default at line 188 of Portable.pm
sub splitdir {
4010s my ($directories) = @_ ;
41 #
42 # split() likes to forget about trailing null fields, so here we
43 # check to be sure that there will not be any before handling the
44 # simple case.
45 #
4610s10s if ( $directories !~ m|[\\/]\Z(?!\n)| ) {
# spent 0s making 1 call to Portable::FileSpec::CORE:match
47 return split( m|[\\/]|, $directories );
48 }
49 else {
50 #
51 # since there was a trailing separator, add a file name to the end,
52 # then do the split, then replace it with ''.
53 #
5410s my( @directories )= split( m|[\\/]|, "${directories}dummy" ) ;
5510s $directories[ $#directories ]= '' ;
5610s return @directories ;
57 }
58}
59
60
# spent 0s within Portable::FileSpec::catpath which was called 6 times, avg 0s/call: # 4 times (0s+0s) by Portable::default at line 190 of Portable.pm, avg 0s/call # once (0s+0s) by Portable::default at line 202 of Portable.pm # once (0s+0s) by Portable::default at line 203 of Portable.pm
sub catpath {
6160s my ($volume,$directory,$file) = @_;
62
63 # If it's UNC, make sure the glue separator is there, reusing
64 # whatever separator is first in the $volume
6560s my $v;
6660s60s $volume .= $v
# spent 0s making 6 calls to Portable::FileSpec::CORE:match, avg 0s/call
67 if ( (($v) = $volume =~ m@^([\\/])[\\/][^\\/]+[\\/][^\\/]+\Z(?!\n)@s) &&
68 $directory =~ m@^[^\\/]@s
69 ) ;
70
7160s $volume .= $directory ;
72
73 # If the volume is not just A:, make sure the glue separator is
74 # there, reusing whatever separator is first in the $volume if possible.
7560s170s if ( $volume !~ m@^[a-zA-Z]:\Z(?!\n)@s &&
# spent 0s making 17 calls to Portable::FileSpec::CORE:match, avg 0s/call
76 $volume =~ m@[^\\/]\Z(?!\n)@ &&
77 $file =~ m@[^\\/]@
78 ) {
7940s40s $volume =~ m@([\\/])@ ;
# spent 0s making 4 calls to Portable::FileSpec::CORE:match, avg 0s/call
8040s my $sep = $1 ? $1 : '\\' ;
8140s $volume .= $sep ;
82 }
83
8460s $volume .= $file ;
85
8660s return $volume ;
87}
88
89
# spent 0s within Portable::FileSpec::catdir which was called 63 times, avg 0s/call: # 50 times (0s+0s) by Portable::Config::new at line 40 of Portable/Config.pm, avg 0s/call # 6 times (0s+0s) by Portable::CPAN::new at line 57 of Portable/CPAN.pm, avg 0s/call # 4 times (0s+0s) by Portable::default at line 194 of Portable.pm, avg 0s/call # 2 times (0s+0s) by Portable::HomeDir::new at line 37 of Portable/HomeDir.pm, avg 0s/call # once (0s+0s) by Portable::minicpan::new at line 35 of Portable/minicpan.pm
sub catdir {
90 # Legacy / compatibility support
91630s return "" unless @_;
92630s40s shift, return _canon_cat( "/", @_ ) if $_[0] eq "";
# spent 0s making 4 calls to Portable::FileSpec::_canon_cat, avg 0s/call
93
94 # Compatibility with File::Spec <= 3.26:
95 # catdir('A:', 'foo') should return 'A:\foo'.
96590s1180s return _canon_cat( ($_[0].'\\'), @_[1..$#_] ) if $_[0] =~ m{^$DRIVE_RX\z}o;
# spent 0s making 59 calls to Portable::FileSpec::CORE:match, avg 0s/call # spent 0s making 59 calls to Portable::FileSpec::CORE:regcomp, avg 0s/call
97
98590s590s return _canon_cat( @_ );
# spent 0s making 59 calls to Portable::FileSpec::_canon_cat, avg 0s/call
99}
100
101
# spent 0s within Portable::FileSpec::catfile which was called 3 times, avg 0s/call: # 2 times (0s+0s) by Portable::CPAN::new at line 54 of Portable/CPAN.pm, avg 0s/call # once (0s+0s) by Portable::Config::new at line 37 of Portable/Config.pm
sub catfile {
102 # Legacy / compatibility support
103 #
10430s shift, return _canon_cat( "/", @_ )
105 if $_[0] eq "";
106
107 # Compatibility with File::Spec <= 3.26:
108 # catfile('A:', 'foo') should return 'A:\foo'.
10930s60s return _canon_cat( ($_[0].'\\'), @_[1..$#_] )
# spent 0s making 3 calls to Portable::FileSpec::CORE:match, avg 0s/call # spent 0s making 3 calls to Portable::FileSpec::CORE:regcomp, avg 0s/call
110 if $_[0] =~ m{^$DRIVE_RX\z}o;
111
11230s30s return _canon_cat( @_ );
# spent 0s making 3 calls to Portable::FileSpec::_canon_cat, avg 0s/call
113}
114
115
# spent 0s within Portable::FileSpec::_canon_cat which was called 66 times, avg 0s/call: # 59 times (0s+0s) by Portable::FileSpec::catdir at line 98, avg 0s/call # 4 times (0s+0s) by Portable::FileSpec::catdir at line 92, avg 0s/call # 3 times (0s+0s) by Portable::FileSpec::catfile at line 112, avg 0s/call
sub _canon_cat {
116660s my ($first, @rest) = @_;
117
118660s740s my $volume = $first =~ s{ \A ([A-Za-z]:) ([\\/]?) }{}x # drive letter
# spent 0s making 74 calls to Portable::FileSpec::CORE:subst, avg 0s/call
119 ? ucfirst( $1 ).( $2 ? "\\" : "" )
120 : $first =~ s{ \A (?:\\\\|//) ([^\\/]+)
121 (?: [\\/] ([^\\/]+) )?
122 [\\/]? }{}xs # UNC volume
123 ? "\\\\$1".( defined $2 ? "\\$2" : "" )."\\"
124 : $first =~ s{ \A [\\/] }{}x # root dir
125 ? "\\"
126 : "";
127660s my $path = join "\\", $first, @rest;
128
129660s $path =~ tr#\\/#\\\\#s; # xx/yy --> xx\yy & xx\\yy --> xx\yy
130
131 # xx/././yy --> xx/yy
132660s660s $path =~ s{(?:
# spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call
133 (?:\A|\\) # at begin or after a slash
134 \.
135 (?:\\\.)* # and more
136 (?:\\|\z) # at end or followed by slash
137 )+ # performance boost -- I do not know why
138 }{\\}gx;
139
140 # XXX I do not know whether more dots are supported by the OS supporting
141 # this ... annotation (NetWare or symbian but not MSWin32).
142 # Then .... could easily become ../../.. etc:
143 # Replace \.\.\. by (\.\.\.+) and substitute with
144 # { $1 . ".." . "\\.." x (length($2)-2) }gex
145 # ... --> ../..
146660s660s $path =~ s{ (\A|\\) # at begin or after a slash
# spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call
147 \.\.\.
148 (?=\\|\z) # at end or followed by slash
149 }{$1..\\..}gx;
150 # xx\yy\..\zz --> xx\zz
151660s660s while ( $path =~ s{(?:
# spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call
152 (?:\A|\\) # at begin or after a slash
153 [^\\]+ # rip this 'yy' off
154 \\\.\.
155 (?<!\A\.\.\\\.\.) # do *not* replace ^..\..
156 (?<!\\\.\.\\\.\.) # do *not* replace \..\..
157 (?:\\|\z) # at end or followed by slash
158 )+ # performance boost -- I do not know why
159 }{\\}sx ) {}
160
161660s660s $path =~ s#\A\\##; # \xx --> xx NOTE: this is *not* root
# spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call
162660s660s $path =~ s#\\\z##; # xx\ --> xx
# spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call
163
164660s660s if ( $volume =~ m#\\\z# )
# spent 0s making 66 calls to Portable::FileSpec::CORE:match, avg 0s/call
165 { # <vol>\.. --> <vol>\
166660s660s $path =~ s{ \A # at begin
# spent 0s making 66 calls to Portable::FileSpec::CORE:subst, avg 0s/call
167 \.\.
168 (?:\\\.\.)* # and more
169 (?:\\|\z) # at end or followed by slash
170 }{}x;
171
172660s10s return $1 # \\HOST\SHARE\ --> \\HOST\SHARE
# spent 0s making 1 call to Portable::FileSpec::CORE:match
173 if $path eq ""
174 and $volume =~ m#\A(\\\\.*)\\\z#s;
175 }
176660s return $path ne "" || $volume ? $volume.$path : ".";
177}
178
179
18010s1;
 
# spent 0s within Portable::FileSpec::CORE:match which was called 158 times, avg 0s/call: # 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 164, avg 0s/call # 59 times (0s+0s) by Portable::FileSpec::catdir at line 96, avg 0s/call # 17 times (0s+0s) by Portable::FileSpec::catpath at line 75, avg 0s/call # 6 times (0s+0s) by Portable::FileSpec::catpath at line 66, avg 0s/call # 4 times (0s+0s) by Portable::FileSpec::catpath at line 79, avg 0s/call # 3 times (0s+0s) by Portable::FileSpec::catfile at line 109, avg 0s/call # once (0s+0s) by Portable::FileSpec::splitpath at line 26 # once (0s+0s) by Portable::FileSpec::splitdir at line 46 # once (0s+0s) by Portable::FileSpec::_canon_cat at line 172
sub Portable::FileSpec::CORE:match; # opcode
# spent 0s within Portable::FileSpec::CORE:regcomp which was called 63 times, avg 0s/call: # 59 times (0s+0s) by Portable::FileSpec::catdir at line 96, avg 0s/call # 3 times (0s+0s) by Portable::FileSpec::catfile at line 109, avg 0s/call # once (0s+0s) by Portable::FileSpec::splitpath at line 26
sub Portable::FileSpec::CORE:regcomp; # opcode
# spent 0s within Portable::FileSpec::CORE:subst which was called 470 times, avg 0s/call: # 74 times (0s+0s) by Portable::FileSpec::_canon_cat at line 118, avg 0s/call # 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 151, avg 0s/call # 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 161, avg 0s/call # 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 166, avg 0s/call # 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 146, avg 0s/call # 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 162, avg 0s/call # 66 times (0s+0s) by Portable::FileSpec::_canon_cat at line 132, avg 0s/call
sub Portable::FileSpec::CORE:subst; # opcode