| Filename | /home/ss5/perl5/perlbrew/perls/tapper-perl/lib/5.16.3/SelectSaver.pm |
| Statements | Executed 14 statements in 142µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 24µs | 31µs | SelectSaver::new |
| 1 | 1 | 1 | 10µs | 36µs | SelectSaver::BEGIN@38 |
| 1 | 1 | 1 | 7µs | 9µs | SelectSaver::DESTROY |
| 1 | 1 | 1 | 7µs | 30µs | SelectSaver::BEGIN@39 |
| 3 | 3 | 1 | 5µs | 5µs | SelectSaver::CORE:select (opcode) |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package SelectSaver; | ||||
| 2 | |||||
| 3 | 1 | 400ns | 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 | 7µs | require 5.000; | ||
| 38 | 2 | 18µs | 2 | 62µs | # spent 36µs (10+26) within SelectSaver::BEGIN@38 which was called:
# once (10µs+26µs) by IO::Handle::BEGIN@265 at line 38 # spent 36µs making 1 call to SelectSaver::BEGIN@38
# spent 26µs making 1 call to Exporter::import |
| 39 | 2 | 77µs | 2 | 53µs | # spent 30µs (7+23) within SelectSaver::BEGIN@39 which was called:
# once (7µs+23µs) by IO::Handle::BEGIN@265 at line 39 # spent 30µs making 1 call to SelectSaver::BEGIN@39
# spent 23µs making 1 call to Exporter::import |
| 40 | |||||
| 41 | # spent 31µs (24+6) within SelectSaver::new which was called:
# once (24µs+6µs) by IO::Handle::autoflush at line 494 of IO/Handle.pm | ||||
| 42 | 1 | 1µs | @_ >= 1 && @_ <= 2 or croak 'usage: SelectSaver->new( [FILEHANDLE] )'; | ||
| 43 | 1 | 10µs | 1 | 2µs | my $fh = select; # spent 2µs making 1 call to SelectSaver::CORE:select |
| 44 | 1 | 4µs | my $self = bless \$fh, $_[0]; | ||
| 45 | 1 | 8µs | 2 | 4µs | select qualify($_[1], caller) if @_ > 1; # spent 2µs making 1 call to Symbol::qualify
# spent 1µs making 1 call to SelectSaver::CORE:select |
| 46 | 1 | 4µs | $self; | ||
| 47 | } | ||||
| 48 | |||||
| 49 | # spent 9µs (7+2) within SelectSaver::DESTROY which was called:
# once (7µs+2µs) by IO::Handle::autoflush at line 267 of lib/Benchmark/Perl/Formance.pm | ||||
| 50 | 1 | 400ns | my $self = $_[0]; | ||
| 51 | 1 | 11µs | 1 | 2µs | select $$self; # spent 2µs making 1 call to SelectSaver::CORE:select |
| 52 | } | ||||
| 53 | |||||
| 54 | 1 | 2µs | 1; | ||
sub SelectSaver::CORE:select; # opcode |