← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Thu Dec 15 15:23:56 2022
Reported on Thu Dec 15 15:27:04 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Reader.pm
StatementsExecuted 26744 statements in 59.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
133611129.1ms64.3msYAML::PP::Reader::File::::readlineYAML::PP::Reader::File::readline
133611117.9ms21.9msYAML::PP::Reader::File::::CORE:readlineYAML::PP::Reader::File::CORE:readline (opcode)
111203µs13.3msYAML::PP::Reader::File::::CORE:openYAML::PP::Reader::File::CORE:open (opcode)
11116µs18µsYAML::PP::Parser::::BEGIN@2.289 YAML::PP::Parser::BEGIN@2.289
11112µs13.4msYAML::PP::Reader::File::::open_handleYAML::PP::Reader::File::open_handle
1116µs23µsYAML::PP::Parser::::BEGIN@3.290 YAML::PP::Parser::BEGIN@3.290
1116µs29µsYAML::PP::Reader::File::::BEGIN@45YAML::PP::Reader::File::BEGIN@45
1116µs22µsYAML::PP::Reader::File::::BEGIN@49YAML::PP::Reader::File::BEGIN@49
2225µs5µsYAML::PP::Reader::::new YAML::PP::Reader::new
0000s0sYAML::PP::Reader::File::::readYAML::PP::Reader::File::read
0000s0sYAML::PP::Reader::::input YAML::PP::Reader::input
0000s0sYAML::PP::Reader::::read YAML::PP::Reader::read
0000s0sYAML::PP::Reader::::readline YAML::PP::Reader::readline
0000s0sYAML::PP::Reader::::set_input YAML::PP::Reader::set_input
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# ABSTRACT: Reader class for YAML::PP representing input data
2220µs220µs
# spent 18µs (16+2) within YAML::PP::Parser::BEGIN@2.289 which was called: # once (16µs+2µs) by YAML::PP::Parser::BEGIN@21 at line 2
use strict;
# spent 18µs making 1 call to YAML::PP::Parser::BEGIN@2.289 # spent 2µs making 1 call to strict::import
32300µs240µs
# spent 23µs (6+17) within YAML::PP::Parser::BEGIN@3.290 which was called: # once (6µs+17µs) by YAML::PP::Parser::BEGIN@21 at line 3
use warnings;
# spent 23µs making 1 call to YAML::PP::Parser::BEGIN@3.290 # spent 17µs making 1 call to warnings::import
4package YAML::PP::Reader;
5
611µsour $VERSION = '0.035'; # VERSION
7
8sub input { return $_[0]->{input} }
9sub set_input { $_[0]->{input} = $_[1] }
10
11
# spent 5µs within YAML::PP::Reader::new which was called 2 times, avg 2µs/call: # once (3µs+0s) by YAML::PP::Parser::new at line 27 of YAML/PP/Parser.pm # once (2µs+0s) by YAML::PP::Loader::load_file at line 84 of YAML/PP/Loader.pm
sub new {
1222µs my ($class, %args) = @_;
1320s my $input = delete $args{input};
1426µs return bless {
15 input => $input,
16 }, $class;
17}
18
19sub 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
27sub 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
43package YAML::PP::Reader::File;
44
45226µs252µs
# spent 29µs (6+23) within YAML::PP::Reader::File::BEGIN@45 which was called: # once (6µs+23µs) by YAML::PP::Parser::BEGIN@21 at line 45
use Scalar::Util qw/ openhandle /;
# spent 29µs making 1 call to YAML::PP::Reader::File::BEGIN@45 # spent 23µs making 1 call to Exporter::import
46
4716µsour @ISA = qw/ YAML::PP::Reader /;
48
492156µs238µs
# spent 22µs (6+16) within YAML::PP::Reader::File::BEGIN@49 which was called: # once (6µs+16µs) by YAML::PP::Parser::BEGIN@21 at line 49
use Carp qw/ croak /;
# spent 22µs making 1 call to YAML::PP::Reader::File::BEGIN@49 # spent 16µs making 1 call to Exporter::import
50
51
# spent 13.4ms (12µs+13.3) within YAML::PP::Reader::File::open_handle which was called: # once (12µs+13.3ms) by YAML::PP::Reader::File::readline at line 74
sub open_handle {
5216µs11µs if (openhandle( $_[0]->{input} )) {
# spent 1µs making 1 call to Scalar::Util::openhandle
53 return $_[0]->{input};
54 }
55 open my $fh, '<:encoding(UTF-8)', $_[0]->{input}
563722µs525.8ms or croak "Could not open '$_[0]->{input}' for reading: $!";
# spent 13.3ms making 1 call to YAML::PP::Reader::File::CORE:open # spent 12.4ms making 1 call to PerlIO::import # spent 112µ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
5715µs return $fh;
58}
59
60sub 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 64.3ms (29.1+35.2) within YAML::PP::Reader::File::readline which was called 13361 times, avg 5µs/call: # 13361 times (29.1ms+35.2ms) by YAML::PP::Lexer::_fetch_next_line at line 141 of YAML/PP/Lexer.pm, avg 5µs/call
sub readline {
74133613.89ms113.4ms my $fh = $_[0]->{filehandle} ||= $_[0]->open_handle;
# spent 13.4ms making 1 call to YAML::PP::Reader::File::open_handle
751336154.7ms1423326.8ms return scalar <$fh>;
# spent 21.9ms making 13361 calls to YAML::PP::Reader::File::CORE:readline, avg 2µs/call # spent 4.01ms making 436 calls to Encode::utf8::decode, avg 9µs/call # spent 868µs making 436 calls to Encode::Encoding::renewed, avg 2µs/call
76}
77
7813µs1;
 
# spent 13.3ms (203µs+13.1) within YAML::PP::Reader::File::CORE:open which was called: # once (203µs+13.1ms) by YAML::PP::Reader::File::open_handle at line 56
sub YAML::PP::Reader::File::CORE:open; # opcode
# spent 21.9ms (17.9+4.01) within YAML::PP::Reader::File::CORE:readline which was called 13361 times, avg 2µs/call: # 13361 times (17.9ms+4.01ms) by YAML::PP::Reader::File::readline at line 75, avg 2µs/call
sub YAML::PP::Reader::File::CORE:readline; # opcode