← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/darwin-2level/IO/Seekable.pm
StatementsExecuted 17 statements in 402µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.81ms2.82msIO::Seekable::::BEGIN@101IO::Seekable::BEGIN@101
11114µs14µsIO::Seekable::::BEGIN@97IO::Seekable::BEGIN@97
1118µs310µsIO::Seekable::::BEGIN@104IO::Seekable::BEGIN@104
1117µs38µsIO::Seekable::::BEGIN@98IO::Seekable::BEGIN@98
1116µs17µsIO::Seekable::::BEGIN@99IO::Seekable::BEGIN@99
0000s0sIO::Seekable::::seekIO::Seekable::seek
0000s0sIO::Seekable::::sysseekIO::Seekable::sysseek
0000s0sIO::Seekable::::tellIO::Seekable::tell
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#
2
3package IO::Seekable;
4
5=head1 NAME
6
7IO::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
17C<IO::Seekable> does not have a constructor of its own as it is intended to
18be inherited by other C<IO::Handle> based objects. It provides methods
19which allow seeking of the file descriptors.
20
21=over 4
22
23=item $io->getpos
24
25Returns an opaque value that represents the current position of the
26IO::File, or C<undef> if this is not possible (eg an unseekable stream such
27as a terminal, pipe or socket). If the fgetpos() function is available in
28your C library it is used to implements getpos, else perl emulates getpos
29using C's ftell() function.
30
31=item $io->setpos
32
33Uses the value of a previous getpos call to return to a previously visited
34position. Returns "0 but true" on success, C<undef> on failure.
35
36=back
37
38See L<perlfunc> for complete descriptions of each of the following
39supported C<IO::Seekable> methods, which are just front ends for the
40corresponding built-in functions:
41
42=over 4
43
44=item $io->seek ( POS, WHENCE )
45
46Seek the IO::File to position POS, relative to WHENCE:
47
48=over 8
49
50=item WHENCE=0 (SEEK_SET)
51
52POS is absolute position. (Seek relative to the start of the file)
53
54=item WHENCE=1 (SEEK_CUR)
55
56POS is an offset from the current position. (Seek relative to current)
57
58=item WHENCE=2 (SEEK_END)
59
60POS is an offset from the end of the file. (Seek relative to end)
61
62=back
63
64The SEEK_* constants can be imported from the C<Fcntl> module if you
65don't wish to use the numbers C<0> C<1> or C<2> in your code.
66
67Returns C<1> upon success, C<0> otherwise.
68
69=item $io->sysseek( POS, WHENCE )
70
71Similar to $io->seek, but sets the IO::File's position using the system
72call lseek(2) directly, so will confuse most perl IO operators except
73sysread and syswrite (see L<perlfunc> for full details)
74
75Returns the new position, or C<undef> on failure. A position
76of zero is returned as the string C<"0 but true">
77
78=item $io->tell
79
80Returns the IO::File's current position, or -1 on error.
81
82=back
83
84=head1 SEE ALSO
85
86L<perlfunc>,
87L<perlop/"I/O Operators">,
88L<IO::Handle>
89L<IO::File>
90
91=head1 HISTORY
92
93Derived from FileHandle.pm by Graham Barr E<lt>gbarr@pobox.comE<gt>
94
95=cut
96
97240µs114µs
# spent 14µs within IO::Seekable::BEGIN@97 which was called: # once (14µs+0s) by File::Temp::BEGIN@16 at line 97
use 5.006_001;
# spent 14µs making 1 call to IO::Seekable::BEGIN@97
98220µs269µs
# spent 38µs (7+31) within IO::Seekable::BEGIN@98 which was called: # once (7µs+31µs) by File::Temp::BEGIN@16 at line 98
use Carp;
# spent 38µs making 1 call to IO::Seekable::BEGIN@98 # spent 31µs making 1 call to Exporter::import
99230µs228µs
# spent 17µs (6+11) within IO::Seekable::BEGIN@99 which was called: # once (6µs+11µs) by File::Temp::BEGIN@16 at line 99
use strict;
# spent 17µs making 1 call to IO::Seekable::BEGIN@99 # spent 11µs making 1 call to strict::import
1001300nsour($VERSION, @EXPORT, @ISA);
1012171µs12.82ms
# spent 2.82ms (1.81+1.01) within IO::Seekable::BEGIN@101 which was called: # once (1.81ms+1.01ms) by File::Temp::BEGIN@16 at line 101
use IO::Handle ();
# spent 2.82ms making 1 call to IO::Seekable::BEGIN@101
102# XXX we can't get these from IO::Handle or we'll get prototype
103# mismatch warnings on C<use POSIX; use IO::File;> :-(
1042116µs2613µs
# spent 310µs (8+303) within IO::Seekable::BEGIN@104 which was called: # once (8µs+303µs) by File::Temp::BEGIN@16 at line 104
use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END);
# spent 310µs making 1 call to IO::Seekable::BEGIN@104 # spent 303µs making 1 call to Exporter::import
1051300nsrequire Exporter;
106
10711µs@EXPORT = qw(SEEK_SET SEEK_CUR SEEK_END);
108110µs@ISA = qw(Exporter);
109
1101300ns$VERSION = "1.10";
11119µs$VERSION = eval $VERSION;
# spent 2µs executing statements in string eval
112
113sub seek {
114 @_ == 3 or croak 'usage: $io->seek(POS, WHENCE)';
115 seek($_[0], $_[1], $_[2]);
116}
117
118sub sysseek {
119 @_ == 3 or croak 'usage: $io->sysseek(POS, WHENCE)';
120 sysseek($_[0], $_[1], $_[2]);
121}
122
123sub tell {
124 @_ == 1 or croak 'usage: $io->tell()';
125 tell($_[0]);
126}
127
12813µs1;