← Index
NYTProf Performance Profile   « line view »
For /Users/brian/bin/perls/cpan5.26.1
  Run on Sat Dec 30 01:41:10 2017
Reported on Sat Dec 30 01:44:14 2017

Filename/usr/local/perls/perl-5.26.1/lib/5.26.1/DirHandle.pm
StatementsExecuted 70 statements in 7.79ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4116.96ms6.96msDirHandle::::CORE:readdirDirHandle::CORE:readdir (opcode)
511283µs283µsDirHandle::::CORE:open_dirDirHandle::CORE:open_dir (opcode)
552199µs242µsDirHandle::::DESTROYDirHandle::DESTROY
552118µs619µsDirHandle::::newDirHandle::new
44262µs7.02msDirHandle::::readDirHandle::read
51161µs344µsDirHandle::::openDirHandle::open
62154µs54µsDirHandle::::CORE:closedirDirHandle::CORE:closedir (opcode)
11117µs28µsDirHandle::::closeDirHandle::close
0000s0sDirHandle::::BEGINDirHandle::BEGIN
0000s0sDirHandle::::rewindDirHandle::rewind
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DirHandle;
2
3our $VERSION = '1.04';
4
5=head1 NAME
6
7DirHandle - supply object methods for directory handles
8
9=head1 SYNOPSIS
10
11 use DirHandle;
12 $d = DirHandle->new(".");
13 if (defined $d) {
14 while (defined($_ = $d->read)) { something($_); }
15 $d->rewind;
16 while (defined($_ = $d->read)) { something_else($_); }
17 undef $d;
18 }
19
20=head1 DESCRIPTION
21
22The C<DirHandle> method provide an alternative interface to the
23opendir(), closedir(), readdir(), and rewinddir() functions.
24
25The only objective benefit to using C<DirHandle> is that it avoids
26namespace pollution by creating globs to hold directory handles.
27
28=cut
29
30require 5.000;
31use Carp;
32use Symbol;
33
34
# spent 619µs (118+501) within DirHandle::new which was called 5 times, avg 124µs/call: # once (27µs+194µs) by CPAN::Distribution::run_preps_on_packagedir at line 513 of CPAN/Distribution.pm # once (29µs+145µs) by CPAN::CacheMgr::entries at line 68 of CPAN/CacheMgr.pm # once (28µs+78µs) by CPAN::Distribution::_find_prefs at line 2398 of CPAN/Distribution.pm # once (18µs+47µs) by CPAN::Distribution::run_preps_on_packagedir at line 533 of CPAN/Distribution.pm # once (16µs+37µs) by CPAN::CacheMgr::new at line 207 of CPAN/CacheMgr.pm
sub new {
35517µs @_ >= 1 && @_ <= 2 or croak 'usage: DirHandle->new( [DIRNAME] )';
36511µs my $class = shift;
37514µs5157µs my $dh = gensym;
# spent 157µs making 5 calls to Symbol::gensym, avg 31µs/call
38523µs5344µs if (@_) {
# spent 344µs making 5 calls to DirHandle::open, avg 69µs/call
39 DirHandle::open($dh, $_[0])
40 or return undef;
41 }
42544µs bless $dh, $class;
43}
44
45
# spent 242µs (199+43) within DirHandle::DESTROY which was called 5 times, avg 48µs/call: # once (59µs+6µs) by CPAN::Distribution::run_preps_on_packagedir at line 546 of CPAN/Distribution.pm # once (40µs+15µs) by CPAN::CacheMgr::new at line 214 of CPAN/CacheMgr.pm # once (34µs+14µs) by CPAN::Distribution::_find_prefs at line 2400 of CPAN/Distribution.pm # once (41µs+7µs) by CPAN::CacheMgr::entries at line 82 of CPAN/CacheMgr.pm # once (25µs+1000ns) by CPAN::Distribution::run_preps_on_packagedir at line 596 of CPAN/Distribution.pm
sub DESTROY {
4653µs my ($dh) = @_;
47 # Don't warn about already being closed as it may have been closed
48 # correctly, or maybe never opened at all.
495134µs local($., $@, $!, $^E, $?);
50 no warnings 'io';
515124µs543µs closedir($dh);
# spent 43µs making 5 calls to DirHandle::CORE:closedir, avg 9µs/call
52}
53
54
# spent 344µs (61+283) within DirHandle::open which was called 5 times, avg 69µs/call: # 5 times (61µs+283µs) by DirHandle::new at line 38, avg 69µs/call
sub open {
5553µs @_ == 2 or croak 'usage: $dh->open(DIRNAME)';
5655µs my ($dh, $dirname) = @_;
575336µs5283µs opendir($dh, $dirname);
# spent 283µs making 5 calls to DirHandle::CORE:open_dir, avg 57µs/call
58}
59
60
# spent 28µs (17+11) within DirHandle::close which was called: # once (17µs+11µs) by CPAN::Distribution::run_preps_on_packagedir at line 525 of CPAN/Distribution.pm
sub close {
6111µs @_ == 1 or croak 'usage: $dh->close()';
6210s my ($dh) = @_;
63138µs111µs closedir($dh);
# spent 11µs making 1 call to DirHandle::CORE:closedir
64}
65
66
# spent 7.02ms (62µs+6.95) within DirHandle::read which was called 4 times, avg 1.75ms/call: # once (35µs+6.83ms) by CPAN::CacheMgr::entries at line 71 of CPAN/CacheMgr.pm # once (7µs+73µs) by CPAN::Distribution::run_preps_on_packagedir at line 546 of CPAN/Distribution.pm # once (9µs+28µs) by CPAN::Distribution::run_preps_on_packagedir at line 515 of CPAN/Distribution.pm # once (11µs+25µs) by CPAN::Distribution::_find_prefs at line 2399 of CPAN/Distribution.pm
sub read {
6742µs @_ == 1 or croak 'usage: $dh->read()';
6841µs my ($dh) = @_;
6947.04ms46.96ms readdir($dh);
# spent 6.96ms making 4 calls to DirHandle::CORE:readdir, avg 1.74ms/call
70}
71
72sub rewind {
73 @_ == 1 or croak 'usage: $dh->rewind()';
74 my ($dh) = @_;
75 rewinddir($dh);
76}
77
781;
 
# spent 54µs within DirHandle::CORE:closedir which was called 6 times, avg 9µs/call: # 5 times (43µs+0s) by DirHandle::DESTROY at line 51, avg 9µs/call # once (11µs+0s) by DirHandle::close at line 63
sub DirHandle::CORE:closedir; # opcode
# spent 283µs within DirHandle::CORE:open_dir which was called 5 times, avg 57µs/call: # 5 times (283µs+0s) by DirHandle::open at line 57, avg 57µs/call
sub DirHandle::CORE:open_dir; # opcode
# spent 6.96ms within DirHandle::CORE:readdir which was called 4 times, avg 1.74ms/call: # 4 times (6.96ms+0s) by DirHandle::read at line 69, avg 1.74ms/call
sub DirHandle::CORE:readdir; # opcode