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