| Filename | /usr/lib/perl/5.10/IO/File.pm |
| Statements | Executed 32 statements in 1.41ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1.02ms | 5.69ms | IO::File::BEGIN@11 |
| 1 | 1 | 1 | 356µs | 547µs | IO::File::BEGIN@10 |
| 68 | 1 | 1 | 92µs | 92µs | IO::File::CORE:match (opcode) |
| 1 | 1 | 1 | 33µs | 33µs | IO::File::BEGIN@5 |
| 1 | 1 | 1 | 18µs | 103µs | IO::File::BEGIN@9 |
| 1 | 1 | 1 | 16µs | 99µs | IO::File::BEGIN@8 |
| 1 | 1 | 1 | 14µs | 14µs | IO::File::BEGIN@12 |
| 1 | 1 | 1 | 14µs | 20µs | IO::File::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | IO::File::binmode |
| 0 | 0 | 0 | 0s | 0s | IO::File::new |
| 0 | 0 | 0 | 0s | 0s | IO::File::open |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # | ||||
| 2 | |||||
| 3 | package IO::File; | ||||
| 4 | |||||
| 5 | 3 | 62µs | 1 | 33µs | # spent 33µs within IO::File::BEGIN@5 which was called:
# once (33µs+0s) by Storable::BEGIN@23 at line 5 # spent 33µs making 1 call to IO::File::BEGIN@5 |
| 6 | 3 | 69µs | 2 | 26µs | # spent 20µs (14+6) within IO::File::BEGIN@6 which was called:
# once (14µs+6µs) by Storable::BEGIN@23 at line 6 # spent 20µs making 1 call to IO::File::BEGIN@6
# spent 6µs making 1 call to strict::import |
| 7 | 1 | 1µs | our($VERSION, @EXPORT, @EXPORT_OK, @ISA); | ||
| 8 | 3 | 40µs | 2 | 182µs | # spent 99µs (16+83) within IO::File::BEGIN@8 which was called:
# once (16µs+83µs) by Storable::BEGIN@23 at line 8 # spent 99µs making 1 call to IO::File::BEGIN@8
# spent 83µs making 1 call to Exporter::import |
| 9 | 3 | 44µs | 2 | 188µs | # spent 103µs (18+85) within IO::File::BEGIN@9 which was called:
# once (18µs+85µs) by Storable::BEGIN@23 at line 9 # spent 103µs making 1 call to IO::File::BEGIN@9
# spent 85µs making 1 call to Exporter::import |
| 10 | 3 | 202µs | 1 | 547µs | # spent 547µs (356+191) within IO::File::BEGIN@10 which was called:
# once (356µs+191µs) by Storable::BEGIN@23 at line 10 # spent 547µs making 1 call to IO::File::BEGIN@10 |
| 11 | 3 | 167µs | 2 | 5.77ms | # spent 5.69ms (1.02+4.67) within IO::File::BEGIN@11 which was called:
# once (1.02ms+4.67ms) by Storable::BEGIN@23 at line 11 # spent 5.69ms making 1 call to IO::File::BEGIN@11
# spent 72µs making 1 call to Exporter::import |
| 12 | 3 | 494µs | 1 | 14µs | # spent 14µs within IO::File::BEGIN@12 which was called:
# once (14µs+0s) by Storable::BEGIN@23 at line 12 # spent 14µs making 1 call to IO::File::BEGIN@12 |
| 13 | |||||
| 14 | 1 | 1µs | require Exporter; | ||
| 15 | |||||
| 16 | 1 | 24µs | @ISA = qw(IO::Handle IO::Seekable Exporter); | ||
| 17 | |||||
| 18 | 1 | 2µs | $VERSION = "1.14"; | ||
| 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 | 261µs | 68 | 92µs | my @O = grep /^O_/, @Fcntl::EXPORT; # spent 92µs making 68 calls to IO::File::CORE:match, avg 1µs/call |
| 26 | 1 | 6µs | 1 | 336µs | Fcntl->import(@O); # first we import what we want to export # spent 336µs making 1 call to Exporter::import |
| 27 | 1 | 14µ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: new $class [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 | 13µs | 1; | ||
# spent 92µs within IO::File::CORE:match which was called 68 times, avg 1µs/call:
# 68 times (92µs+0s) by Storable::BEGIN@23 at line 25, avg 1µs/call |