Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Writer/File.pm |
Statements | Executed 12 statements in 484µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 40µs | 42µs | BEGIN@1.297 | YAML::PP::Dumper::
1 | 1 | 1 | 10µs | 45µs | BEGIN@7 | YAML::PP::Writer::File::
1 | 1 | 1 | 9µs | 44µs | BEGIN@2.298 | YAML::PP::Dumper::
1 | 1 | 1 | 7µs | 29µs | BEGIN@11 | YAML::PP::Writer::File::
1 | 1 | 1 | 6µs | 88µs | BEGIN@9 | YAML::PP::Writer::File::
0 | 0 | 0 | 0s | 0s | _open_handle | YAML::PP::Writer::File::
0 | 0 | 0 | 0s | 0s | finish | YAML::PP::Writer::File::
0 | 0 | 0 | 0s | 0s | init | YAML::PP::Writer::File::
0 | 0 | 0 | 0s | 0s | write | YAML::PP::Writer::File::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 45µs | 2 | 44µs | # spent 42µs (40+2) within YAML::PP::Dumper::BEGIN@1.297 which was called:
# once (40µs+2µs) by YAML::PP::Dumper::BEGIN@12 at line 1 # spent 42µs making 1 call to YAML::PP::Dumper::BEGIN@1.297
# spent 2µs making 1 call to strict::import |
2 | 2 | 54µs | 2 | 79µs | # spent 44µs (9+35) within YAML::PP::Dumper::BEGIN@2.298 which was called:
# once (9µs+35µs) by YAML::PP::Dumper::BEGIN@12 at line 2 # spent 44µs making 1 call to YAML::PP::Dumper::BEGIN@2.298
# spent 35µs making 1 call to warnings::import |
3 | package YAML::PP::Writer::File; | ||||
4 | |||||
5 | 1 | 0s | our $VERSION = '0.035'; # VERSION | ||
6 | |||||
7 | 2 | 43µs | 2 | 80µs | # spent 45µs (10+35) within YAML::PP::Writer::File::BEGIN@7 which was called:
# once (10µs+35µs) by YAML::PP::Dumper::BEGIN@12 at line 7 # spent 45µs making 1 call to YAML::PP::Writer::File::BEGIN@7
# spent 35µs making 1 call to Exporter::import |
8 | |||||
9 | 2 | 28µs | 2 | 170µs | # spent 88µs (6+82) within YAML::PP::Writer::File::BEGIN@9 which was called:
# once (6µs+82µs) by YAML::PP::Dumper::BEGIN@12 at line 9 # spent 88µs making 1 call to YAML::PP::Writer::File::BEGIN@9
# spent 82µs making 1 call to base::import |
10 | |||||
11 | 2 | 310µs | 2 | 51µs | # spent 29µs (7+22) within YAML::PP::Writer::File::BEGIN@11 which was called:
# once (7µs+22µs) by YAML::PP::Dumper::BEGIN@12 at line 11 # spent 29µs making 1 call to YAML::PP::Writer::File::BEGIN@11
# spent 22µs making 1 call to Exporter::import |
12 | |||||
13 | sub _open_handle { | ||||
14 | my ($self) = @_; | ||||
15 | if (openhandle($self->{output})) { | ||||
16 | $self->{filehandle} = $self->{output}; | ||||
17 | return $self->{output}; | ||||
18 | } | ||||
19 | open my $fh, '>:encoding(UTF-8)', $self->{output} | ||||
20 | or croak "Could not open '$self->{output}' for writing: $!"; | ||||
21 | $self->{filehandle} = $fh; | ||||
22 | return $fh; | ||||
23 | } | ||||
24 | |||||
25 | sub write { | ||||
26 | my ($self, $line) = @_; | ||||
27 | my $fh = $self->{filehandle}; | ||||
28 | print $fh $line; | ||||
29 | } | ||||
30 | |||||
31 | sub init { | ||||
32 | my ($self) = @_; | ||||
33 | my $fh = $self->_open_handle; | ||||
34 | } | ||||
35 | |||||
36 | sub finish { | ||||
37 | my ($self) = @_; | ||||
38 | if (openhandle($self->{output})) { | ||||
39 | # Original argument was a file handle, so the caller needs | ||||
40 | # to close it | ||||
41 | return; | ||||
42 | } | ||||
43 | close $self->{filehandle}; | ||||
44 | } | ||||
45 | |||||
46 | 1 | 4µs | 1; | ||
47 | |||||
48 | __END__ |