| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Reader.pm |
| Statements | Executed 26934 statements in 83.6ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 13456 | 1 | 1 | 40.5ms | 78.4ms | YAML::PP::Reader::File::readline |
| 13456 | 1 | 1 | 28.9ms | 33.5ms | YAML::PP::Reader::File::CORE:readline (opcode) |
| 1 | 1 | 1 | 2.12ms | 4.38ms | YAML::PP::Reader::File::CORE:open (opcode) |
| 1 | 1 | 1 | 30µs | 34µs | YAML::PP::Parser::BEGIN@2.288 |
| 1 | 1 | 1 | 18µs | 48µs | YAML::PP::Parser::BEGIN@3.289 |
| 1 | 1 | 1 | 15µs | 4.40ms | YAML::PP::Reader::File::open_handle |
| 2 | 2 | 2 | 10µs | 10µs | YAML::PP::Reader::new |
| 1 | 1 | 1 | 7µs | 19µs | YAML::PP::Reader::File::BEGIN@49 |
| 1 | 1 | 1 | 6µs | 36µs | YAML::PP::Reader::File::BEGIN@45 |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Reader::File::read |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Reader::input |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Reader::read |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Reader::readline |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Reader::set_input |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # ABSTRACT: Reader class for YAML::PP representing input data | ||||
| 2 | 2 | 31µs | 2 | 38µs | # spent 34µs (30+4) within YAML::PP::Parser::BEGIN@2.288 which was called:
# once (30µs+4µs) by YAML::PP::Parser::BEGIN@21 at line 2 # spent 34µs making 1 call to YAML::PP::Parser::BEGIN@2.288
# spent 4µs making 1 call to strict::import |
| 3 | 2 | 263µs | 2 | 78µs | # spent 48µs (18+30) within YAML::PP::Parser::BEGIN@3.289 which was called:
# once (18µs+30µs) by YAML::PP::Parser::BEGIN@21 at line 3 # spent 48µs making 1 call to YAML::PP::Parser::BEGIN@3.289
# spent 30µs making 1 call to warnings::import |
| 4 | package YAML::PP::Reader; | ||||
| 5 | |||||
| 6 | 1 | 1µs | our $VERSION = '0.035'; # VERSION | ||
| 7 | |||||
| 8 | sub input { return $_[0]->{input} } | ||||
| 9 | sub set_input { $_[0]->{input} = $_[1] } | ||||
| 10 | |||||
| 11 | # spent 10µs within YAML::PP::Reader::new which was called 2 times, avg 5µs/call:
# once (6µs+0s) by YAML::PP::Parser::new at line 27 of YAML/PP/Parser.pm
# once (4µs+0s) by YAML::PP::Loader::load_file at line 84 of YAML/PP/Loader.pm | ||||
| 12 | 2 | 2µs | my ($class, %args) = @_; | ||
| 13 | 2 | 2µs | my $input = delete $args{input}; | ||
| 14 | 2 | 8µs | return bless { | ||
| 15 | input => $input, | ||||
| 16 | }, $class; | ||||
| 17 | } | ||||
| 18 | |||||
| 19 | sub read { | ||||
| 20 | my ($self) = @_; | ||||
| 21 | my $pos = pos $self->{input} || 0; | ||||
| 22 | my $yaml = substr($self->{input}, $pos); | ||||
| 23 | $self->{input} = ''; | ||||
| 24 | return $yaml; | ||||
| 25 | } | ||||
| 26 | |||||
| 27 | sub readline { | ||||
| 28 | my ($self) = @_; | ||||
| 29 | unless (length $self->{input}) { | ||||
| 30 | return; | ||||
| 31 | } | ||||
| 32 | if ( $self->{input} =~ m/\G([^\r\n]*(?:\n|\r\n|\r|\z))/g ) { | ||||
| 33 | my $line = $1; | ||||
| 34 | unless (length $line) { | ||||
| 35 | $self->{input} = ''; | ||||
| 36 | return; | ||||
| 37 | } | ||||
| 38 | return $line; | ||||
| 39 | } | ||||
| 40 | return; | ||||
| 41 | } | ||||
| 42 | |||||
| 43 | package YAML::PP::Reader::File; | ||||
| 44 | |||||
| 45 | 2 | 31µs | 2 | 66µs | # spent 36µs (6+30) within YAML::PP::Reader::File::BEGIN@45 which was called:
# once (6µs+30µs) by YAML::PP::Parser::BEGIN@21 at line 45 # spent 36µs making 1 call to YAML::PP::Reader::File::BEGIN@45
# spent 30µs making 1 call to Exporter::import |
| 46 | |||||
| 47 | 1 | 7µs | our @ISA = qw/ YAML::PP::Reader /; | ||
| 48 | |||||
| 49 | 2 | 171µs | 2 | 31µs | # spent 19µs (7+12) within YAML::PP::Reader::File::BEGIN@49 which was called:
# once (7µs+12µs) by YAML::PP::Parser::BEGIN@21 at line 49 # spent 19µs making 1 call to YAML::PP::Reader::File::BEGIN@49
# spent 12µs making 1 call to Exporter::import |
| 50 | |||||
| 51 | # spent 4.40ms (15µs+4.38) within YAML::PP::Reader::File::open_handle which was called:
# once (15µs+4.38ms) by YAML::PP::Reader::File::readline at line 74 | ||||
| 52 | 1 | 7µs | 1 | 2µs | if (openhandle( $_[0]->{input} )) { # spent 2µs making 1 call to Scalar::Util::openhandle |
| 53 | return $_[0]->{input}; | ||||
| 54 | } | ||||
| 55 | open my $fh, '<:encoding(UTF-8)', $_[0]->{input} | ||||
| 56 | 3 | 675µs | 5 | 6.10ms | or croak "Could not open '$_[0]->{input}' for reading: $!"; # spent 4.38ms making 1 call to YAML::PP::Reader::File::CORE:open
# spent 1.60ms making 1 call to PerlIO::import
# spent 113µs making 1 call to Encode::find_encoding
# spent 6µs making 1 call to Encode::Encoding::renew
# spent 1µs making 1 call to Encode::Encoding::needs_lines |
| 57 | 1 | 3µs | return $fh; | ||
| 58 | } | ||||
| 59 | |||||
| 60 | sub read { | ||||
| 61 | my $fh = $_[0]->{filehandle} ||= $_[0]->open_handle; | ||||
| 62 | if (wantarray) { | ||||
| 63 | my @yaml = <$fh>; | ||||
| 64 | return @yaml; | ||||
| 65 | } | ||||
| 66 | else { | ||||
| 67 | local $/; | ||||
| 68 | my $yaml = <$fh>; | ||||
| 69 | return $yaml; | ||||
| 70 | } | ||||
| 71 | } | ||||
| 72 | |||||
| 73 | # spent 78.4ms (40.5+37.9) within YAML::PP::Reader::File::readline which was called 13456 times, avg 6µs/call:
# 13456 times (40.5ms+37.9ms) by YAML::PP::Lexer::_fetch_next_line at line 141 of YAML/PP/Lexer.pm, avg 6µs/call | ||||
| 74 | 13456 | 5.88ms | 1 | 4.40ms | my $fh = $_[0]->{filehandle} ||= $_[0]->open_handle; # spent 4.40ms making 1 call to YAML::PP::Reader::File::open_handle |
| 75 | 13456 | 76.5ms | 14334 | 39.3ms | return scalar <$fh>; # spent 33.5ms making 13456 calls to YAML::PP::Reader::File::CORE:readline, avg 2µs/call
# spent 4.68ms making 439 calls to Encode::utf8::decode, avg 11µs/call
# spent 1.04ms making 439 calls to Encode::Encoding::renewed, avg 2µs/call |
| 76 | } | ||||
| 77 | |||||
| 78 | 1 | 3µs | 1; | ||
# spent 4.38ms (2.12+2.26) within YAML::PP::Reader::File::CORE:open which was called:
# once (2.12ms+2.26ms) by YAML::PP::Reader::File::open_handle at line 56 | |||||
# spent 33.5ms (28.9+4.68) within YAML::PP::Reader::File::CORE:readline which was called 13456 times, avg 2µs/call:
# 13456 times (28.9ms+4.68ms) by YAML::PP::Reader::File::readline at line 75, avg 2µs/call |