| Filename | /home/micha/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/x86_64-linux/IO/Seekable.pm |
| Statements | Executed 89 statements in 420µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1.43ms | 1.92ms | IO::Seekable::BEGIN@100 |
| 28 | 10 | 2 | 33µs | 79µs | IO::Seekable::seek |
| 9 | 3 | 2 | 13µs | 15µs | IO::Seekable::tell |
| 1 | 1 | 1 | 11µs | 11µs | IO::Seekable::BEGIN@97 |
| 1 | 1 | 1 | 5µs | 26µs | IO::Seekable::BEGIN@103 |
| 1 | 1 | 1 | 4µs | 24µs | IO::Seekable::BEGIN@98 |
| 1 | 1 | 1 | 4µs | 5µs | IO::Seekable::BEGIN@99 |
| 0 | 0 | 0 | 0s | 0s | IO::Seekable::sysseek |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # | ||||
| 2 | |||||
| 3 | package IO::Seekable; | ||||
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| 7 | IO::Seekable - supply seek based methods for I/O objects | ||||
| 8 | |||||
| 9 | =head1 SYNOPSIS | ||||
| 10 | |||||
| 11 | use IO::Seekable; | ||||
| 12 | package IO::Something; | ||||
| 13 | @ISA = qw(IO::Seekable); | ||||
| 14 | |||||
| 15 | =head1 DESCRIPTION | ||||
| 16 | |||||
| 17 | C<IO::Seekable> does not have a constructor of its own as it is intended to | ||||
| 18 | be inherited by other C<IO::Handle> based objects. It provides methods | ||||
| 19 | which allow seeking of the file descriptors. | ||||
| 20 | |||||
| 21 | =over 4 | ||||
| 22 | |||||
| 23 | =item $io->getpos | ||||
| 24 | |||||
| 25 | Returns an opaque value that represents the current position of the | ||||
| 26 | IO::File, or C<undef> if this is not possible (eg an unseekable stream such | ||||
| 27 | as a terminal, pipe or socket). If the fgetpos() function is available in | ||||
| 28 | your C library it is used to implements getpos, else perl emulates getpos | ||||
| 29 | using C's ftell() function. | ||||
| 30 | |||||
| 31 | =item $io->setpos | ||||
| 32 | |||||
| 33 | Uses the value of a previous getpos call to return to a previously visited | ||||
| 34 | position. Returns "0 but true" on success, C<undef> on failure. | ||||
| 35 | |||||
| 36 | =back | ||||
| 37 | |||||
| 38 | See L<perlfunc> for complete descriptions of each of the following | ||||
| 39 | supported C<IO::Seekable> methods, which are just front ends for the | ||||
| 40 | corresponding built-in functions: | ||||
| 41 | |||||
| 42 | =over 4 | ||||
| 43 | |||||
| 44 | =item $io->seek ( POS, WHENCE ) | ||||
| 45 | |||||
| 46 | Seek the IO::File to position POS, relative to WHENCE: | ||||
| 47 | |||||
| 48 | =over 8 | ||||
| 49 | |||||
| 50 | =item WHENCE=0 (SEEK_SET) | ||||
| 51 | |||||
| 52 | POS is absolute position. (Seek relative to the start of the file) | ||||
| 53 | |||||
| 54 | =item WHENCE=1 (SEEK_CUR) | ||||
| 55 | |||||
| 56 | POS is an offset from the current position. (Seek relative to current) | ||||
| 57 | |||||
| 58 | =item WHENCE=2 (SEEK_END) | ||||
| 59 | |||||
| 60 | POS is an offset from the end of the file. (Seek relative to end) | ||||
| 61 | |||||
| 62 | =back | ||||
| 63 | |||||
| 64 | The SEEK_* constants can be imported from the C<Fcntl> module if you | ||||
| 65 | don't wish to use the numbers C<0> C<1> or C<2> in your code. | ||||
| 66 | |||||
| 67 | Returns C<1> upon success, C<0> otherwise. | ||||
| 68 | |||||
| 69 | =item $io->sysseek( POS, WHENCE ) | ||||
| 70 | |||||
| 71 | Similar to $io->seek, but sets the IO::File's position using the system | ||||
| 72 | call lseek(2) directly, so will confuse most perl IO operators except | ||||
| 73 | sysread and syswrite (see L<perlfunc> for full details) | ||||
| 74 | |||||
| 75 | Returns the new position, or C<undef> on failure. A position | ||||
| 76 | of zero is returned as the string C<"0 but true"> | ||||
| 77 | |||||
| 78 | =item $io->tell | ||||
| 79 | |||||
| 80 | Returns the IO::File's current position, or -1 on error. | ||||
| 81 | |||||
| 82 | =back | ||||
| 83 | |||||
| 84 | =head1 SEE ALSO | ||||
| 85 | |||||
| 86 | L<perlfunc>, | ||||
| 87 | L<perlop/"I/O Operators">, | ||||
| 88 | L<IO::Handle> | ||||
| 89 | L<IO::File> | ||||
| 90 | |||||
| 91 | =head1 HISTORY | ||||
| 92 | |||||
| 93 | Derived from FileHandle.pm by Graham Barr E<lt>gbarr@pobox.comE<gt> | ||||
| 94 | |||||
| 95 | =cut | ||||
| 96 | |||||
| 97 | 2 | 30µs | 1 | 11µs | # spent 11µs within IO::Seekable::BEGIN@97 which was called:
# once (11µs+0s) by IO::File::BEGIN@124 at line 97 # spent 11µs making 1 call to IO::Seekable::BEGIN@97 |
| 98 | 2 | 13µs | 2 | 43µs | # spent 24µs (4+20) within IO::Seekable::BEGIN@98 which was called:
# once (4µs+20µs) by IO::File::BEGIN@124 at line 98 # spent 24µs making 1 call to IO::Seekable::BEGIN@98
# spent 20µs making 1 call to Exporter::import |
| 99 | 2 | 18µs | 2 | 6µs | # spent 5µs (4+1) within IO::Seekable::BEGIN@99 which was called:
# once (4µs+1µs) by IO::File::BEGIN@124 at line 99 # spent 5µs making 1 call to IO::Seekable::BEGIN@99
# spent 1µs making 1 call to strict::import |
| 100 | 2 | 150µs | 1 | 1.92ms | # spent 1.92ms (1.43+486µs) within IO::Seekable::BEGIN@100 which was called:
# once (1.43ms+486µs) by IO::File::BEGIN@124 at line 100 # spent 1.92ms making 1 call to IO::Seekable::BEGIN@100 |
| 101 | # XXX we can't get these from IO::Handle or we'll get prototype | ||||
| 102 | # mismatch warnings on C<use POSIX; use IO::File;> :-( | ||||
| 103 | 2 | 84µs | 2 | 46µs | # spent 26µs (5+20) within IO::Seekable::BEGIN@103 which was called:
# once (5µs+20µs) by IO::File::BEGIN@124 at line 103 # spent 26µs making 1 call to IO::Seekable::BEGIN@103
# spent 20µs making 1 call to Exporter::import |
| 104 | 1 | 300ns | require Exporter; | ||
| 105 | |||||
| 106 | 1 | 800ns | our @EXPORT = qw(SEEK_SET SEEK_CUR SEEK_END); | ||
| 107 | 1 | 8µs | our @ISA = qw(Exporter); | ||
| 108 | |||||
| 109 | 1 | 200ns | our $VERSION = "1.55"; | ||
| 110 | |||||
| 111 | # spent 79µs (33+46) within IO::Seekable::seek which was called 28 times, avg 3µs/call:
# 7 times (8µs+16µs) by Archive::Zip::ZipFileMember::_skipLocalFileHeader at line 157 of Archive/Zip/ZipFileMember.pm, avg 3µs/call
# 7 times (10µs+10µs) by Archive::Zip::ZipFileMember::_seekToLocalHeader at line 67 of Archive/Zip/ZipFileMember.pm, avg 3µs/call
# 7 times (6µs+11µs) by Archive::Zip::ZipFileMember::rewindData at line 458 of Archive/Zip/ZipFileMember.pm, avg 2µs/call
# once (3µs+2µs) by Archive::Zip::Archive::readFromFileHandle at line 759 of Archive/Zip/Archive.pm
# once (1µs+2µs) by Archive::Zip::Archive::_readEndOfCentralDirectory at line 949 of Archive/Zip/Archive.pm
# once (1µs+1µs) by Archive::Zip::Archive::_findEndOfCentralDirectory at line 1026 of Archive/Zip/Archive.pm
# once (1µs+1µs) by Archive::Zip::Archive::_findEndOfCentralDirectory at line 1039 of Archive/Zip/Archive.pm
# once (900ns+1µs) by Archive::Zip::Archive::readFromFileHandle at line 770 of Archive/Zip/Archive.pm
# once (900ns+1µs) by Archive::Zip::Archive::_findEndOfCentralDirectory at line 1053 of Archive/Zip/Archive.pm
# once (900ns+1µs) by Archive::Zip::Archive::_readEndOfCentralDirectory at line 862 of Archive/Zip/Archive.pm | ||||
| 112 | 28 | 3µs | @_ == 3 or croak 'usage: $io->seek(POS, WHENCE)'; | ||
| 113 | 28 | 89µs | 28 | 46µs | seek($_[0], $_[1], $_[2]); # spent 46µs making 28 calls to CORE::seek, avg 2µs/call |
| 114 | } | ||||
| 115 | |||||
| 116 | sub sysseek { | ||||
| 117 | @_ == 3 or croak 'usage: $io->sysseek(POS, WHENCE)'; | ||||
| 118 | sysseek($_[0], $_[1], $_[2]); | ||||
| 119 | } | ||||
| 120 | |||||
| 121 | # spent 15µs (13+2) within IO::Seekable::tell which was called 9 times, avg 2µs/call:
# 7 times (8µs+2µs) by Archive::Zip::ZipFileMember::_skipLocalFileHeader at line 178 of Archive/Zip/ZipFileMember.pm, avg 1µs/call
# once (4µs+400ns) by Archive::Zip::Archive::_findEndOfCentralDirectory at line 1029 of Archive/Zip/Archive.pm
# once (800ns+200ns) by Archive::Zip::Archive::_readEndOfCentralDirectory at line 839 of Archive/Zip/Archive.pm | ||||
| 122 | 9 | 2µs | @_ == 1 or croak 'usage: $io->tell()'; | ||
| 123 | 9 | 18µs | 9 | 2µs | tell($_[0]); # spent 2µs making 9 calls to CORE::tell, avg 233ns/call |
| 124 | } | ||||
| 125 | |||||
| 126 | 1 | 3µs | 1; |