Filename | /usr/lib/perl/5.14/IO/File.pm |
Statements | Executed 25 statements in 822µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 557µs | 609µs | BEGIN@9 | IO::File::
1 | 1 | 1 | 327µs | 3.08ms | BEGIN@11 | IO::File::
1 | 1 | 1 | 220µs | 303µs | BEGIN@10 | IO::File::
1 | 1 | 1 | 20µs | 20µs | BEGIN@5 | IO::File::
68 | 1 | 1 | 18µs | 18µs | CORE:match (opcode) | IO::File::
1 | 1 | 1 | 9µs | 49µs | BEGIN@8 | IO::File::
1 | 1 | 1 | 7µs | 10µs | BEGIN@6 | IO::File::
1 | 1 | 1 | 7µs | 7µs | BEGIN@12 | 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 | 2 | 42µs | 1 | 20µs | # spent 20µs within IO::File::BEGIN@5 which was called:
# once (20µs+0s) by MongoDB::GridFS::File::BEGIN@27 at line 5 # spent 20µs making 1 call to IO::File::BEGIN@5 |
6 | 2 | 40µs | 2 | 13µs | # spent 10µs (7+3) within IO::File::BEGIN@6 which was called:
# once (7µs+3µs) by MongoDB::GridFS::File::BEGIN@27 at line 6 # spent 10µs making 1 call to IO::File::BEGIN@6
# spent 3µs making 1 call to strict::import |
7 | 1 | 400ns | our($VERSION, @EXPORT, @EXPORT_OK, @ISA); | ||
8 | 2 | 23µs | 2 | 88µs | # spent 49µs (9+39) within IO::File::BEGIN@8 which was called:
# once (9µs+39µs) by MongoDB::GridFS::File::BEGIN@27 at line 8 # spent 49µs making 1 call to IO::File::BEGIN@8
# spent 39µs making 1 call to Exporter::import |
9 | 2 | 97µs | 2 | 645µs | # spent 609µs (557+51) within IO::File::BEGIN@9 which was called:
# once (557µs+51µs) by MongoDB::GridFS::File::BEGIN@27 at line 9 # spent 609µs making 1 call to IO::File::BEGIN@9
# spent 36µs making 1 call to Exporter::import |
10 | 2 | 110µs | 1 | 303µs | # spent 303µs (220+84) within IO::File::BEGIN@10 which was called:
# once (220µs+84µs) by MongoDB::GridFS::File::BEGIN@27 at line 10 # spent 303µs making 1 call to IO::File::BEGIN@10 |
11 | 2 | 92µs | 2 | 3.11ms | # spent 3.08ms (327µs+2.75) within IO::File::BEGIN@11 which was called:
# once (327µs+2.75ms) by MongoDB::GridFS::File::BEGIN@27 at line 11 # spent 3.08ms making 1 call to IO::File::BEGIN@11
# spent 31µs making 1 call to Exporter::import |
12 | 2 | 304µs | 1 | 7µs | # spent 7µs within IO::File::BEGIN@12 which was called:
# once (7µs+0s) by MongoDB::GridFS::File::BEGIN@27 at line 12 # spent 7µs making 1 call to IO::File::BEGIN@12 |
13 | |||||
14 | 1 | 500ns | require Exporter; | ||
15 | |||||
16 | 1 | 10µs | @ISA = qw(IO::Handle IO::Seekable Exporter); | ||
17 | |||||
18 | 1 | 300ns | $VERSION = "1.15"; | ||
19 | |||||
20 | 1 | 700ns | @EXPORT = @IO::Seekable::EXPORT; | ||
21 | |||||
22 | 5 | 94µs | eval { | ||
23 | # Make all Fcntl O_XXX constants available for importing | ||||
24 | require Fcntl; | ||||
25 | 68 | 18µs | my @O = grep /^O_/, @Fcntl::EXPORT; # spent 18µs making 68 calls to IO::File::CORE:match, avg 266ns/call | ||
26 | 1 | 144µs | Fcntl->import(@O); # first we import what we want to export # spent 144µs making 1 call to Exporter::import | ||
27 | 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: $class->new([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 | 8µs | 1; | ||
# spent 18µs within IO::File::CORE:match which was called 68 times, avg 266ns/call:
# 68 times (18µs+0s) by MongoDB::GridFS::File::BEGIN@27 at line 25, avg 266ns/call |