← 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/SelectSaver.pm
StatementsExecuted 7 statements in 121µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs39µsSelectSaver::::BEGIN@38SelectSaver::BEGIN@38
1117µs37µsSelectSaver::::BEGIN@39SelectSaver::BEGIN@39
0000s0sSelectSaver::::DESTROYSelectSaver::DESTROY
0000s0sSelectSaver::::newSelectSaver::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package SelectSaver;
2
31600nsour $VERSION = '1.02';
4
5=head1 NAME
6
7SelectSaver - 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
27A C<SelectSaver> object contains a reference to the file handle that
28was selected when it was created. If its C<new> method gets an extra
29parameter, then that parameter is selected; otherwise, the selected
30file handle remains unchanged.
31
32When a C<SelectSaver> is destroyed, it re-selects the file handle
33that was selected when it was created.
34
35=cut
36
3716µsrequire 5.000;
38219µs266µs
# spent 39µs (12+27) within SelectSaver::BEGIN@38 which was called: # once (12µs+27µs) by IO::Handle::BEGIN@268 at line 38
use Carp;
# spent 39µs making 1 call to SelectSaver::BEGIN@38 # spent 27µs making 1 call to Exporter::import
39293µs266µs
# spent 37µs (7+30) within SelectSaver::BEGIN@39 which was called: # once (7µs+30µs) by IO::Handle::BEGIN@268 at line 39
use Symbol;
# spent 37µs making 1 call to SelectSaver::BEGIN@39 # spent 30µs making 1 call to Exporter::import
40
41sub 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
49sub DESTROY {
50 my $self = $_[0];
51 select $$self;
52}
53
5412µs1;