← 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/lib/perl/5.18/IO/Dir.pm
StatementsExecuted 26 statements in 1.10ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111564µs680µsIO::Dir::::BEGIN@17IO::Dir::BEGIN@17
111521µs3.85msIO::Dir::::BEGIN@15IO::Dir::BEGIN@15
111504µs547µsIO::Dir::::BEGIN@13IO::Dir::BEGIN@13
11115µs61µsIO::Dir::::BEGIN@18IO::Dir::BEGIN@18
11115µs15µsIO::Dir::::BEGIN@9IO::Dir::BEGIN@9
1119µs9µsIO::Dir::::BEGIN@19IO::Dir::BEGIN@19
1119µs20µsIO::Dir::::BEGIN@42IO::Dir::BEGIN@42
1117µs18µsIO::Dir::::BEGIN@14IO::Dir::BEGIN@14
1116µs39µsIO::Dir::::BEGIN@12IO::Dir::BEGIN@12
1116µs16µsIO::Dir::::BEGIN@11IO::Dir::BEGIN@11
0000s0sIO::Dir::::DELETEIO::Dir::DELETE
0000s0sIO::Dir::::DESTROYIO::Dir::DESTROY
0000s0sIO::Dir::::EXISTSIO::Dir::EXISTS
0000s0sIO::Dir::::FETCHIO::Dir::FETCH
0000s0sIO::Dir::::FIRSTKEYIO::Dir::FIRSTKEY
0000s0sIO::Dir::::NEXTKEYIO::Dir::NEXTKEY
0000s0sIO::Dir::::STOREIO::Dir::STORE
0000s0sIO::Dir::::TIEHASHIO::Dir::TIEHASH
0000s0sIO::Dir::::closeIO::Dir::close
0000s0sIO::Dir::::newIO::Dir::new
0000s0sIO::Dir::::openIO::Dir::open
0000s0sIO::Dir::::readIO::Dir::read
0000s0sIO::Dir::::rewindIO::Dir::rewind
0000s0sIO::Dir::::seekIO::Dir::seek
0000s0sIO::Dir::::tellIO::Dir::tell
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# IO::Dir.pm
2#
3# Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
4# This program is free software; you can redistribute it and/or
5# modify it under the same terms as Perl itself.
6
7package IO::Dir;
8
9241µs115µs
# spent 15µs within IO::Dir::BEGIN@9 which was called: # once (15µs+0s) by Path::Class::Dir::BEGIN@12 at line 9
use 5.006;
# spent 15µs making 1 call to IO::Dir::BEGIN@9
10
11221µs227µs
# spent 16µs (6+10) within IO::Dir::BEGIN@11 which was called: # once (6µs+10µs) by Path::Class::Dir::BEGIN@12 at line 11
use strict;
# spent 16µs making 1 call to IO::Dir::BEGIN@11 # spent 10µs making 1 call to strict::import
12219µs272µs
# spent 39µs (6+33) within IO::Dir::BEGIN@12 which was called: # once (6µs+33µs) by Path::Class::Dir::BEGIN@12 at line 12
use Carp;
# spent 39µs making 1 call to IO::Dir::BEGIN@12 # spent 33µs making 1 call to Exporter::import
13281µs2579µs
# spent 547µs (504+43) within IO::Dir::BEGIN@13 which was called: # once (504µs+43µs) by Path::Class::Dir::BEGIN@12 at line 13
use Symbol;
# spent 547µs making 1 call to IO::Dir::BEGIN@13 # spent 33µs making 1 call to Exporter::import
14218µs230µs
# spent 18µs (7+11) within IO::Dir::BEGIN@14 which was called: # once (7µs+11µs) by Path::Class::Dir::BEGIN@12 at line 14
use Exporter;
# spent 18µs making 1 call to IO::Dir::BEGIN@14 # spent 11µs making 1 call to Exporter::import
15290µs23.93ms
# spent 3.85ms (521µs+3.33) within IO::Dir::BEGIN@15 which was called: # once (521µs+3.33ms) by Path::Class::Dir::BEGIN@12 at line 15
use IO::File;
# spent 3.85ms making 1 call to IO::Dir::BEGIN@15 # spent 83µs making 1 call to Exporter::import
161300nsour(@ISA, $VERSION, @EXPORT_OK);
172116µs1680µs
# spent 680µs (564+116) within IO::Dir::BEGIN@17 which was called: # once (564µs+116µs) by Path::Class::Dir::BEGIN@12 at line 17
use Tie::Hash;
# spent 680µs making 1 call to IO::Dir::BEGIN@17
18236µs267µs
# spent 61µs (15+46) within IO::Dir::BEGIN@18 which was called: # once (15µs+46µs) by Path::Class::Dir::BEGIN@12 at line 18
use File::stat;
# spent 61µs making 1 call to IO::Dir::BEGIN@18 # spent 6µs making 1 call to File::stat::import
192177µs19µs
# spent 9µs within IO::Dir::BEGIN@19 which was called: # once (9µs+0s) by Path::Class::Dir::BEGIN@12 at line 19
use File::Spec;
# spent 9µs making 1 call to IO::Dir::BEGIN@19
20
2116µs@ISA = qw(Tie::Hash Exporter);
221200ns$VERSION = "1.10";
23110µs$VERSION = eval $VERSION;
# spent 2µs executing statements in string eval
241500ns@EXPORT_OK = qw(DIR_UNLINK);
25
26sub DIR_UNLINK () { 1 }
27
28sub new {
29 @_ >= 1 && @_ <= 2 or croak 'usage: IO::Dir->new([DIRNAME])';
30 my $class = shift;
31 my $dh = gensym;
32 if (@_) {
33 IO::Dir::open($dh, $_[0])
34 or return undef;
35 }
36 bless $dh, $class;
37}
38
39sub DESTROY {
40 my ($dh) = @_;
41 local($., $@, $!, $^E, $?);
422482µs231µs
# spent 20µs (9+11) within IO::Dir::BEGIN@42 which was called: # once (9µs+11µs) by Path::Class::Dir::BEGIN@12 at line 42
no warnings 'io';
# spent 20µs making 1 call to IO::Dir::BEGIN@42 # spent 11µs making 1 call to warnings::unimport
43 closedir($dh);
44}
45
46sub open {
47 @_ == 2 or croak 'usage: $dh->open(DIRNAME)';
48 my ($dh, $dirname) = @_;
49 return undef
50 unless opendir($dh, $dirname);
51 # a dir name should always have a ":" in it; assume dirname is
52 # in current directory
53 $dirname = ':' . $dirname if ( ($^O eq 'MacOS') && ($dirname !~ /:/) );
54 ${*$dh}{io_dir_path} = $dirname;
55 1;
56}
57
58sub close {
59 @_ == 1 or croak 'usage: $dh->close()';
60 my ($dh) = @_;
61 closedir($dh);
62}
63
64sub read {
65 @_ == 1 or croak 'usage: $dh->read()';
66 my ($dh) = @_;
67 readdir($dh);
68}
69
70sub seek {
71 @_ == 2 or croak 'usage: $dh->seek(POS)';
72 my ($dh,$pos) = @_;
73 seekdir($dh,$pos);
74}
75
76sub tell {
77 @_ == 1 or croak 'usage: $dh->tell()';
78 my ($dh) = @_;
79 telldir($dh);
80}
81
82sub rewind {
83 @_ == 1 or croak 'usage: $dh->rewind()';
84 my ($dh) = @_;
85 rewinddir($dh);
86}
87
88sub TIEHASH {
89 my($class,$dir,$options) = @_;
90
91 my $dh = $class->new($dir)
92 or return undef;
93
94 $options ||= 0;
95
96 ${*$dh}{io_dir_unlink} = $options & DIR_UNLINK;
97 $dh;
98}
99
100sub FIRSTKEY {
101 my($dh) = @_;
102 $dh->rewind;
103 scalar $dh->read;
104}
105
106sub NEXTKEY {
107 my($dh) = @_;
108 scalar $dh->read;
109}
110
111sub EXISTS {
112 my($dh,$key) = @_;
113 -e File::Spec->catfile(${*$dh}{io_dir_path}, $key);
114}
115
116sub FETCH {
117 my($dh,$key) = @_;
118 &lstat(File::Spec->catfile(${*$dh}{io_dir_path}, $key));
119}
120
121sub STORE {
122 my($dh,$key,$data) = @_;
123 my($atime,$mtime) = ref($data) ? @$data : ($data,$data);
124 my $file = File::Spec->catfile(${*$dh}{io_dir_path}, $key);
125 unless(-e $file) {
126 my $io = IO::File->new($file,O_CREAT | O_RDWR);
127 $io->close if $io;
128 }
129 utime($atime,$mtime, $file);
130}
131
132sub DELETE {
133 my($dh,$key) = @_;
134
135 # Only unlink if unlink-ing is enabled
136 return 0
137 unless ${*$dh}{io_dir_unlink};
138
139 my $file = File::Spec->catfile(${*$dh}{io_dir_path}, $key);
140
141 -d $file
142 ? rmdir($file)
143 : unlink($file);
144}
145
14613µs1;
147
148__END__