Profile of SelectSaver.pm

← Index
NYTProf Performance Profile «block view•line view•sub view»
For bin/dpath
Run on Tue Jun 5 15:31:33 2012
Reported on Tue Jun 5 15:31:51 2012

Filename | /home/ss5/perl5/perlbrew/perls/perl-5.14.1/lib/5.14.1/SelectSaver.pm
Statements | Executed 7 statements in 619µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 50µs | 264µs | SelectSaver::::BEGIN@38SelectSaver::BEGIN@38
1 | 1 | 1 | 28µs | 163µs | SelectSaver::::BEGIN@39SelectSaver::BEGIN@39
0 | 0 | 0 | 0s | 0s | SelectSaver::::DESTROYSelectSaver::DESTROY
0 | 0 | 0 | 0s | 0s | SelectSaver::::newSelectSaver::new

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package SelectSaver;
2 |  |  |  |  |
3 | 1 | 2µ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 | 53µs |  |  | require 5.000;
38 | 2 | 99µs | 2 | 478µs | # spent 264µs (50+214) within SelectSaver::BEGIN@38 which was called: # once (50µs+214µs) by IO::Handle::BEGIN@265 at line 38 use Carp; # spent 264µs making 1 call to SelectSaver::BEGIN@38 # spent 214µs making 1 call to Exporter::import
39 | 2 | 451µs | 2 | 299µs | # spent 163µs (28+135) within SelectSaver::BEGIN@39 which was called: # once (28µs+135µs) by IO::Handle::BEGIN@265 at line 39 use Symbol; # spent 163µs making 1 call to SelectSaver::BEGIN@39 # spent 135µs making 1 call to Exporter::import
40 |  |  |  |  |
41 |  |  |  |  | sub new {
42 |  |  |  |  | @_ >= 1 && @_ <= 2 or croak 'usage: SelectSaver->new( [FILEHANDLE] )';
43 |  |  |  |  | my $fh = select;
44 |  |  |  |  | my $self = bless \$fh, $_[0];
45 |  |  |  |  | select qualify($_[1], caller) if @_ > 1;
46 |  |  |  |  | $self;
47 |  |  |  |  | }
48 |  |  |  |  |
49 |  |  |  |  | sub DESTROY {
50 |  |  |  |  | my $self = $_[0];
51 |  |  |  |  | select $$self;
52 |  |  |  |  | }
53 |  |  |  |  |
54 | 1 | 12µs |  |  | 1;