Filename | /usr/share/perl/5.10/FileHandle.pm |
Statements | Executed 84 statements in 692µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 2 | 2 | 51µs | 1.30ms | import | FileHandle::
1 | 1 | 1 | 40µs | 40µs | BEGIN@3 | FileHandle::
1 | 1 | 1 | 12µs | 19µs | BEGIN@4 | FileHandle::
1 | 1 | 1 | 11µs | 33µs | BEGIN@46 | FileHandle::
0 | 0 | 0 | 0s | 0s | pipe | FileHandle::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package FileHandle; | ||||
2 | |||||
3 | 3 | 55µs | 1 | 40µs | # spent 40µs within FileHandle::BEGIN@3 which was called:
# once (40µs+0s) by Module::Load::Conditional::BEGIN@11 at line 3 # spent 40µs making 1 call to FileHandle::BEGIN@3 |
4 | 3 | 151µs | 2 | 26µs | # spent 19µs (12+7) within FileHandle::BEGIN@4 which was called:
# once (12µs+7µs) by Module::Load::Conditional::BEGIN@11 at line 4 # spent 19µs making 1 call to FileHandle::BEGIN@4
# spent 7µs making 1 call to strict::import |
5 | 1 | 1µs | our($VERSION, @ISA, @EXPORT, @EXPORT_OK); | ||
6 | |||||
7 | 1 | 700ns | $VERSION = "2.02"; | ||
8 | |||||
9 | 1 | 2µs | require IO::File; | ||
10 | 1 | 22µs | @ISA = qw(IO::File); | ||
11 | |||||
12 | 1 | 1µs | @EXPORT = qw(_IOFBF _IOLBF _IONBF); | ||
13 | |||||
14 | 1 | 3µs | @EXPORT_OK = qw( | ||
15 | pipe | ||||
16 | |||||
17 | autoflush | ||||
18 | output_field_separator | ||||
19 | output_record_separator | ||||
20 | input_record_separator | ||||
21 | input_line_number | ||||
22 | format_page_number | ||||
23 | format_lines_per_page | ||||
24 | format_lines_left | ||||
25 | format_name | ||||
26 | format_top_name | ||||
27 | format_line_break_characters | ||||
28 | format_formfeed | ||||
29 | |||||
30 | |||||
31 | printf | ||||
32 | getline | ||||
33 | getlines | ||||
34 | ); | ||||
35 | |||||
36 | # | ||||
37 | # Everything we're willing to export, we must first import. | ||||
38 | # | ||||
39 | 1 | 20µs | 1 | 231µs | import IO::Handle grep { !defined(&$_) } @EXPORT, @EXPORT_OK; # spent 231µs making 1 call to Exporter::import |
40 | |||||
41 | # | ||||
42 | # Some people call "FileHandle::function", so all the functions | ||||
43 | # that were in the old FileHandle class must be imported, too. | ||||
44 | # | ||||
45 | { | ||||
46 | 4 | 271µs | 2 | 55µs | # spent 33µs (11+22) within FileHandle::BEGIN@46 which was called:
# once (11µs+22µs) by Module::Load::Conditional::BEGIN@11 at line 46 # spent 33µs making 1 call to FileHandle::BEGIN@46
# spent 22µs making 1 call to strict::unimport |
47 | |||||
48 | 1 | 6µs | my %import = ( | ||
49 | 'IO::Handle' => | ||||
50 | [qw(DESTROY new_from_fd fdopen close fileno getc ungetc gets | ||||
51 | eof flush error clearerr setbuf setvbuf _open_mode_string)], | ||||
52 | 'IO::Seekable' => | ||||
53 | [qw(seek tell getpos setpos)], | ||||
54 | 'IO::File' => | ||||
55 | [qw(new new_tmpfile open)] | ||||
56 | ); | ||||
57 | 1 | 4µs | for my $pkg (keys %import) { | ||
58 | 3 | 4µs | for my $func (@{$import{$pkg}}) { | ||
59 | 22 | 37µs | my $c = *{"${pkg}::$func"}{CODE} | ||
60 | or die "${pkg}::$func missing"; | ||||
61 | 22 | 45µs | *$func = $c; | ||
62 | } | ||||
63 | } | ||||
64 | } | ||||
65 | |||||
66 | # | ||||
67 | # Specialized importer for Fcntl magic. | ||||
68 | # | ||||
69 | # spent 1.30ms (51µs+1.25) within FileHandle::import which was called 2 times, avg 651µs/call:
# once (30µs+716µs) by Storable::BEGIN@23 at line 23 of Storable.pm
# once (21µs+535µs) by MIME::Lite::BEGIN@331 at line 331 of MIME/Lite.pm | ||||
70 | 2 | 3µs | my $pkg = shift; | ||
71 | 2 | 2µs | my $callpkg = caller; | ||
72 | 2 | 2µs | require Exporter; | ||
73 | 2 | 6µs | 2 | 54µs | Exporter::export($pkg, $callpkg, @_); # spent 54µs making 2 calls to Exporter::export, avg 27µs/call |
74 | |||||
75 | # | ||||
76 | # If the Fcntl extension is available, | ||||
77 | # export its constants. | ||||
78 | # | ||||
79 | 2 | 16µs | eval { | ||
80 | 2 | 2µs | require Fcntl; | ||
81 | 2 | 5µs | 2 | 26µs | Exporter::export('Fcntl', $callpkg); # spent 26µs making 2 calls to Exporter::export, avg 13µs/call |
82 | }; | ||||
83 | } | ||||
84 | |||||
85 | ################################################ | ||||
86 | # This is the only exported function we define; | ||||
87 | # the rest come from other classes. | ||||
88 | # | ||||
89 | |||||
90 | sub pipe { | ||||
91 | my $r = new IO::Handle; | ||||
92 | my $w = new IO::Handle; | ||||
93 | CORE::pipe($r, $w) or return undef; | ||||
94 | ($r, $w); | ||||
95 | } | ||||
96 | |||||
97 | # Rebless standard file handles | ||||
98 | 1 | 8µs | bless *STDIN{IO}, "FileHandle" if ref *STDIN{IO} eq "IO::Handle"; | ||
99 | 1 | 1µs | bless *STDOUT{IO}, "FileHandle" if ref *STDOUT{IO} eq "IO::Handle"; | ||
100 | 1 | 1µs | bless *STDERR{IO}, "FileHandle" if ref *STDERR{IO} eq "IO::Handle"; | ||
101 | |||||
102 | 1 | 22µs | 1; | ||
103 | |||||
104 | __END__ |