Filename | /usr/lib/perl/5.10/IO/File.pm |
Statements | Executed 32 statements in 1.22ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 534µs | 838µs | BEGIN@11 | IO::File::
68 | 1 | 1 | 80µs | 80µs | CORE:match (opcode) | IO::File::
1 | 1 | 1 | 31µs | 31µs | BEGIN@5 | IO::File::
1 | 1 | 1 | 17µs | 104µs | BEGIN@9 | IO::File::
1 | 1 | 1 | 15µs | 22µs | BEGIN@6 | IO::File::
1 | 1 | 1 | 14µs | 14µs | BEGIN@12 | IO::File::
1 | 1 | 1 | 14µs | 86µs | BEGIN@8 | IO::File::
1 | 1 | 1 | 13µs | 13µs | BEGIN@10 | IO::File::
0 | 0 | 0 | 0s | 0s | binmode | IO::File::
0 | 0 | 0 | 0s | 0s | new | IO::File::
0 | 0 | 0 | 0s | 0s | open | IO::File::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # | ||||
2 | |||||
3 | package IO::File; | ||||
4 | |||||
5 | 3 | 54µs | 1 | 31µs | # spent 31µs within IO::File::BEGIN@5 which was called:
# once (31µs+0s) by Storable::BEGIN@23 at line 5 # spent 31µs making 1 call to IO::File::BEGIN@5 |
6 | 3 | 63µs | 2 | 29µs | # spent 22µs (15+7) within IO::File::BEGIN@6 which was called:
# once (15µs+7µs) by Storable::BEGIN@23 at line 6 # spent 22µs making 1 call to IO::File::BEGIN@6
# spent 7µs making 1 call to strict::import |
7 | 1 | 1µs | our($VERSION, @EXPORT, @EXPORT_OK, @ISA); | ||
8 | 3 | 39µs | 2 | 158µs | # spent 86µs (14+72) within IO::File::BEGIN@8 which was called:
# once (14µs+72µs) by Storable::BEGIN@23 at line 8 # spent 86µs making 1 call to IO::File::BEGIN@8
# spent 72µs making 1 call to Exporter::import |
9 | 3 | 42µs | 2 | 191µs | # spent 104µs (17+87) within IO::File::BEGIN@9 which was called:
# once (17µs+87µs) by Storable::BEGIN@23 at line 9 # spent 104µs making 1 call to IO::File::BEGIN@9
# spent 87µs making 1 call to Exporter::import |
10 | 3 | 39µs | 1 | 13µs | # spent 13µs within IO::File::BEGIN@10 which was called:
# once (13µs+0s) by Storable::BEGIN@23 at line 10 # spent 13µs making 1 call to IO::File::BEGIN@10 |
11 | 3 | 170µs | 2 | 909µs | # spent 838µs (534+304) within IO::File::BEGIN@11 which was called:
# once (534µs+304µs) by Storable::BEGIN@23 at line 11 # spent 838µs making 1 call to IO::File::BEGIN@11
# spent 71µs making 1 call to Exporter::import |
12 | 3 | 489µs | 1 | 14µs | # spent 14µs within IO::File::BEGIN@12 which was called:
# once (14µs+0s) by Storable::BEGIN@23 at line 12 # spent 14µs making 1 call to IO::File::BEGIN@12 |
13 | |||||
14 | 1 | 1µs | require Exporter; | ||
15 | |||||
16 | 1 | 24µs | @ISA = qw(IO::Handle IO::Seekable Exporter); | ||
17 | |||||
18 | 1 | 2µs | $VERSION = "1.14"; | ||
19 | |||||
20 | 1 | 2µs | @EXPORT = @IO::Seekable::EXPORT; | ||
21 | |||||
22 | 1 | 3µs | eval { | ||
23 | # Make all Fcntl O_XXX constants available for importing | ||||
24 | 1 | 2µs | require Fcntl; | ||
25 | 1 | 258µs | 68 | 80µs | my @O = grep /^O_/, @Fcntl::EXPORT; # spent 80µs making 68 calls to IO::File::CORE:match, avg 1µs/call |
26 | 1 | 6µs | 1 | 333µs | Fcntl->import(@O); # first we import what we want to export # spent 333µs making 1 call to Exporter::import |
27 | 1 | 13µs | push(@EXPORT, @O); | ||
28 | }; | ||||
29 | |||||
30 | ################################################ | ||||
31 | ## Constructor | ||||
32 | ## | ||||
33 | |||||
34 | sub new { | ||||
35 | my $type = shift; | ||||
36 | my $class = ref($type) || $type || "IO::File"; | ||||
37 | @_ >= 0 && @_ <= 3 | ||||
38 | or croak "usage: new $class [FILENAME [,MODE [,PERMS]]]"; | ||||
39 | my $fh = $class->SUPER::new(); | ||||
40 | if (@_) { | ||||
41 | $fh->open(@_) | ||||
42 | or return undef; | ||||
43 | } | ||||
44 | $fh; | ||||
45 | } | ||||
46 | |||||
47 | ################################################ | ||||
48 | ## Open | ||||
49 | ## | ||||
50 | |||||
51 | sub open { | ||||
52 | @_ >= 2 && @_ <= 4 or croak 'usage: $fh->open(FILENAME [,MODE [,PERMS]])'; | ||||
53 | my ($fh, $file) = @_; | ||||
54 | if (@_ > 2) { | ||||
55 | my ($mode, $perms) = @_[2, 3]; | ||||
56 | if ($mode =~ /^\d+$/) { | ||||
57 | defined $perms or $perms = 0666; | ||||
58 | return sysopen($fh, $file, $mode, $perms); | ||||
59 | } elsif ($mode =~ /:/) { | ||||
60 | return open($fh, $mode, $file) if @_ == 3; | ||||
61 | croak 'usage: $fh->open(FILENAME, IOLAYERS)'; | ||||
62 | } else { | ||||
63 | return open($fh, IO::Handle::_open_mode_string($mode), $file); | ||||
64 | } | ||||
65 | } | ||||
66 | open($fh, $file); | ||||
67 | } | ||||
68 | |||||
69 | ################################################ | ||||
70 | ## Binmode | ||||
71 | ## | ||||
72 | |||||
73 | sub binmode { | ||||
74 | ( @_ == 1 or @_ == 2 ) or croak 'usage $fh->binmode([LAYER])'; | ||||
75 | |||||
76 | my($fh, $layer) = @_; | ||||
77 | |||||
78 | return binmode $$fh unless $layer; | ||||
79 | return binmode $$fh, $layer; | ||||
80 | } | ||||
81 | |||||
82 | 1 | 13µs | 1; | ||
# spent 80µs within IO::File::CORE:match which was called 68 times, avg 1µs/call:
# 68 times (80µs+0s) by Storable::BEGIN@23 at line 25, avg 1µs/call |