← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/usr/share/perl/5.18/File/stat.pm
StatementsExecuted 65 statements in 1.78ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.13ms6.68msFile::stat::::BEGIN@184File::stat::BEGIN@184
111343µs780µsFile::stat::::BEGIN@30File::stat::BEGIN@30
11165µs86µsFile::stat::::BEGIN@32File::stat::BEGIN@32
11112µs12µsFile::stat::::BEGIN@2File::stat::BEGIN@2
11110µs42µsFile::stat::::BEGIN@158File::stat::BEGIN@158
1119µs9µsFile::stat::::BEGIN@16File::stat::BEGIN@16
1117µs44µsFile::stat::::BEGIN@154File::stat::BEGIN@154
1117µs98µsFile::stat::::BEGIN@6File::stat::BEGIN@6
1117µs44µsFile::stat::::BEGIN@7File::stat::BEGIN@7
1117µs17µsFile::stat::::BEGIN@211File::stat::BEGIN@211
1116µs14µsFile::stat::::BEGIN@35File::stat::BEGIN@35
1116µs134µsFile::stat::::BEGIN@28File::stat::BEGIN@28
1116µs6µsFile::stat::::importFile::stat::import
1115µs13µsFile::stat::::BEGIN@4File::stat::BEGIN@4
1115µs9µsFile::stat::::BEGIN@5File::stat::BEGIN@5
1113µs3µsFile::stat::::BEGIN@17File::stat::BEGIN@17
1113µs3µsFile::stat::::BEGIN@9File::stat::BEGIN@9
0000s0sFile::stat::::__ANON__[:116]File::stat::__ANON__[:116]
0000s0sFile::stat::::__ANON__[:123]File::stat::__ANON__[:123]
0000s0sFile::stat::::__ANON__[:124]File::stat::__ANON__[:124]
0000s0sFile::stat::::__ANON__[:125]File::stat::__ANON__[:125]
0000s0sFile::stat::::__ANON__[:126]File::stat::__ANON__[:126]
0000s0sFile::stat::::__ANON__[:128]File::stat::__ANON__[:128]
0000s0sFile::stat::::__ANON__[:129]File::stat::__ANON__[:129]
0000s0sFile::stat::::__ANON__[:130]File::stat::__ANON__[:130]
0000s0sFile::stat::::__ANON__[:131]File::stat::__ANON__[:131]
0000s0sFile::stat::::__ANON__[:133]File::stat::__ANON__[:133]
0000s0sFile::stat::::__ANON__[:134]File::stat::__ANON__[:134]
0000s0sFile::stat::::__ANON__[:135]File::stat::__ANON__[:135]
0000s0sFile::stat::::__ANON__[:137]File::stat::__ANON__[:137]
0000s0sFile::stat::::__ANON__[:138]File::stat::__ANON__[:138]
0000s0sFile::stat::::__ANON__[:139]File::stat::__ANON__[:139]
0000s0sFile::stat::::__ANON__[:140]File::stat::__ANON__[:140]
0000s0sFile::stat::::__ANON__[:141]File::stat::__ANON__[:141]
0000s0sFile::stat::::__ANON__[:142]File::stat::__ANON__[:142]
0000s0sFile::stat::::__ANON__[:143]File::stat::__ANON__[:143]
0000s0sFile::stat::::__ANON__[:145]File::stat::__ANON__[:145]
0000s0sFile::stat::::__ANON__[:146]File::stat::__ANON__[:146]
0000s0sFile::stat::::__ANON__[:147]File::stat::__ANON__[:147]
0000s0sFile::stat::::__ANON__[:149]File::stat::__ANON__[:149]
0000s0sFile::stat::::__ANON__[:150]File::stat::__ANON__[:150]
0000s0sFile::stat::::__ANON__[:151]File::stat::__ANON__[:151]
0000s0sFile::stat::::__ANON__[:179]File::stat::__ANON__[:179]
0000s0sFile::stat::::__ANON__[:38]File::stat::__ANON__[:38]
0000s0sFile::stat::::__ANON__[:42]File::stat::__ANON__[:42]
0000s0sFile::stat::::__ANON__[:47]File::stat::__ANON__[:47]
0000s0sFile::stat::::__ANON__[:82]File::stat::__ANON__[:82]
0000s0sFile::stat::::_ingroupFile::stat::_ingroup
0000s0sFile::stat::::lstatFile::stat::lstat
0000s0sFile::stat::::populateFile::stat::populate
0000s0sFile::stat::::statFile::stat::stat
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package File::stat;
2235µs112µs
# spent 12µs within File::stat::BEGIN@2 which was called: # once (12µs+0s) by Path::Class::Entity::BEGIN@9 at line 2
use 5.006;
# spent 12µs making 1 call to File::stat::BEGIN@2
3
4216µs221µs
# spent 13µs (5+8) within File::stat::BEGIN@4 which was called: # once (5µs+8µs) by Path::Class::Entity::BEGIN@9 at line 4
use strict;
# spent 13µs making 1 call to File::stat::BEGIN@4 # spent 8µs making 1 call to strict::import
5219µs212µs
# spent 9µs (5+3) within File::stat::BEGIN@5 which was called: # once (5µs+3µs) by Path::Class::Entity::BEGIN@9 at line 5
use warnings;
# spent 9µs making 1 call to File::stat::BEGIN@5 # spent 4µs making 1 call to warnings::import
6231µs2189µs
# spent 98µs (7+91) within File::stat::BEGIN@6 which was called: # once (7µs+91µs) by Path::Class::Entity::BEGIN@9 at line 6
use warnings::register;
# spent 98µs making 1 call to File::stat::BEGIN@6 # spent 91µs making 1 call to warnings::register::import
7228µs280µs
# spent 44µs (7+37) within File::stat::BEGIN@7 which was called: # once (7µs+37µs) by Path::Class::Entity::BEGIN@9 at line 7
use Carp;
# spent 44µs making 1 call to File::stat::BEGIN@7 # spent 37µs making 1 call to Exporter::import
8
9148µs13µs
# spent 3µs within File::stat::BEGIN@9 which was called: # once (3µs+0s) by Path::Class::Entity::BEGIN@9 at line 9
BEGIN { *warnif = \&warnings::warnif }
# spent 3µs making 1 call to File::stat::BEGIN@9
10
111300nsour(@EXPORT, @EXPORT_OK, %EXPORT_TAGS);
12
131400nsour $VERSION = '1.07';
14
151100nsmy @fields;
16
# spent 9µs within File::stat::BEGIN@16 which was called: # once (9µs+0s) by Path::Class::Entity::BEGIN@9 at line 27
BEGIN {
17257µs13µs
# spent 3µs within File::stat::BEGIN@17 which was called: # once (3µs+0s) by Path::Class::Entity::BEGIN@9 at line 17
use Exporter ();
# spent 3µs making 1 call to File::stat::BEGIN@17
1811µs @EXPORT = qw(stat lstat);
1912µs @fields = qw( $st_dev $st_ino $st_mode
20 $st_nlink $st_uid $st_gid
21 $st_rdev $st_size
22 $st_atime $st_mtime $st_ctime
23 $st_blksize $st_blocks
24 );
2511µs @EXPORT_OK = ( @fields, "stat_cando" );
2615µs %EXPORT_TAGS = ( FIELDS => [ @fields, @EXPORT ] );
27118µs19µs}
# spent 9µs making 1 call to File::stat::BEGIN@16
28226µs2263µs
# spent 134µs (6+128) within File::stat::BEGIN@28 which was called: # once (6µs+128µs) by Path::Class::Entity::BEGIN@9 at line 28
use vars @fields;
# spent 134µs making 1 call to File::stat::BEGIN@28 # spent 128µs making 1 call to vars::import
29
30288µs2990µs
# spent 780µs (343+437) within File::stat::BEGIN@30 which was called: # once (343µs+437µs) by Path::Class::Entity::BEGIN@9 at line 30
use Fcntl qw(S_IRUSR S_IWUSR S_IXUSR);
# spent 780µs making 1 call to File::stat::BEGIN@30 # spent 210µs making 1 call to Exporter::import
31
32
# spent 86µs (65+21) within File::stat::BEGIN@32 which was called: # once (65µs+21µs) by Path::Class::Entity::BEGIN@9 at line 48
BEGIN {
33 # These constants will croak on use if the platform doesn't define
34 # them. It's important to avoid inflicting that on the user.
352143µs222µs
# spent 14µs (6+8) within File::stat::BEGIN@35 which was called: # once (6µs+8µs) by Path::Class::Entity::BEGIN@9 at line 35
no strict 'refs';
# spent 14µs making 1 call to File::stat::BEGIN@35 # spent 8µs making 1 call to strict::unimport
361500ns for (qw(suid sgid svtx)) {
37627µs38µs my $val = eval { &{"Fcntl::S_I\U$_"} };
# spent 3µs making 1 call to Fcntl::S_ISUID # spent 3µs making 1 call to Fcntl::S_ISGID # spent 2µs making 1 call to Fcntl::S_ISVTX
38310µs *{"_$_"} = defined $val ? sub { $_[0] & $val ? 1 : "" } : sub { "" };
39 }
401400ns for (qw(SOCK CHR BLK REG DIR LNK)) {
41633µs613µs *{"S_IS$_"} = defined eval { &{"Fcntl::S_IF$_"} }
# spent 3µs making 1 call to Fcntl::S_IFSOCK # spent 2µs making 1 call to Fcntl::S_IFLNK # spent 2µs making 1 call to Fcntl::S_IFCHR # spent 2µs making 1 call to Fcntl::S_IFDIR # spent 2µs making 1 call to Fcntl::S_IFBLK # spent 2µs making 1 call to Fcntl::S_IFREG
42612µs ? \&{"Fcntl::S_IS$_"} : sub { "" };
43 }
44 # FIFO flag and macro don't quite follow the S_IF/S_IS pattern above
45 # RT #111638
46 *{"S_ISFIFO"} = defined &Fcntl::S_IFIFO
4715µs ? \&Fcntl::S_ISFIFO : sub { "" };
481638µs186µs}
# spent 86µs making 1 call to File::stat::BEGIN@32
49
50# from doio.c
51sub _ingroup {
52 my ($gid, $eff) = @_;
53
54 # I am assuming that since VMS doesn't have getgroups(2), $) will
55 # always only contain a single entry.
56 $^O eq "VMS" and return $_[0] == $);
57
58 my ($egid, @supp) = split " ", $);
59 my ($rgid) = split " ", $(;
60
61 $gid == ($eff ? $egid : $rgid) and return 1;
62 grep $gid == $_, @supp and return 1;
63
64 return "";
65}
66
67# VMS uses the Unix version of the routine, even though this is very
68# suboptimal. VMS has a permissions structure that doesn't really fit
69# into struct stat, and unlike on Win32 the normal -X operators respect
70# that, but unfortunately by the time we get here we've already lost the
71# information we need. It looks to me as though if we were to preserve
72# the st_devnam entry of vmsish.h's fake struct stat (which actually
73# holds the filename) it might be possible to do this right, but both
74# getting that value out of the struct (perl's stat doesn't return it)
75# and interpreting it later would require this module to have an XS
76# component (at which point we might as well just call Perl_cando and
77# have done with it).
78
7913µsif (grep $^O eq $_, qw/os2 MSWin32 dos/) {
80
81 # from doio.c
82 *cando = sub { ($_[0][2] & $_[1]) ? 1 : "" };
83}
84else {
85
86 # from doio.c
87 *cando = sub {
88 my ($s, $mode, $eff) = @_;
89 my $uid = $eff ? $> : $<;
90 my ($stmode, $stuid, $stgid) = @$s[2,4,5];
91
92 # This code basically assumes that the rwx bits of the mode are
93 # the 0777 bits, but so does Perl_cando.
94
95 if ($uid == 0 && $^O ne "VMS") {
96 # If we're root on unix
97 # not testing for executable status => all file tests are true
98 return 1 if !($mode & 0111);
99 # testing for executable status =>
100 # for a file, any x bit will do
101 # for a directory, always true
102 return 1 if $stmode & 0111 || S_ISDIR($stmode);
103 return "";
104 }
105
106 if ($stuid == $uid) {
107 $stmode & $mode and return 1;
108 }
109 elsif (_ingroup($stgid, $eff)) {
110 $stmode & ($mode >> 3) and return 1;
111 }
112 else {
113 $stmode & ($mode >> 6) and return 1;
114 }
115 return "";
11613µs };
117}
118
119# alias for those who don't like objects
1201500ns*stat_cando = \&cando;
121
122my %op = (
123 r => sub { cando($_[0], S_IRUSR, 1) },
124 w => sub { cando($_[0], S_IWUSR, 1) },
125 x => sub { cando($_[0], S_IXUSR, 1) },
126 o => sub { $_[0][4] == $> },
127
128 R => sub { cando($_[0], S_IRUSR, 0) },
129 W => sub { cando($_[0], S_IWUSR, 0) },
130 X => sub { cando($_[0], S_IXUSR, 0) },
131 O => sub { $_[0][4] == $< },
132
133 e => sub { 1 },
134 z => sub { $_[0][7] == 0 },
135 s => sub { $_[0][7] },
136
137 f => sub { S_ISREG ($_[0][2]) },
138 d => sub { S_ISDIR ($_[0][2]) },
139 l => sub { S_ISLNK ($_[0][2]) },
140 p => sub { S_ISFIFO($_[0][2]) },
141 S => sub { S_ISSOCK($_[0][2]) },
142 b => sub { S_ISBLK ($_[0][2]) },
143 c => sub { S_ISCHR ($_[0][2]) },
144
145 u => sub { _suid($_[0][2]) },
146 g => sub { _sgid($_[0][2]) },
147 k => sub { _svtx($_[0][2]) },
148
149 M => sub { ($^T - $_[0][9] ) / 86400 },
150 C => sub { ($^T - $_[0][10]) / 86400 },
151 A => sub { ($^T - $_[0][8] ) / 86400 },
152132µs);
153
1542115µs281µs
# spent 44µs (7+37) within File::stat::BEGIN@154 which was called: # once (7µs+37µs) by Path::Class::Entity::BEGIN@9 at line 154
use constant HINT_FILETEST_ACCESS => 0x00400000;
# spent 44µs making 1 call to File::stat::BEGIN@154 # spent 37µs making 1 call to constant::import
155
156# we need fallback=>1 or stringifying breaks
157use overload
158
# spent 42µs (10+32) within File::stat::BEGIN@158 which was called: # once (10µs+32µs) by Path::Class::Entity::BEGIN@9 at line 179
fallback => 1,
159 -X => sub {
160 my ($s, $op) = @_;
161
162 if (index("rwxRWX", $op) >= 0) {
163 (caller 0)[8] & HINT_FILETEST_ACCESS
164 and warnif("File::stat ignores use filetest 'access'");
165
166 $^O eq "VMS" and warnif("File::stat ignores VMS ACLs");
167
168 # It would be nice to have a warning about using -l on a
169 # non-lstat, but that would require an extra member in the
170 # object.
171 }
172
173 if ($op{$op}) {
174 return $op{$op}->($_[0]);
175 }
176 else {
177 croak "-$op is not implemented on a File::stat object";
178 }
179242µs273µs };
# spent 42µs making 1 call to File::stat::BEGIN@158 # spent 32µs making 1 call to overload::import
180
181# Class::Struct forbids use of @ISA
182111µs140µs
# spent 6µs within File::stat::import which was called: # once (6µs+0s) by IO::Dir::BEGIN@18 at line 18 of IO/Dir.pm
sub import { goto &Exporter::import }
# spent 40µs making 1 call to Exporter::import
183
1842221µs212.0ms
# spent 6.68ms (1.13+5.55) within File::stat::BEGIN@184 which was called: # once (1.13ms+5.55ms) by Path::Class::Entity::BEGIN@9 at line 184
use Class::Struct qw(struct);
# spent 6.68ms making 1 call to File::stat::BEGIN@184 # spent 5.36ms making 1 call to Class::Struct::import
185struct 'File::stat' => [
186110µs1800µs map { $_ => '$' } qw{
# spent 800µs making 1 call to Class::Struct::struct
187 dev ino mode nlink uid gid rdev size
188 atime mtime ctime blksize blocks
189 }
190];
191
192sub populate (@) {
193 return unless @_;
194 my $stob = new();
195 @$stob = (
196 $st_dev, $st_ino, $st_mode, $st_nlink, $st_uid, $st_gid, $st_rdev,
197 $st_size, $st_atime, $st_mtime, $st_ctime, $st_blksize, $st_blocks )
198 = @_;
199 return $stob;
200}
201
202sub lstat ($) { populate(CORE::lstat(shift)) }
203
204sub stat ($) {
205 my $arg = shift;
206 my $st = populate(CORE::stat $arg);
207 return $st if defined $st;
208 my $fh;
209 {
210 local $!;
211288µs227µs
# spent 17µs (7+10) within File::stat::BEGIN@211 which was called: # once (7µs+10µs) by Path::Class::Entity::BEGIN@9 at line 211
no strict 'refs';
# spent 17µs making 1 call to File::stat::BEGIN@211 # spent 10µs making 1 call to strict::unimport
212 require Symbol;
213 $fh = \*{ Symbol::qualify( $arg, caller() )};
214 return unless defined fileno $fh;
215 }
216 return populate(CORE::stat $fh);
217}
218
219112µs1;
220__END__