| File | /usr/local/lib/perl5/5.10.1/SelectSaver.pm |
| Statements Executed | 23 |
| Statement Execution Time | 944µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 1 | 1 | 37µs | 76µs | SelectSaver::new |
| 6 | 3 | 2 | 36µs | 36µs | SelectSaver::CORE:select (opcode) |
| 1 | 1 | 1 | 14µs | 47µs | SelectSaver::BEGIN@38 |
| 2 | 1 | 1 | 12µs | 13µs | SelectSaver::DESTROY |
| 1 | 1 | 1 | 8µs | 40µs | SelectSaver::BEGIN@39 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package SelectSaver; | ||||
| 2 | |||||
| 3 | 1 | 3µs | our $VERSION = '1.02'; | ||
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| 7 | SelectSaver - save and restore selected file handle | ||||
| 8 | |||||
| 9 | =head1 SYNOPSIS | ||||
| 10 | |||||
| 11 | use SelectSaver; | ||||
| 12 | |||||
| 13 | { | ||||
| 14 | my $saver = SelectSaver->new(FILEHANDLE); | ||||
| 15 | # FILEHANDLE is selected | ||||
| 16 | } | ||||
| 17 | # previous handle is selected | ||||
| 18 | |||||
| 19 | { | ||||
| 20 | my $saver = SelectSaver->new; | ||||
| 21 | # new handle may be selected, or not | ||||
| 22 | } | ||||
| 23 | # previous handle is selected | ||||
| 24 | |||||
| 25 | =head1 DESCRIPTION | ||||
| 26 | |||||
| 27 | A C<SelectSaver> object contains a reference to the file handle that | ||||
| 28 | was selected when it was created. If its C<new> method gets an extra | ||||
| 29 | parameter, then that parameter is selected; otherwise, the selected | ||||
| 30 | file handle remains unchanged. | ||||
| 31 | |||||
| 32 | When a C<SelectSaver> is destroyed, it re-selects the file handle | ||||
| 33 | that was selected when it was created. | ||||
| 34 | |||||
| 35 | =cut | ||||
| 36 | |||||
| 37 | 1 | 40µs | require 5.000; | ||
| 38 | 3 | 112µs | 2 | 80µs | # spent 47µs (14+33) within SelectSaver::BEGIN@38 which was called
# once (14µs+33µs) by IO::File::BEGIN@132 at line 38 # spent 47µs making 1 call to SelectSaver::BEGIN@38
# spent 33µs making 1 call to Exporter::import |
| 39 | 3 | 691µs | 2 | 72µs | # spent 40µs (8+32) within SelectSaver::BEGIN@39 which was called
# once (8µs+32µs) by IO::File::BEGIN@132 at line 39 # spent 40µs making 1 call to SelectSaver::BEGIN@39
# spent 32µs making 1 call to Exporter::import |
| 40 | |||||
| 41 | # spent 76µs (37+39) within SelectSaver::new which was called 2 times, avg 38µs/call:
# 2 times (37µs+39µs) by IO::Handle::autoflush at line 479 of IO/Handle.pm, avg 38µs/call | ||||
| 42 | 10 | 71µs | @_ >= 1 && @_ <= 2 or croak 'usage: SelectSaver->new( [FILEHANDLE] )'; | ||
| 43 | my $fh = select; # spent 6µs making 2 calls to SelectSaver::CORE:select, avg 3µs/call | ||||
| 44 | my $self = bless \$fh, $_[0]; | ||||
| 45 | select qualify($_[1], caller) if @_ > 1; # spent 30µs making 2 calls to SelectSaver::CORE:select, avg 15µs/call
# spent 4µs making 2 calls to Symbol::qualify, avg 2µs/call | ||||
| 46 | $self; | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | # spent 13µs (12+700ns) within SelectSaver::DESTROY which was called 2 times, avg 6µs/call:
# 2 times (12µs+700ns) by IO::Handle::autoflush at line 44 of IO/Socket.pm, avg 6µs/call | ||||
| 50 | 4 | 14µs | my $self = $_[0]; | ||
| 51 | select $$self; # spent 700ns making 2 calls to SelectSaver::CORE:select, avg 350ns/call | ||||
| 52 | } | ||||
| 53 | |||||
| 54 | 1 | 12µs | 1; | ||
# spent 36µs within SelectSaver::CORE:select which was called 6 times, avg 6µs/call:
# 2 times (30µs+0s) by SelectSaver::new at line 45 of SelectSaver.pm, avg 15µs/call
# 2 times (6µs+0s) by SelectSaver::new at line 43 of SelectSaver.pm, avg 3µs/call
# 2 times (700ns+0s) by SelectSaver::DESTROY at line 51 of SelectSaver.pm, avg 350ns/call |