Filename | /usr/lib/perl5/5.14/File/stat.pm |
Statements | Executed 66 statements in 7.48ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 5.77ms | 6.72ms | BEGIN@173 | File::stat::
1 | 1 | 1 | 342µs | 342µs | BEGIN@2 | File::stat::
1 | 1 | 1 | 167µs | 263µs | BEGIN@32 | File::stat::
1 | 1 | 1 | 32µs | 32µs | BEGIN@16 | File::stat::
1 | 1 | 1 | 24µs | 83µs | BEGIN@147 | File::stat::
1 | 1 | 1 | 20µs | 30µs | BEGIN@4 | File::stat::
1 | 1 | 1 | 20µs | 103µs | BEGIN@7 | File::stat::
1 | 1 | 1 | 17µs | 96µs | BEGIN@143 | File::stat::
1 | 1 | 1 | 17µs | 39µs | BEGIN@5 | File::stat::
1 | 1 | 1 | 16µs | 330µs | BEGIN@28 | File::stat::
1 | 1 | 1 | 16µs | 234µs | BEGIN@6 | File::stat::
1 | 1 | 1 | 16µs | 73µs | BEGIN@30 | File::stat::
1 | 1 | 1 | 13µs | 37µs | BEGIN@35 | File::stat::
1 | 1 | 1 | 13µs | 34µs | BEGIN@200 | File::stat::
1 | 1 | 1 | 11µs | 11µs | BEGIN@9 | File::stat::
1 | 1 | 1 | 9µs | 9µs | BEGIN@17 | File::stat::
1 | 1 | 1 | 7µs | 7µs | import | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:105] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:112] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:113] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:114] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:115] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:117] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:118] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:119] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:120] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:122] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:123] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:124] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:126] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:127] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:128] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:129] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:130] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:131] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:132] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:134] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:135] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:136] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:138] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:139] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:140] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:168] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:38] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:42] | File::stat::
0 | 0 | 0 | 0s | 0s | __ANON__[:78] | File::stat::
0 | 0 | 0 | 0s | 0s | _ingroup | File::stat::
0 | 0 | 0 | 0s | 0s | lstat | File::stat::
0 | 0 | 0 | 0s | 0s | populate | File::stat::
0 | 0 | 0 | 0s | 0s | stat | File::stat::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package File::stat; | ||||
2 | 2 | 230µs | 1 | 342µs | # spent 342µs within File::stat::BEGIN@2 which was called:
# once (342µs+0s) by installer::worker::BEGIN@32 at line 2 # spent 342µs making 1 call to File::stat::BEGIN@2 |
3 | |||||
4 | 2 | 58µs | 2 | 39µs | # spent 30µs (20+10) within File::stat::BEGIN@4 which was called:
# once (20µs+10µs) by installer::worker::BEGIN@32 at line 4 # spent 30µs making 1 call to File::stat::BEGIN@4
# spent 10µs making 1 call to strict::import |
5 | 2 | 54µs | 2 | 62µs | # spent 39µs (17+23) within File::stat::BEGIN@5 which was called:
# once (17µs+23µs) by installer::worker::BEGIN@32 at line 5 # spent 39µs making 1 call to File::stat::BEGIN@5
# spent 23µs making 1 call to warnings::import |
6 | 2 | 58µs | 2 | 451µs | # spent 234µs (16+218) within File::stat::BEGIN@6 which was called:
# once (16µs+218µs) by installer::worker::BEGIN@32 at line 6 # spent 234µs making 1 call to File::stat::BEGIN@6
# spent 218µs making 1 call to warnings::register::import |
7 | 2 | 76µs | 2 | 187µs | # spent 103µs (20+84) within File::stat::BEGIN@7 which was called:
# once (20µs+84µs) by installer::worker::BEGIN@32 at line 7 # spent 103µs making 1 call to File::stat::BEGIN@7
# spent 84µs making 1 call to Exporter::import |
8 | |||||
9 | 1 | 121µs | 1 | 11µs | # spent 11µs within File::stat::BEGIN@9 which was called:
# once (11µs+0s) by installer::worker::BEGIN@32 at line 9 # spent 11µs making 1 call to File::stat::BEGIN@9 |
10 | |||||
11 | 1 | 1µs | our(@EXPORT, @EXPORT_OK, %EXPORT_TAGS); | ||
12 | |||||
13 | 1 | 2µs | our $VERSION = '1.05'; | ||
14 | |||||
15 | 1 | 500ns | my @fields; | ||
16 | # spent 32µs within File::stat::BEGIN@16 which was called:
# once (32µs+0s) by installer::worker::BEGIN@32 at line 27 | ||||
17 | 2 | 125µs | 1 | 9µs | # spent 9µs within File::stat::BEGIN@17 which was called:
# once (9µs+0s) by installer::worker::BEGIN@32 at line 17 # spent 9µs making 1 call to File::stat::BEGIN@17 |
18 | 4 | 32µs | @EXPORT = qw(stat lstat); | ||
19 | @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 | ); | ||||
25 | @EXPORT_OK = ( @fields, "stat_cando" ); | ||||
26 | %EXPORT_TAGS = ( FIELDS => [ @fields, @EXPORT ] ); | ||||
27 | 1 | 67µs | 1 | 32µs | } # spent 32µs making 1 call to File::stat::BEGIN@16 |
28 | 2 | 66µs | 2 | 644µs | # spent 330µs (16+314) within File::stat::BEGIN@28 which was called:
# once (16µs+314µs) by installer::worker::BEGIN@32 at line 28 # spent 330µs making 1 call to File::stat::BEGIN@28
# spent 314µs making 1 call to vars::import |
29 | |||||
30 | 2 | 70µs | 2 | 130µs | # spent 73µs (16+57) within File::stat::BEGIN@30 which was called:
# once (16µs+57µs) by installer::worker::BEGIN@32 at line 30 # spent 73µs making 1 call to File::stat::BEGIN@30
# spent 57µs making 1 call to Exporter::import |
31 | |||||
32 | # spent 263µs (167+96) within File::stat::BEGIN@32 which was called:
# once (167µs+96µs) by installer::worker::BEGIN@32 at line 44 | ||||
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. | ||||
35 | 2 | 298µs | 2 | 60µs | # spent 37µs (13+23) within File::stat::BEGIN@35 which was called:
# once (13µs+23µs) by installer::worker::BEGIN@32 at line 35 # spent 37µs making 1 call to File::stat::BEGIN@35
# spent 23µs making 1 call to strict::unimport |
36 | 2 | 8µs | for (qw(suid sgid svtx)) { | ||
37 | 9 | 89µs | 3 | 31µs | my $val = eval { &{"Fcntl::S_I\U$_"} }; # spent 12µs making 1 call to Fcntl::S_ISUID
# spent 9µs making 1 call to Fcntl::S_ISGID
# spent 9µs making 1 call to Fcntl::S_ISVTX |
38 | *{"_$_"} = defined $val ? sub { $_[0] & $val ? 1 : "" } : sub { "" }; | ||||
39 | } | ||||
40 | for (qw(SOCK CHR BLK REG DIR FIFO LNK)) { | ||||
41 | 7 | 65µs | *{"S_IS$_"} = defined eval { &{"Fcntl::S_IF$_"} } # spent 23µs making 1 call to Fcntl::S_IFFIFO
# spent 8µs making 1 call to Fcntl::S_IFSOCK
# spent 7µs making 1 call to Fcntl::S_IFCHR
# spent 7µs making 1 call to Fcntl::S_IFLNK
# spent 7µs making 1 call to Fcntl::S_IFBLK
# spent 7µs making 1 call to Fcntl::S_IFREG
# spent 7µs making 1 call to Fcntl::S_IFDIR | ||
42 | 14 | 165µs | ? \&{"Fcntl::S_IS$_"} : sub { "" }; | ||
43 | } | ||||
44 | 1 | 1.65ms | 1 | 263µs | } # spent 263µs making 1 call to File::stat::BEGIN@32 |
45 | |||||
46 | # from doio.c | ||||
47 | sub _ingroup { | ||||
48 | my ($gid, $eff) = @_; | ||||
49 | |||||
50 | # I am assuming that since VMS doesn't have getgroups(2), $) will | ||||
51 | # always only contain a single entry. | ||||
52 | $^O eq "VMS" and return $_[0] == $); | ||||
53 | |||||
54 | my ($egid, @supp) = split " ", $); | ||||
55 | my ($rgid) = split " ", $(; | ||||
56 | |||||
57 | $gid == ($eff ? $egid : $rgid) and return 1; | ||||
58 | grep $gid == $_, @supp and return 1; | ||||
59 | |||||
60 | return ""; | ||||
61 | } | ||||
62 | |||||
63 | # VMS uses the Unix version of the routine, even though this is very | ||||
64 | # suboptimal. VMS has a permissions structure that doesn't really fit | ||||
65 | # into struct stat, and unlike on Win32 the normal -X operators respect | ||||
66 | # that, but unfortunately by the time we get here we've already lost the | ||||
67 | # information we need. It looks to me as though if we were to preserve | ||||
68 | # the st_devnam entry of vmsish.h's fake struct stat (which actually | ||||
69 | # holds the filename) it might be possible to do this right, but both | ||||
70 | # getting that value out of the struct (perl's stat doesn't return it) | ||||
71 | # and interpreting it later would require this module to have an XS | ||||
72 | # component (at which point we might as well just call Perl_cando and | ||||
73 | # have done with it). | ||||
74 | |||||
75 | 2 | 12µs | if (grep $^O eq $_, qw/os2 MSWin32 dos/) { | ||
76 | |||||
77 | # from doio.c | ||||
78 | *cando = sub { ($_[0][2] & $_[1]) ? 1 : "" }; | ||||
79 | } | ||||
80 | else { | ||||
81 | |||||
82 | # from doio.c | ||||
83 | *cando = sub { | ||||
84 | my ($s, $mode, $eff) = @_; | ||||
85 | my $uid = $eff ? $> : $<; | ||||
86 | |||||
87 | # If we're root on unix and we are not testing for executable | ||||
88 | # status, then all file tests are true. | ||||
89 | $^O ne "VMS" and $uid == 0 and !($mode & 0111) and return 1; | ||||
90 | |||||
91 | my ($stmode, $stuid, $stgid) = @$s[2,4,5]; | ||||
92 | |||||
93 | # This code basically assumes that the rwx bits of the mode are | ||||
94 | # the 0777 bits, but so does Perl_cando. | ||||
95 | if ($stuid == $uid) { | ||||
96 | $stmode & $mode and return 1; | ||||
97 | } | ||||
98 | elsif (_ingroup($stgid, $eff)) { | ||||
99 | $stmode & ($mode >> 3) and return 1; | ||||
100 | } | ||||
101 | else { | ||||
102 | $stmode & ($mode >> 6) and return 1; | ||||
103 | } | ||||
104 | return ""; | ||||
105 | }; | ||||
106 | } | ||||
107 | |||||
108 | # alias for those who don't like objects | ||||
109 | 1 | 2µs | *stat_cando = \&cando; | ||
110 | |||||
111 | my %op = ( | ||||
112 | r => sub { cando($_[0], S_IRUSR, 1) }, | ||||
113 | w => sub { cando($_[0], S_IWUSR, 1) }, | ||||
114 | x => sub { cando($_[0], S_IXUSR, 1) }, | ||||
115 | o => sub { $_[0][4] == $> }, | ||||
116 | |||||
117 | R => sub { cando($_[0], S_IRUSR, 0) }, | ||||
118 | W => sub { cando($_[0], S_IWUSR, 0) }, | ||||
119 | X => sub { cando($_[0], S_IXUSR, 0) }, | ||||
120 | O => sub { $_[0][4] == $< }, | ||||
121 | |||||
122 | e => sub { 1 }, | ||||
123 | z => sub { $_[0][7] == 0 }, | ||||
124 | s => sub { $_[0][7] }, | ||||
125 | |||||
126 | f => sub { S_ISREG ($_[0][2]) }, | ||||
127 | d => sub { S_ISDIR ($_[0][2]) }, | ||||
128 | l => sub { S_ISLNK ($_[0][2]) }, | ||||
129 | p => sub { S_ISFIFO($_[0][2]) }, | ||||
130 | S => sub { S_ISSOCK($_[0][2]) }, | ||||
131 | b => sub { S_ISBLK ($_[0][2]) }, | ||||
132 | c => sub { S_ISCHR ($_[0][2]) }, | ||||
133 | |||||
134 | u => sub { _suid($_[0][2]) }, | ||||
135 | g => sub { _sgid($_[0][2]) }, | ||||
136 | k => sub { _svtx($_[0][2]) }, | ||||
137 | |||||
138 | M => sub { ($^T - $_[0][9] ) / 86400 }, | ||||
139 | C => sub { ($^T - $_[0][10]) / 86400 }, | ||||
140 | A => sub { ($^T - $_[0][8] ) / 86400 }, | ||||
141 | 1 | 108µs | ); | ||
142 | |||||
143 | 2 | 258µs | 2 | 174µs | # spent 96µs (17+78) within File::stat::BEGIN@143 which was called:
# once (17µs+78µs) by installer::worker::BEGIN@32 at line 143 # spent 96µs making 1 call to File::stat::BEGIN@143
# spent 78µs making 1 call to constant::import |
144 | |||||
145 | # we need fallback=>1 or stringifying breaks | ||||
146 | use overload | ||||
147 | # spent 83µs (24+59) within File::stat::BEGIN@147 which was called:
# once (24µs+59µs) by installer::worker::BEGIN@32 at line 168 | ||||
148 | -X => sub { | ||||
149 | my ($s, $op) = @_; | ||||
150 | |||||
151 | if (index "rwxRWX", $op) { | ||||
152 | (caller 0)[8] & HINT_FILETEST_ACCESS | ||||
153 | and warnif("File::stat ignores use filetest 'access'"); | ||||
154 | |||||
155 | $^O eq "VMS" and warnif("File::stat ignores VMS ACLs"); | ||||
156 | |||||
157 | # It would be nice to have a warning about using -l on a | ||||
158 | # non-lstat, but that would require an extra member in the | ||||
159 | # object. | ||||
160 | } | ||||
161 | |||||
162 | if ($op{$op}) { | ||||
163 | return $op{$op}->($_[0]); | ||||
164 | } | ||||
165 | else { | ||||
166 | croak "-$op is not implemented on a File::stat object"; | ||||
167 | } | ||||
168 | 2 | 98µs | 2 | 141µs | }; # spent 83µs making 1 call to File::stat::BEGIN@147
# spent 59µs making 1 call to overload::import |
169 | |||||
170 | # Class::Struct forbids use of @ISA | ||||
171 | 1 | 12µs | 1 | 56µs | # spent 7µs within File::stat::import which was called:
# once (7µs+0s) by installer::worker::BEGIN@32 at line 32 of /cygdrive/c/lo/libo-master/instsetoo_native/util/C:/lo/libo-master/solenv/bin/modules/installer/worker.pm # spent 56µs making 1 call to Exporter::import |
172 | |||||
173 | 2 | 3.47ms | 2 | 6.97ms | # spent 6.72ms (5.77+950µs) within File::stat::BEGIN@173 which was called:
# once (5.77ms+950µs) by installer::worker::BEGIN@32 at line 173 # spent 6.72ms making 1 call to File::stat::BEGIN@173
# spent 248µs making 1 call to Class::Struct::import |
174 | struct 'File::stat' => [ | ||||
175 | 1 | 47µs | 1 | 1.77ms | map { $_ => '$' } qw{ # spent 1.77ms making 1 call to Class::Struct::struct |
176 | dev ino mode nlink uid gid rdev size | ||||
177 | atime mtime ctime blksize blocks | ||||
178 | } | ||||
179 | ]; | ||||
180 | |||||
181 | sub populate (@) { | ||||
182 | return unless @_; | ||||
183 | my $stob = new(); | ||||
184 | @$stob = ( | ||||
185 | $st_dev, $st_ino, $st_mode, $st_nlink, $st_uid, $st_gid, $st_rdev, | ||||
186 | $st_size, $st_atime, $st_mtime, $st_ctime, $st_blksize, $st_blocks ) | ||||
187 | = @_; | ||||
188 | return $stob; | ||||
189 | } | ||||
190 | |||||
191 | sub lstat ($) { populate(CORE::lstat(shift)) } | ||||
192 | |||||
193 | sub stat ($) { | ||||
194 | my $arg = shift; | ||||
195 | my $st = populate(CORE::stat $arg); | ||||
196 | return $st if defined $st; | ||||
197 | my $fh; | ||||
198 | { | ||||
199 | local $!; | ||||
200 | 2 | 209µs | 2 | 54µs | # spent 34µs (13+21) within File::stat::BEGIN@200 which was called:
# once (13µs+21µs) by installer::worker::BEGIN@32 at line 200 # spent 34µs making 1 call to File::stat::BEGIN@200
# spent 21µs making 1 call to strict::unimport |
201 | require Symbol; | ||||
202 | $fh = \*{ Symbol::qualify( $arg, caller() )}; | ||||
203 | return unless defined fileno $fh; | ||||
204 | } | ||||
205 | return populate(CORE::stat $fh); | ||||
206 | } | ||||
207 | |||||
208 | 1 | 92µs | 1; | ||
209 | __END__ |