← Index
NYTProf Performance Profile   « line view »
For flows_to_es.pl
  Run on Mon May 9 23:27:59 2016
Reported on Mon May 9 23:28:08 2016

Filename/usr/lib/perl/5.18/File/Spec/Unix.pm
StatementsExecuted 69 statements in 1.83ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
42157µs69µsFile::Spec::Unix::::canonpathFile::Spec::Unix::canonpath
33116µs63µsFile::Spec::Unix::::catdirFile::Spec::Unix::catdir
11114µs28µsFile::Spec::Unix::::BEGIN@3File::Spec::Unix::BEGIN@3
11112µs42µsFile::Spec::Unix::::rel2absFile::Spec::Unix::rel2abs
246112µs12µsFile::Spec::Unix::::CORE:substFile::Spec::Unix::CORE:subst (opcode)
11111µs26µsFile::Spec::Unix::::BEGIN@65File::Spec::Unix::BEGIN@65
1117µs27µsFile::Spec::Unix::::BEGIN@4File::Spec::Unix::BEGIN@4
1116µs8µsFile::Spec::Unix::::file_name_is_absoluteFile::Spec::Unix::file_name_is_absolute
1112µs2µsFile::Spec::Unix::::CORE:matchFile::Spec::Unix::CORE:match (opcode)
0000s0sFile::Spec::Unix::::_collapseFile::Spec::Unix::_collapse
0000s0sFile::Spec::Unix::::_cwdFile::Spec::Unix::_cwd
0000s0sFile::Spec::Unix::::_sameFile::Spec::Unix::_same
0000s0sFile::Spec::Unix::::_tmpdirFile::Spec::Unix::_tmpdir
0000s0sFile::Spec::Unix::::abs2relFile::Spec::Unix::abs2rel
0000s0sFile::Spec::Unix::::case_tolerantFile::Spec::Unix::case_tolerant
0000s0sFile::Spec::Unix::::catfileFile::Spec::Unix::catfile
0000s0sFile::Spec::Unix::::catpathFile::Spec::Unix::catpath
0000s0sFile::Spec::Unix::::curdirFile::Spec::Unix::curdir
0000s0sFile::Spec::Unix::::devnullFile::Spec::Unix::devnull
0000s0sFile::Spec::Unix::::joinFile::Spec::Unix::join
0000s0sFile::Spec::Unix::::no_upwardsFile::Spec::Unix::no_upwards
0000s0sFile::Spec::Unix::::pathFile::Spec::Unix::path
0000s0sFile::Spec::Unix::::rootdirFile::Spec::Unix::rootdir
0000s0sFile::Spec::Unix::::splitdirFile::Spec::Unix::splitdir
0000s0sFile::Spec::Unix::::splitpathFile::Spec::Unix::splitpath
0000s0sFile::Spec::Unix::::tmpdirFile::Spec::Unix::tmpdir
0000s0sFile::Spec::Unix::::updirFile::Spec::Unix::updir
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package File::Spec::Unix;
2
3232µs242µs
# spent 28µs (14+14) within File::Spec::Unix::BEGIN@3 which was called: # once (14µs+14µs) by local::lib::BEGIN@9 at line 3
use strict;
# spent 28µs making 1 call to File::Spec::Unix::BEGIN@3 # spent 14µs making 1 call to strict::import
42420µs248µs
# spent 27µs (7+21) within File::Spec::Unix::BEGIN@4 which was called: # once (7µs+21µs) by local::lib::BEGIN@9 at line 4
use vars qw($VERSION);
# spent 27µs making 1 call to File::Spec::Unix::BEGIN@4 # spent 21µs making 1 call to vars::import
5
61800ns$VERSION = '3.40';
71600ns$VERSION =~ tr/_//;
8
9
# spent 69µs (57+12) within File::Spec::Unix::canonpath which was called 4 times, avg 17µs/call: # 3 times (37µs+10µs) by File::Spec::Unix::catdir at line 41, avg 16µs/call # once (20µs+2µs) by File::Spec::Unix::rel2abs at line 252
sub canonpath {
1042µs my ($self,$path) = @_;
1141µs return unless defined $path;
12
13 # Handle POSIX-style node names beginning with double slash (qnx, nto)
14 # (POSIX says: "a pathname that begins with two successive slashes
15 # may be interpreted in an implementation-defined manner, although
16 # more than two leading slashes shall be treated as a single slash.")
174800ns my $node = '';
1844µs my $double_slashes_special = $^O eq 'qnx' || $^O eq 'nto';
19
204600ns if ( $double_slashes_special
21 && ( $path =~ s{^(//[^/]+)/?\z}{}s || $path =~ s{^(//[^/]+)/}{/}s ) ) {
22 $node = $1;
23 }
24 # This used to be
25 # $path =~ s|/+|/|g unless ($^O eq 'cygwin');
26 # but that made tests 29, 30, 35, 46, and 213 (as of #13272) to fail
27 # (Mainly because trailing "" directories didn't get stripped).
28 # Why would cygwin avoid collapsing multiple slashes into one? --jhi
29413µs43µs $path =~ s|/{2,}|/|g; # xx////xx -> xx/xx
# spent 3µs making 4 calls to File::Spec::Unix::CORE:subst, avg 675ns/call
3047µs41µs $path =~ s{(?:/\.)+(?:/|\z)}{/}g; # xx/././xx -> xx/xx
# spent 1µs making 4 calls to File::Spec::Unix::CORE:subst, avg 275ns/call
3148µs41µs $path =~ s|^(?:\./)+||s unless $path eq "./"; # ./xx -> xx
# spent 1µs making 4 calls to File::Spec::Unix::CORE:subst, avg 250ns/call
3247µs41µs $path =~ s|^/(?:\.\./)+|/|; # /../../xx -> xx
# spent 1µs making 4 calls to File::Spec::Unix::CORE:subst, avg 250ns/call
3347µs4900ns $path =~ s|^/\.\.$|/|; # /.. -> /
# spent 900ns making 4 calls to File::Spec::Unix::CORE:subst, avg 225ns/call
34412µs45µs $path =~ s|/\z|| unless $path eq "/"; # xx/ -> xx
# spent 5µs making 4 calls to File::Spec::Unix::CORE:subst, avg 1µs/call
35416µs return "$node$path";
36}
37
38
# spent 63µs (16+47) within File::Spec::Unix::catdir which was called 3 times, avg 21µs/call: # once (7µs+16µs) by local::lib::setup_local_lib_for at line 240 of local/lib.pm # once (6µs+17µs) by local::lib::install_base_perl_path at line 258 of local/lib.pm # once (3µs+14µs) by local::lib::install_base_bin_path at line 253 of local/lib.pm
sub catdir {
3931µs my $self = shift;
40
41314µs347µs $self->canonpath(join('/', @_, '')); # '' because need a trailing '/'
# spent 47µs making 3 calls to File::Spec::Unix::canonpath, avg 16µs/call
42}
43
44sub catfile {
45 my $self = shift;
46 my $file = $self->canonpath(pop @_);
47 return $file unless @_;
48 my $dir = $self->catdir(@_);
49 $dir .= "/" unless substr($dir,-1) eq "/";
50 return $dir.$file;
51}
52
53sub curdir { '.' }
54
55sub devnull { '/dev/null' }
56
57sub rootdir { '/' }
58
591200nsmy $tmpdir;
60sub _tmpdir {
61 return $tmpdir if defined $tmpdir;
62 my $self = shift;
63 my @dirlist = @_;
64 {
6521.26ms240µs
# spent 26µs (11+14) within File::Spec::Unix::BEGIN@65 which was called: # once (11µs+14µs) by local::lib::BEGIN@9 at line 65
no strict 'refs';
# spent 26µs making 1 call to File::Spec::Unix::BEGIN@65 # spent 14µs making 1 call to strict::unimport
66 if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0
67 require Scalar::Util;
68 @dirlist = grep { ! Scalar::Util::tainted($_) } @dirlist;
69 }
70 elsif ($] < 5.007) { # No ${^TAINT} before 5.8
71 @dirlist = grep { eval { eval('1'.substr $_,0,0) } } @dirlist;
72 }
73 }
74 foreach (@dirlist) {
75 next unless defined && -d && -w _;
76 $tmpdir = $_;
77 last;
78 }
79 $tmpdir = $self->curdir unless defined $tmpdir;
80 $tmpdir = defined $tmpdir && $self->canonpath($tmpdir);
81 return $tmpdir;
82}
83
84sub tmpdir {
85 return $tmpdir if defined $tmpdir;
86 $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp" );
87}
88
89sub updir { '..' }
90
91sub no_upwards {
92 my $self = shift;
93 return grep(!/^\.{1,2}\z/s, @_);
94}
95
96sub case_tolerant { 0 }
97
98
# spent 8µs (6+2) within File::Spec::Unix::file_name_is_absolute which was called: # once (6µs+2µs) by File::Spec::Unix::rel2abs at line 236
sub file_name_is_absolute {
991500ns my ($self,$file) = @_;
10019µs12µs return scalar($file =~ m:^/:s);
# spent 2µs making 1 call to File::Spec::Unix::CORE:match
101}
102
103sub path {
104 return () unless exists $ENV{PATH};
105 my @path = split(':', $ENV{PATH});
106 foreach (@path) { $_ = '.' if $_ eq '' }
107 return @path;
108}
109
110sub join {
111 my $self = shift;
112 return $self->catfile(@_);
113}
114
115sub splitpath {
116 my ($self,$path, $nofile) = @_;
117
118 my ($volume,$directory,$file) = ('','','');
119
120 if ( $nofile ) {
121 $directory = $path;
122 }
123 else {
124 $path =~ m|^ ( (?: .* / (?: \.\.?\z )? )? ) ([^/]*) |xs;
125 $directory = $1;
126 $file = $2;
127 }
128
129 return ($volume,$directory,$file);
130}
131
132sub splitdir {
133 return split m|/|, $_[1], -1; # Preserve trailing fields
134}
135
136sub catpath {
137 my ($self,$volume,$directory,$file) = @_;
138
139 if ( $directory ne '' &&
140 $file ne '' &&
141 substr( $directory, -1 ) ne '/' &&
142 substr( $file, 0, 1 ) ne '/'
143 ) {
144 $directory .= "/$file" ;
145 }
146 else {
147 $directory .= $file ;
148 }
149
150 return $directory ;
151}
152
153sub abs2rel {
154 my($self,$path,$base) = @_;
155 $base = $self->_cwd() unless defined $base and length $base;
156
157 ($path, $base) = map $self->canonpath($_), $path, $base;
158
159 my $path_directories;
160 my $base_directories;
161
162 if (grep $self->file_name_is_absolute($_), $path, $base) {
163 ($path, $base) = map $self->rel2abs($_), $path, $base;
164
165 my ($path_volume) = $self->splitpath($path, 1);
166 my ($base_volume) = $self->splitpath($base, 1);
167
168 # Can't relativize across volumes
169 return $path unless $path_volume eq $base_volume;
170
171 $path_directories = ($self->splitpath($path, 1))[1];
172 $base_directories = ($self->splitpath($base, 1))[1];
173
174 # For UNC paths, the user might give a volume like //foo/bar that
175 # strictly speaking has no directory portion. Treat it as if it
176 # had the root directory for that volume.
177 if (!length($base_directories) and $self->file_name_is_absolute($base)) {
178 $base_directories = $self->rootdir;
179 }
180 }
181 else {
182 my $wd= ($self->splitpath($self->_cwd(), 1))[1];
183 $path_directories = $self->catdir($wd, $path);
184 $base_directories = $self->catdir($wd, $base);
185 }
186
187 # Now, remove all leading components that are the same
188 my @pathchunks = $self->splitdir( $path_directories );
189 my @basechunks = $self->splitdir( $base_directories );
190
191 if ($base_directories eq $self->rootdir) {
192 return $self->curdir if $path_directories eq $self->rootdir;
193 shift @pathchunks;
194 return $self->canonpath( $self->catpath('', $self->catdir( @pathchunks ), '') );
195 }
196
197 my @common;
198 while (@pathchunks && @basechunks && $self->_same($pathchunks[0], $basechunks[0])) {
199 push @common, shift @pathchunks ;
200 shift @basechunks ;
201 }
202 return $self->curdir unless @pathchunks || @basechunks;
203
204 # @basechunks now contains the directories the resulting relative path
205 # must ascend out of before it can descend to $path_directory. If there
206 # are updir components, we must descend into the corresponding directories
207 # (this only works if they are no symlinks).
208 my @reverse_base;
209 while( defined(my $dir= shift @basechunks) ) {
210 if( $dir ne $self->updir ) {
211 unshift @reverse_base, $self->updir;
212 push @common, $dir;
213 }
214 elsif( @common ) {
215 if( @reverse_base && $reverse_base[0] eq $self->updir ) {
216 shift @reverse_base;
217 pop @common;
218 }
219 else {
220 unshift @reverse_base, pop @common;
221 }
222 }
223 }
224 my $result_dirs = $self->catdir( @reverse_base, @pathchunks );
225 return $self->canonpath( $self->catpath('', $result_dirs, '') );
226}
227
228sub _same {
229 $_[1] eq $_[2];
230}
231
232
# spent 42µs (12+30) within File::Spec::Unix::rel2abs which was called: # once (12µs+30µs) by local::lib::resolve_relative_path at line 192 of local/lib.pm
sub rel2abs {
2331700ns my ($self,$path,$base ) = @_;
234
235 # Clean up $path
23613µs18µs if ( ! $self->file_name_is_absolute( $path ) ) {
# spent 8µs making 1 call to File::Spec::Unix::file_name_is_absolute
237 # Figure out the effective $base and clean it up.
238 if ( !defined( $base ) || $base eq '' ) {
239 $base = $self->_cwd();
240 }
241 elsif ( ! $self->file_name_is_absolute( $base ) ) {
242 $base = $self->rel2abs( $base ) ;
243 }
244 else {
245 $base = $self->canonpath( $base ) ;
246 }
247
248 # Glom them together
249 $path = $self->catdir( $base, $path ) ;
250 }
251
25216µs122µs return $self->canonpath( $path ) ;
# spent 22µs making 1 call to File::Spec::Unix::canonpath
253}
254
255# Internal routine to File::Spec, no point in making this public since
256# it is the standard Cwd interface. Most of the platform-specific
257# File::Spec subclasses use this.
258sub _cwd {
259 require Cwd;
260 Cwd::getcwd();
261}
262
263# Internal method to reduce xx\..\yy -> yy
264sub _collapse {
265 my($fs, $path) = @_;
266
267 my $updir = $fs->updir;
268 my $curdir = $fs->curdir;
269
270 my($vol, $dirs, $file) = $fs->splitpath($path);
271 my @dirs = $fs->splitdir($dirs);
272 pop @dirs if @dirs && $dirs[-1] eq '';
273
274 my @collapsed;
275 foreach my $dir (@dirs) {
276 if( $dir eq $updir and # if we have an updir
277 @collapsed and # and something to collapse
278 length $collapsed[-1] and # and its not the rootdir
279 $collapsed[-1] ne $updir and # nor another updir
280 $collapsed[-1] ne $curdir # nor the curdir
281 )
282 { # then
283 pop @collapsed; # collapse
284 }
285 else { # else
286 push @collapsed, $dir; # just hang onto it
287 }
288 }
289
290 return $fs->catpath($vol,
291 $fs->catdir(@collapsed),
292 $file
293 );
294}
295
29613µs1;
 
# spent 2µs within File::Spec::Unix::CORE:match which was called: # once (2µs+0s) by File::Spec::Unix::file_name_is_absolute at line 100
sub File::Spec::Unix::CORE:match; # opcode
# spent 12µs within File::Spec::Unix::CORE:subst which was called 24 times, avg 488ns/call: # 4 times (5µs+0s) by File::Spec::Unix::canonpath at line 34, avg 1µs/call # 4 times (3µs+0s) by File::Spec::Unix::canonpath at line 29, avg 675ns/call # 4 times (1µs+0s) by File::Spec::Unix::canonpath at line 30, avg 275ns/call # 4 times (1µs+0s) by File::Spec::Unix::canonpath at line 32, avg 250ns/call # 4 times (1µs+0s) by File::Spec::Unix::canonpath at line 31, avg 250ns/call # 4 times (900ns+0s) by File::Spec::Unix::canonpath at line 33, avg 225ns/call
sub File::Spec::Unix::CORE:subst; # opcode