← Index
NYTProf Performance Profile   « line view »
For rbm/rbm
  Run on Wed Feb 12 03:38:15 2020
Reported on Wed Feb 12 04:56:35 2020

Filename/usr/share/perl/5.28/File/Basename.pm
StatementsExecuted 103666 statements in 315ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
412731104ms313msFile::Basename::::basenameFile::Basename::basename
414421100ms120msFile::Basename::::fileparseFile::Basename::fileparse
41442146.8ms89.6msFile::Basename::::_strip_trailing_sepFile::Basename::_strip_trailing_sep
41441142.8ms42.8msFile::Basename::::CORE:substFile::Basename::CORE:subst (opcode)
41542120.0ms20.0msFile::Basename::::CORE:matchFile::Basename::CORE:match (opcode)
1112.73ms2.75msFile::Basename::::BEGIN@14File::Basename::BEGIN@14
1752358µs1.33msFile::Basename::::dirnameFile::Basename::dirname
11133µs63µsFile::Basename::::fileparse_set_fstypeFile::Basename::fileparse_set_fstype
101127µs27µsFile::Basename::::CORE:regcompFile::Basename::CORE:regcomp (opcode)
11116µs16µsFile::Basename::::BEGIN@13File::Basename::BEGIN@13
1116µs6µsFile::Basename::::BEGIN@184File::Basename::BEGIN@184
1116µs6µsFile::Basename::::BEGIN@5File::Basename::BEGIN@5
1115µs7µsFile::Basename::::BEGIN@12File::Basename::BEGIN@12
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package File::Basename;
2
3# File::Basename is used during the Perl build, when the re extension may
4# not be available, but we only actually need it if running under tainting.
5
# spent 6µs within File::Basename::BEGIN@5 which was called: # once (6µs+0s) by main::BEGIN@4 at line 10
BEGIN {
614µs if (${^TAINT}) {
7 require re;
8 re->import('taint');
9 }
10120µs16µs}
# spent 6µs making 1 call to File::Basename::BEGIN@5
11
12220µs28µs
# spent 7µs (5+2) within File::Basename::BEGIN@12 which was called: # once (5µs+2µs) by main::BEGIN@4 at line 12
use strict;
# spent 7µs making 1 call to File::Basename::BEGIN@12 # spent 2µs making 1 call to strict::import
13242µs116µs
# spent 16µs within File::Basename::BEGIN@13 which was called: # once (16µs+0s) by main::BEGIN@4 at line 13
use 5.006;
# spent 16µs making 1 call to File::Basename::BEGIN@13
1423.69ms22.76ms
# spent 2.75ms (2.73+20µs) within File::Basename::BEGIN@14 which was called: # once (2.73ms+20µs) by main::BEGIN@4 at line 14
use warnings;
# spent 2.75ms making 1 call to File::Basename::BEGIN@14 # spent 17µs making 1 call to warnings::import
15our(@ISA, @EXPORT, $VERSION, $Fileparse_fstype, $Fileparse_igncase);
161633µsrequire Exporter;
1716µs@ISA = qw(Exporter);
181600ns@EXPORT = qw(fileparse fileparse_set_fstype basename dirname);
191200ns$VERSION = "2.85";
20
2111µs163µsfileparse_set_fstype($^O);
# spent 63µs making 1 call to File::Basename::fileparse_set_fstype
22
23
# spent 120ms (100+20.0) within File::Basename::fileparse which was called 4144 times, avg 29µs/call: # 4127 times (99.8ms+19.8ms) by File::Basename::basename at line 106, avg 29µs/call # 17 times (524µs+165µs) by File::Basename::dirname at line 134, avg 41µs/call
sub fileparse {
2441445.01ms my($fullname,@suffices) = @_;
25
2641442.17ms unless (defined $fullname) {
27 require Carp;
28 Carp::croak("fileparse(): need a valid pathname");
29 }
30
3141443.61ms my $orig_type = '';
3241445.62ms my($type,$igncase) = ($Fileparse_fstype, $Fileparse_igncase);
33
3441447.90ms my($taint) = substr($fullname,0,0); # Is $fullname tainted?
35
3641444.02ms if ($type eq "VMS" and $fullname =~ m{/} ) {
37 # We're doing Unix emulation
38 $orig_type = $type;
39 $type = 'Unix';
40 }
41
4241441.29ms my($dirpath, $basename);
43
44414418.2ms if (grep { $type eq $_ } qw(MSDOS DOS MSWin32 Epoc)) {
45 ($dirpath,$basename) = ($fullname =~ /^((?:.*[:\\\/])?)(.*)/s);
46 $dirpath .= '.\\' unless $dirpath =~ /[\\\/]\z/;
47 }
48 elsif ($type eq "OS2") {
49 ($dirpath,$basename) = ($fullname =~ m#^((?:.*[:\\/])?)(.*)#s);
50 $dirpath = './' unless $dirpath; # Can't be 0
51 $dirpath .= '/' unless $dirpath =~ m#[\\/]\z#;
52 }
53 elsif ($type eq "MacOS") {
54 ($dirpath,$basename) = ($fullname =~ /^(.*:)?(.*)/s);
55 $dirpath = ':' unless $dirpath;
56 }
57 elsif ($type eq "AmigaOS") {
58 ($dirpath,$basename) = ($fullname =~ /(.*[:\/])?(.*)/s);
59 $dirpath = './' unless $dirpath;
60 }
61 elsif ($type eq 'VMS' ) {
62 ($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/s);
63 $dirpath ||= ''; # should always be defined
64 }
65 else { # Default to Unix semantics.
66414438.6ms414420.0ms ($dirpath,$basename) = ($fullname =~ m{^(.*/)?(.*)}s);
# spent 20.0ms making 4144 calls to File::Basename::CORE:match, avg 5µs/call
6741441.99ms if ($orig_type eq 'VMS' and $fullname =~ m{^(/[^/]+/000000(/|$))(.*)}) {
68 # dev:[000000] is top of VMS tree, similar to Unix '/'
69 # so strip it off and treat the rest as "normal"
70 my $devspec = $1;
71 my $remainder = $3;
72 ($dirpath,$basename) = ($remainder =~ m{^(.*/)?(.*)}s);
73 $dirpath ||= ''; # should always be defined
74 $dirpath = $devspec.$dirpath;
75 }
7641441.38ms $dirpath = './' unless $dirpath;
77 }
78
79
8041443.33ms my $tail = '';
8141442.11ms my $suffix = '';
8241441.48ms if (@suffices) {
83 foreach $suffix (@suffices) {
84 my $pat = ($igncase ? '(?i)' : '') . "($suffix)\$";
85 if ($basename =~ s/$pat//s) {
86 $taint .= substr($suffix,0,0);
87 $tail = $1 . $tail;
88 }
89 }
90 }
91
92 # Ensure taint is propagated from the path to its pieces.
9341442.44ms $tail .= $taint;
94414438.7ms wantarray ? ($basename .= $taint, $dirpath .= $taint, $tail)
95 : ($basename .= $taint);
96}
97
98
# spent 313ms (104+209) within File::Basename::basename which was called 4127 times, avg 76µs/call: # 1992 times (53.2ms+106ms) by RBM::input_files at line 859 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 80µs/call # 1992 times (50.2ms+100ms) by RBM::__ANON__[rbm/lib/RBM.pm:845] at line 840 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 76µs/call # 143 times (811µs+2.94ms) by RBM::load_config at line 55 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 26µs/call
sub basename {
9941275.27ms my($path) = shift;
100
101 # From BSD basename(1)
102 # The basename utility deletes any prefix ending with the last slash '/'
103 # character present in string (after first stripping trailing slashes)
104412713.2ms412789.3ms _strip_trailing_sep($path);
# spent 89.3ms making 4127 calls to File::Basename::_strip_trailing_sep, avg 22µs/call
105
106412721.8ms4127120ms my($basename, $dirname, $suffix) = fileparse( $path, map("\Q$_\E",@_) );
# spent 120ms making 4127 calls to File::Basename::fileparse, avg 29µs/call
107
108 # From BSD basename(1)
109 # The suffix is not stripped if it is identical to the remaining
110 # characters in string.
11141273.02ms if( length $suffix and !length $basename ) {
112 $basename = $suffix;
113 }
114
115 # Ensure that basename '/' == '/'
11641272.69ms if( !length $basename ) {
117 $basename = $dirname;
118 }
119
120412718.9ms return $basename;
121}
122
123
# spent 1.33ms (358µs+975µs) within File::Basename::dirname which was called 17 times, avg 78µs/call: # 8 times (186µs+523µs) by RBM::build_run at line 1075 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 89µs/call # 6 times (131µs+317µs) by RBM::input_files at line 960 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 75µs/call # once (16µs+62µs) by RBM::build_run at line 1066 of /root/tor-browser-build/rbm/lib/RBM.pm # once (14µs+43µs) by RBM::load_config at line 49 of /root/tor-browser-build/rbm/lib/RBM.pm # once (11µs+29µs) by main::BEGIN@5 at line 5 of /root/tor-browser-build/rbm/rbm
sub dirname {
1241746µs my $path = shift;
125
1261719µs my($type) = $Fileparse_fstype;
127
1281710µs if( $type eq 'VMS' and $path =~ m{/} ) {
129 # Parse as Unix
130 local($File::Basename::Fileparse_fstype) = '';
131 return dirname($path);
132 }
133
13417127µs17689µs my($basename, $dirname) = fileparse($path);
# spent 689µs making 17 calls to File::Basename::fileparse, avg 41µs/call
135
1361742µs if ($type eq 'VMS') {
137 $dirname ||= $ENV{DEFAULT};
138 }
139 elsif ($type eq 'MacOS') {
140 if( !length($basename) && $dirname !~ /^[^:]+:\z/) {
141 _strip_trailing_sep($dirname);
142 ($basename,$dirname) = fileparse $dirname;
143 }
144 $dirname .= ":" unless $dirname =~ /:\z/;
145 }
146 elsif (grep { $type eq $_ } qw(MSDOS DOS MSWin32 OS2)) {
147 _strip_trailing_sep($dirname);
148 unless( length($basename) ) {
149 ($basename,$dirname) = fileparse $dirname;
150 _strip_trailing_sep($dirname);
151 }
152 }
153 elsif ($type eq 'AmigaOS') {
154 if ( $dirname =~ /:\z/) { return $dirname }
155 chop $dirname;
156 $dirname =~ s{[^:/]+\z}{} unless length($basename);
157 }
158 else {
1591748µs17286µs _strip_trailing_sep($dirname);
# spent 286µs making 17 calls to File::Basename::_strip_trailing_sep, avg 17µs/call
160178µs unless( length($basename) ) {
161 ($basename,$dirname) = fileparse $dirname;
162 _strip_trailing_sep($dirname);
163 }
164 }
165
1661766µs $dirname;
167}
168
169# Strip the trailing path separator.
170
# spent 89.6ms (46.8+42.8) within File::Basename::_strip_trailing_sep which was called 4144 times, avg 22µs/call: # 4127 times (46.7ms+42.6ms) by File::Basename::basename at line 104, avg 22µs/call # 17 times (146µs+140µs) by File::Basename::dirname at line 159, avg 17µs/call
sub _strip_trailing_sep {
17141445.34ms my $type = $Fileparse_fstype;
172
173414443.7ms if ($type eq 'MacOS') {
174 $_[0] =~ s/([^:]):\z/$1/s;
175 }
176 elsif (grep { $type eq $_ } qw(MSDOS DOS MSWin32 OS2)) {
177 $_[0] =~ s/([^:])[\\\/]*\z/$1/;
178 }
179 else {
180414458.5ms414442.8ms $_[0] =~ s{(.)/*\z}{$1}s;
# spent 42.8ms making 4144 calls to File::Basename::CORE:subst, avg 10µs/call
181 }
182}
183
184
# spent 6µs within File::Basename::BEGIN@184 which was called: # once (6µs+0s) by main::BEGIN@4 at line 207
BEGIN {
185
18611µsmy @Ignore_Case = qw(MacOS VMS AmigaOS OS2 RISCOS MSWin32 MSDOS DOS Epoc);
18716µsmy @Types = (@Ignore_Case, qw(Unix));
188
189
# spent 63µs (33+30) within File::Basename::fileparse_set_fstype which was called: # once (33µs+30µs) by main::BEGIN@4 at line 21
sub fileparse_set_fstype {
1901300ns my $old = $Fileparse_fstype;
191
1921400ns if (@_) {
19311µs my $new_type = shift;
194
1951200ns $Fileparse_fstype = 'Unix'; # default
1961500ns foreach my $type (@Types) {
1971058µs2030µs $Fileparse_fstype = $type if $new_type =~ /^$type/i;
# spent 27µs making 10 calls to File::Basename::CORE:regcomp, avg 3µs/call # spent 3µs making 10 calls to File::Basename::CORE:match, avg 330ns/call
198 }
199
200 $Fileparse_igncase =
20112µs (grep $Fileparse_fstype eq $_, @Ignore_Case) ? 1 : 0;
202 }
203
20412µs return $old;
205}
206
207127µs16µs}
# spent 6µs making 1 call to File::Basename::BEGIN@184
208
20915µs1;
210
 
# spent 20.0ms within File::Basename::CORE:match which was called 4154 times, avg 5µs/call: # 4144 times (20.0ms+0s) by File::Basename::fileparse at line 66, avg 5µs/call # 10 times (3µs+0s) by File::Basename::fileparse_set_fstype at line 197, avg 330ns/call
sub File::Basename::CORE:match; # opcode
# spent 27µs within File::Basename::CORE:regcomp which was called 10 times, avg 3µs/call: # 10 times (27µs+0s) by File::Basename::fileparse_set_fstype at line 197, avg 3µs/call
sub File::Basename::CORE:regcomp; # opcode
# spent 42.8ms within File::Basename::CORE:subst which was called 4144 times, avg 10µs/call: # 4144 times (42.8ms+0s) by File::Basename::_strip_trailing_sep at line 180, avg 10µs/call
sub File::Basename::CORE:subst; # opcode