Filename | /usr/lib/perl/5.14/IO/File.pm |
Statements | Executed 25 statements in 1.59ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 944µs | 1.08ms | BEGIN@9 | IO::File::
1 | 1 | 1 | 620µs | 7.68ms | BEGIN@11 | IO::File::
1 | 1 | 1 | 349µs | 595µs | BEGIN@10 | IO::File::
68 | 1 | 1 | 94µs | 94µs | CORE:match (opcode) | IO::File::
1 | 1 | 1 | 35µs | 35µs | BEGIN@5 | IO::File::
1 | 1 | 1 | 19µs | 123µs | BEGIN@8 | IO::File::
1 | 1 | 1 | 16µs | 23µs | BEGIN@6 | IO::File::
1 | 1 | 1 | 13µs | 13µs | BEGIN@12 | IO::File::
0 | 0 | 0 | 0s | 0s | binmode | IO::File::
0 | 0 | 0 | 0s | 0s | new | IO::File::
0 | 0 | 0 | 0s | 0s | open | IO::File::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # | ||||
2 | |||||
3 | package IO::File; | ||||
4 | |||||
5 | 2 | 74µs | 1 | 35µs | # spent 35µs within IO::File::BEGIN@5 which was called:
# once (35µs+0s) by Foswiki::Request::BEGIN@37 at line 5 # spent 35µs making 1 call to IO::File::BEGIN@5 |
6 | 2 | 66µs | 2 | 30µs | # spent 23µs (16+7) within IO::File::BEGIN@6 which was called:
# once (16µs+7µs) by Foswiki::Request::BEGIN@37 at line 6 # spent 23µs making 1 call to IO::File::BEGIN@6
# spent 7µs making 1 call to strict::import |
7 | 1 | 2µs | our($VERSION, @EXPORT, @EXPORT_OK, @ISA); | ||
8 | 2 | 52µs | 2 | 228µs | # spent 123µs (19+105) within IO::File::BEGIN@8 which was called:
# once (19µs+105µs) by Foswiki::Request::BEGIN@37 at line 8 # spent 123µs making 1 call to IO::File::BEGIN@8
# spent 105µs making 1 call to Exporter::import |
9 | 2 | 180µs | 2 | 1.19ms | # spent 1.08ms (944µs+136µs) within IO::File::BEGIN@9 which was called:
# once (944µs+136µs) by Foswiki::Request::BEGIN@37 at line 9 # spent 1.08ms making 1 call to IO::File::BEGIN@9
# spent 110µs making 1 call to Exporter::import |
10 | 2 | 184µs | 1 | 595µs | # spent 595µs (349+246) within IO::File::BEGIN@10 which was called:
# once (349µs+246µs) by Foswiki::Request::BEGIN@37 at line 10 # spent 595µs making 1 call to IO::File::BEGIN@10 |
11 | 2 | 151µs | 2 | 7.77ms | # spent 7.68ms (620µs+7.06) within IO::File::BEGIN@11 which was called:
# once (620µs+7.06ms) by Foswiki::Request::BEGIN@37 at line 11 # spent 7.68ms making 1 call to IO::File::BEGIN@11
# spent 88µs making 1 call to Exporter::import |
12 | 2 | 540µs | 1 | 13µs | # spent 13µs within IO::File::BEGIN@12 which was called:
# once (13µs+0s) by Foswiki::Request::BEGIN@37 at line 12 # spent 13µs making 1 call to IO::File::BEGIN@12 |
13 | |||||
14 | 1 | 2µs | require Exporter; | ||
15 | |||||
16 | 1 | 15µs | @ISA = qw(IO::Handle IO::Seekable Exporter); | ||
17 | |||||
18 | 1 | 2µs | $VERSION = "1.15"; | ||
19 | |||||
20 | 1 | 2µs | @EXPORT = @IO::Seekable::EXPORT; | ||
21 | |||||
22 | 1 | 3µs | eval { | ||
23 | # Make all Fcntl O_XXX constants available for importing | ||||
24 | 1 | 1µs | require Fcntl; | ||
25 | 1 | 273µs | 68 | 94µs | my @O = grep /^O_/, @Fcntl::EXPORT; # spent 94µs making 68 calls to IO::File::CORE:match, avg 1µs/call |
26 | 1 | 7µs | 1 | 498µs | Fcntl->import(@O); # first we import what we want to export # spent 498µs making 1 call to Exporter::import |
27 | 1 | 18µs | push(@EXPORT, @O); | ||
28 | }; | ||||
29 | |||||
30 | ################################################ | ||||
31 | ## Constructor | ||||
32 | ## | ||||
33 | |||||
34 | sub new { | ||||
35 | my $type = shift; | ||||
36 | my $class = ref($type) || $type || "IO::File"; | ||||
37 | @_ >= 0 && @_ <= 3 | ||||
38 | or croak "usage: $class->new([FILENAME [,MODE [,PERMS]]])"; | ||||
39 | my $fh = $class->SUPER::new(); | ||||
40 | if (@_) { | ||||
41 | $fh->open(@_) | ||||
42 | or return undef; | ||||
43 | } | ||||
44 | $fh; | ||||
45 | } | ||||
46 | |||||
47 | ################################################ | ||||
48 | ## Open | ||||
49 | ## | ||||
50 | |||||
51 | sub open { | ||||
52 | @_ >= 2 && @_ <= 4 or croak 'usage: $fh->open(FILENAME [,MODE [,PERMS]])'; | ||||
53 | my ($fh, $file) = @_; | ||||
54 | if (@_ > 2) { | ||||
55 | my ($mode, $perms) = @_[2, 3]; | ||||
56 | if ($mode =~ /^\d+$/) { | ||||
57 | defined $perms or $perms = 0666; | ||||
58 | return sysopen($fh, $file, $mode, $perms); | ||||
59 | } elsif ($mode =~ /:/) { | ||||
60 | return open($fh, $mode, $file) if @_ == 3; | ||||
61 | croak 'usage: $fh->open(FILENAME, IOLAYERS)'; | ||||
62 | } else { | ||||
63 | return open($fh, IO::Handle::_open_mode_string($mode), $file); | ||||
64 | } | ||||
65 | } | ||||
66 | open($fh, $file); | ||||
67 | } | ||||
68 | |||||
69 | ################################################ | ||||
70 | ## Binmode | ||||
71 | ## | ||||
72 | |||||
73 | sub binmode { | ||||
74 | ( @_ == 1 or @_ == 2 ) or croak 'usage $fh->binmode([LAYER])'; | ||||
75 | |||||
76 | my($fh, $layer) = @_; | ||||
77 | |||||
78 | return binmode $$fh unless $layer; | ||||
79 | return binmode $$fh, $layer; | ||||
80 | } | ||||
81 | |||||
82 | 1 | 14µs | 1; | ||
# spent 94µs within IO::File::CORE:match which was called 68 times, avg 1µs/call:
# 68 times (94µs+0s) by Foswiki::Request::BEGIN@37 at line 25, avg 1µs/call |