← Index
NYTProf Performance Profile   « block view • line view • sub view »
For ddd2.pl
  Run on Tue May 25 16:52:24 2010
Reported on Tue May 25 16:57:03 2010

File /usr/local/lib/perl5/5.8.8/SelectSaver.pm
Statements Executed 3236
Statement Execution Time 55.5ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4611130.9ms52.5msSelectSaver::::newSelectSaver::new
13833214.6ms14.6msSelectSaver::::CORE:selectSelectSaver::CORE:select (opcode)
0000s0sSelectSaver::::BEGINSelectSaver::BEGIN
0000s0sSelectSaver::::DESTROYSelectSaver::DESTROY
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
315µsour $VERSION = '1.01';
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 = new SelectSaver(FILEHANDLE);
15 # FILEHANDLE is selected
16 }
17 # previous handle is selected
18
19 {
20 my $saver = new SelectSaver;
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
3715µsrequire 5.000;
383123µs1234µsuse Carp;
# spent 234µs making 1 call to Exporter::import
393310µs1242µsuse Symbol;
# spent 242µs making 1 call to Exporter::import
40
41
# spent 52.5ms (30.9+21.6) within SelectSaver::new which was called 461 times, avg 114µs/call: # 461 times (30.9ms+21.6ms) by IO::Handle::autoflush at line 467 of IO/Handle.pm, avg 114µs/call
sub new {
424612.66ms @_ >= 1 && @_ <= 2 or croak 'usage: new SelectSaver [FILEHANDLE]';
4346110.3ms4614.10ms my $fh = select;
# spent 4.10ms making 461 calls to SelectSaver::CORE:select, avg 9µs/call
444613.32ms my $self = bless \$fh, $_[0];
4546120.0ms92217.5ms select qualify($_[1], caller) if @_ > 1;
# spent 9.57ms making 461 calls to Symbol::qualify, avg 21µs/call # spent 7.94ms making 461 calls to SelectSaver::CORE:select, avg 17µs/call
464616.55ms $self;
47}
48
49sub DESTROY {
504612.18ms my $self = $_[0];
5146110.0ms4612.53ms select $$self;
# spent 2.53ms making 461 calls to SelectSaver::CORE:select, avg 5µs/call
52}
53
54112µs1;
# spent 14.6ms within SelectSaver::CORE:select which was called 1383 times, avg 11µs/call: # 461 times (7.94ms+0s) by SelectSaver::new at line 45 of SelectSaver.pm, avg 17µs/call # 461 times (4.10ms+0s) by SelectSaver::new at line 43 of SelectSaver.pm, avg 9µs/call # 461 times (2.53ms+0s) by IO::Handle::autoflush at line 51 of SelectSaver.pm, avg 5µs/call
sub SelectSaver::CORE:select; # xsub