| Filename | /usr/lib/perl/5.10/IO/File.pm |
| Statements | Executed 32 statements in 1.57ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 937µs | 1.05ms | IO::File::BEGIN@9 |
| 1 | 1 | 1 | 550µs | 5.20ms | IO::File::BEGIN@11 |
| 1 | 1 | 1 | 421µs | 669µs | IO::File::BEGIN@10 |
| 68 | 1 | 1 | 86µs | 86µs | IO::File::CORE:match (opcode) |
| 1 | 1 | 1 | 32µs | 32µs | IO::File::BEGIN@5 |
| 1 | 1 | 1 | 16µs | 16µs | IO::File::BEGIN@12 |
| 1 | 1 | 1 | 15µs | 20µs | IO::File::BEGIN@6 |
| 1 | 1 | 1 | 15µs | 91µs | IO::File::BEGIN@8 |
| 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 | 52µs | 1 | 32µs | # spent 32µs within IO::File::BEGIN@5 which was called:
# once (32µs+0s) by Storable::BEGIN@23 at line 5 # spent 32µs making 1 call to IO::File::BEGIN@5 |
| 6 | 3 | 63µs | 2 | 25µs | # spent 20µs (15+5) within IO::File::BEGIN@6 which was called:
# once (15µs+5µs) by Storable::BEGIN@23 at line 6 # spent 20µs making 1 call to IO::File::BEGIN@6
# spent 5µs making 1 call to strict::import |
| 7 | 1 | 1µs | our($VERSION, @EXPORT, @EXPORT_OK, @ISA); | ||
| 8 | 3 | 39µs | 2 | 167µs | # spent 91µs (15+76) within IO::File::BEGIN@8 which was called:
# once (15µs+76µs) by Storable::BEGIN@23 at line 8 # spent 91µs making 1 call to IO::File::BEGIN@8
# spent 76µs making 1 call to Exporter::import |
| 9 | 3 | 204µs | 2 | 1.14ms | # spent 1.05ms (937µs+117µs) within IO::File::BEGIN@9 which was called:
# once (937µs+117µs) by Storable::BEGIN@23 at line 9 # spent 1.05ms making 1 call to IO::File::BEGIN@9
# spent 87µs making 1 call to Exporter::import |
| 10 | 3 | 207µs | 1 | 669µs | # spent 669µs (421+248) within IO::File::BEGIN@10 which was called:
# once (421µs+248µs) by Storable::BEGIN@23 at line 10 # spent 669µs making 1 call to IO::File::BEGIN@10 |
| 11 | 3 | 208µs | 2 | 5.28ms | # spent 5.20ms (550µs+4.65) within IO::File::BEGIN@11 which was called:
# once (550µs+4.65ms) by Storable::BEGIN@23 at line 11 # spent 5.20ms making 1 call to IO::File::BEGIN@11
# spent 71µs making 1 call to Exporter::import |
| 12 | 3 | 471µs | 1 | 16µs | # spent 16µs within IO::File::BEGIN@12 which was called:
# once (16µs+0s) by Storable::BEGIN@23 at line 12 # spent 16µs making 1 call to IO::File::BEGIN@12 |
| 13 | |||||
| 14 | 1 | 1µs | require Exporter; | ||
| 15 | |||||
| 16 | 1 | 31µs | @ISA = qw(IO::Handle IO::Seekable Exporter); | ||
| 17 | |||||
| 18 | 1 | 1µs | $VERSION = "1.14"; | ||
| 19 | |||||
| 20 | 1 | 3µs | @EXPORT = @IO::Seekable::EXPORT; | ||
| 21 | |||||
| 22 | 1 | 2µs | eval { | ||
| 23 | # Make all Fcntl O_XXX constants available for importing | ||||
| 24 | 1 | 1µs | require Fcntl; | ||
| 25 | 1 | 256µs | 68 | 86µs | my @O = grep /^O_/, @Fcntl::EXPORT; # spent 86µs making 68 calls to IO::File::CORE:match, avg 1µs/call |
| 26 | 1 | 5µs | 1 | 347µs | Fcntl->import(@O); # first we import what we want to export # spent 347µ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 86µs within IO::File::CORE:match which was called 68 times, avg 1µs/call:
# 68 times (86µs+0s) by Storable::BEGIN@23 at line 25, avg 1µs/call |