← 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/Loader.pm
StatementsExecuted 39 statements in 1.75ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1116.30ms18.8msYAML::PP::Loader::::BEGIN@8YAML::PP::Loader::BEGIN@8
1112.24ms2.44msYAML::PP::Loader::::BEGIN@9YAML::PP::Loader::BEGIN@9
11128µs114µsYAML::PP::Loader::::newYAML::PP::Loader::new
11127µs30µsYAML::PP::::BEGIN@2.285 YAML::PP::BEGIN@2.285
11117µs5.21sYAML::PP::Loader::::load_fileYAML::PP::Loader::load_file
11113µs5.21sYAML::PP::Loader::::loadYAML::PP::Loader::load
1116µs29µsYAML::PP::::BEGIN@3 YAML::PP::BEGIN@3
1116µs6µsYAML::PP::Loader::::BEGIN@10YAML::PP::Loader::BEGIN@10
2213µs3µsYAML::PP::Loader::::parserYAML::PP::Loader::parser
3312µs2µsYAML::PP::Loader::::__ANON__YAML::PP::Loader::__ANON__ (xsub)
0000s0sYAML::PP::Loader::::cloneYAML::PP::Loader::clone
1110s0sYAML::PP::Loader::::constructorYAML::PP::Loader::constructor
0000s0sYAML::PP::Loader::::filenameYAML::PP::Loader::filename
0000s0sYAML::PP::Loader::::load_stringYAML::PP::Loader::load_string
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# ABSTRACT: Load YAML into data with Parser and Constructor
2252µs233µs
# spent 30µs (27+3) within YAML::PP::BEGIN@2.285 which was called: # once (27µs+3µs) by YAML::PP::BEGIN@10 at line 2
use strict;
# spent 30µs making 1 call to YAML::PP::BEGIN@2.285 # spent 3µs making 1 call to strict::import
3232µs252µs
# spent 29µs (6+23) within YAML::PP::BEGIN@3 which was called: # once (6µs+23µs) by YAML::PP::BEGIN@10 at line 3
use warnings;
# spent 29µs making 1 call to YAML::PP::BEGIN@3 # spent 23µs making 1 call to warnings::import
4package YAML::PP::Loader;
5
611µsour $VERSION = '0.035'; # VERSION
7
82839µs218.8ms
# spent 18.8ms (6.30+12.5) within YAML::PP::Loader::BEGIN@8 which was called: # once (6.30ms+12.5ms) by YAML::PP::BEGIN@10 at line 8
use YAML::PP::Parser;
# spent 18.8ms making 1 call to YAML::PP::Loader::BEGIN@8 # spent 2µs making 1 call to YAML::PP::Loader::__ANON__
92497µs22.44ms
# spent 2.44ms (2.24+203µs) within YAML::PP::Loader::BEGIN@9 which was called: # once (2.24ms+203µs) by YAML::PP::BEGIN@10 at line 9
use YAML::PP::Constructor;
# spent 2.44ms making 1 call to YAML::PP::Loader::BEGIN@9 # spent 0s making 1 call to YAML::PP::Loader::__ANON__
102285µs26µs
# spent 6µs within YAML::PP::Loader::BEGIN@10 which was called: # once (6µs+0s) by YAML::PP::BEGIN@10 at line 10
use YAML::PP::Reader;
# spent 6µs making 1 call to YAML::PP::Loader::BEGIN@10 # spent 0s making 1 call to YAML::PP::Loader::__ANON__
11
12
# spent 114µs (28+86) within YAML::PP::Loader::new which was called: # once (28µs+86µs) by YAML::PP::new at line 65 of YAML/PP.pm
sub new {
1313µs my ($class, %args) = @_;
14
1511µs my $cyclic_refs = delete $args{cyclic_refs} || 'allow';
1610s my $default_yaml_version = delete $args{default_yaml_version} || '1.2';
1710s my $preserve = delete $args{preserve};
1810s my $duplicate_keys = delete $args{duplicate_keys};
1910s my $schemas = delete $args{schemas};
2010s $schemas ||= {
21 '1.2' => YAML::PP->default_schema(
22 boolean => 'perl',
23 )
24 };
25
2614µs152µs my $constructor = delete $args{constructor} || YAML::PP::Constructor->new(
# spent 52µs making 1 call to YAML::PP::Constructor::new
27 schemas => $schemas,
28 cyclic_refs => $cyclic_refs,
29 default_yaml_version => $default_yaml_version,
30 preserve => $preserve,
31 duplicate_keys => $duplicate_keys,
32 );
3310s my $parser = delete $args{parser};
3413µs129µs unless ($parser) {
# spent 29µs making 1 call to YAML::PP::Parser::new
35 $parser = YAML::PP::Parser->new(
36 default_yaml_version => $default_yaml_version,
37 );
38 }
3913µs25µs unless ($parser->receiver) {
# spent 4µs making 1 call to YAML::PP::Parser::set_receiver # spent 1µs making 1 call to YAML::PP::Parser::receiver
40 $parser->set_receiver($constructor);
41 }
42
4310s if (keys %args) {
44 die "Unexpected arguments: " . join ', ', sort keys %args;
45 }
4611µs my $self = bless {
47 parser => $parser,
48 constructor => $constructor,
49 }, $class;
5012µs return $self;
51}
52
53sub clone {
54 my ($self) = @_;
55 my $clone = {
56 parser => $self->parser->clone,
57 constructor => $self->constructor->clone,
58 };
59 bless $clone, ref $self;
60 $clone->parser->set_receiver($clone->constructor);
61 return $clone;
62}
63
6424µs
# spent 3µs within YAML::PP::Loader::parser which was called 2 times, avg 2µs/call: # once (2µs+0s) by YAML::PP::Loader::load_file at line 84 # once (1µs+0s) by YAML::PP::Loader::load at line 90
sub parser { return $_[0]->{parser} }
6511µs
# spent 0s within YAML::PP::Loader::constructor which was called: # once (0s+0s) by YAML::PP::Loader::load at line 91
sub constructor { return $_[0]->{constructor} }
66
67sub filename {
68 my ($self) = @_;
69 my $reader = $self->parser->reader;
70 if ($reader->isa('YAML::PP::Reader::File')) {
71 return $reader->input;
72 }
73 die "Reader is not a YAML::PP::Reader::File";
74}
75
76sub load_string {
77 my ($self, $yaml) = @_;
78 $self->parser->set_reader(YAML::PP::Reader->new( input => $yaml ));
79 $self->load();
80}
81
82
# spent 5.21s (17µs+5.21) within YAML::PP::Loader::load_file which was called: # once (17µs+5.21s) by YAML::PP::load_file at line 154 of YAML/PP.pm
sub load_file {
8311µs my ($self, $file) = @_;
8415µs316µs $self->parser->set_reader(YAML::PP::Reader::File->new( input => $file ));
# spent 12µs making 1 call to YAML::PP::Parser::set_reader # spent 2µs making 1 call to YAML::PP::Loader::parser # spent 2µs making 1 call to YAML::PP::Reader::new
8515µs15.21s $self->load();
# spent 5.21s making 1 call to YAML::PP::Loader::load
86}
87
88
# spent 5.21s (13µs+5.21) within YAML::PP::Loader::load which was called: # once (13µs+5.21s) by YAML::PP::Loader::load_file at line 85
sub load {
8910s my ($self) = @_;
9011µs11µs my $parser = $self->parser;
# spent 1µs making 1 call to YAML::PP::Loader::parser
9110s10s my $constructor = $self->constructor;
# spent 0s making 1 call to YAML::PP::Loader::constructor
92
9311µs117µs $constructor->init;
# spent 17µs making 1 call to YAML::PP::Constructor::init
9413µs15.21s $parser->parse();
# spent 5.21s making 1 call to YAML::PP::Parser::parse
95
9611µs10s my $docs = $constructor->docs;
# spent 0s making 1 call to YAML::PP::Constructor::docs
9716µs return wantarray ? @$docs : $docs->[0];
98}
99
100
10113µs1;
 
# spent 2µs within YAML::PP::Loader::__ANON__ which was called 3 times, avg 667ns/call: # once (2µs+0s) by YAML::PP::Loader::BEGIN@8 at line 8 # once (0s+0s) by YAML::PP::Loader::BEGIN@9 at line 9 # once (0s+0s) by YAML::PP::Loader::BEGIN@10 at line 10
sub YAML::PP::Loader::__ANON__; # xsub