← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:57:08 2022
Reported on Wed Dec 14 16:00:36 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Constructor.pm
StatementsExecuted 604683 statements in 721ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
2094111247ms1.05sYAML::PP::Constructor::::scalar_eventYAML::PP::Constructor::scalar_event
693911159ms223msYAML::PP::Constructor::::mapping_end_eventYAML::PP::Constructor::mapping_end_event
693911120ms188msYAML::PP::Constructor::::mapping_start_eventYAML::PP::Constructor::mapping_start_event
69391160.3ms60.3msYAML::PP::Constructor::::__ANON__[:218]YAML::PP::Constructor::__ANON__[:218]
361117121.4ms21.4msYAML::PP::Constructor::::stackYAML::PP::Constructor::stack
285253120.8ms20.8msYAML::PP::Constructor::::preserve_aliasYAML::PP::Constructor::preserve_alias
285253119.7ms19.7msYAML::PP::Constructor::::schemaYAML::PP::Constructor::schema
209411116.2ms16.2msYAML::PP::Constructor::::preserve_scalar_styleYAML::PP::Constructor::preserve_scalar_style
6451111.0ms12.8msYAML::PP::Constructor::::sequence_end_eventYAML::PP::Constructor::sequence_end_event
6451110.8ms16.8msYAML::PP::Constructor::::sequence_start_eventYAML::PP::Constructor::sequence_start_event
7584218.05ms8.05msYAML::PP::Constructor::::preserve_flow_styleYAML::PP::Constructor::preserve_flow_style
6939117.60ms7.60msYAML::PP::Constructor::::preserve_orderYAML::PP::Constructor::preserve_order
645111.52ms1.52msYAML::PP::Constructor::::__ANON__[:270]YAML::PP::Constructor::__ANON__[:270]
22253µs79µsYAML::PP::Constructor::::initYAML::PP::Constructor::init
11127µs31µsYAML::PP::Loader::::BEGIN@2.290 YAML::PP::Loader::BEGIN@2.290
11122µs67µsYAML::PP::Constructor::::newYAML::PP::Constructor::new
11118µs18µsYAML::PP::Constructor::::BEGIN@8YAML::PP::Constructor::BEGIN@8
11117µs23µsYAML::PP::Constructor::::document_end_eventYAML::PP::Constructor::document_end_event
1119µs11µsYAML::PP::Constructor::::document_start_eventYAML::PP::Constructor::document_start_event
2118µs8µsYAML::PP::Constructor::::set_docsYAML::PP::Constructor::set_docs
1116µs17µsYAML::PP::Constructor::::BEGIN@12YAML::PP::Constructor::BEGIN@12
1116µs38µsYAML::PP::Loader::::BEGIN@3.291 YAML::PP::Loader::BEGIN@3.291
1115µs56µsYAML::PP::Constructor::::BEGIN@15YAML::PP::Constructor::BEGIN@15
1115µs42µsYAML::PP::Constructor::::BEGIN@9YAML::PP::Constructor::BEGIN@9
1114µs12µsYAML::PP::Constructor::::BEGIN@13YAML::PP::Constructor::BEGIN@13
2114µs4µsYAML::PP::Constructor::::set_schemaYAML::PP::Constructor::set_schema
3214µs4µsYAML::PP::Constructor::::set_stackYAML::PP::Constructor::set_stack
1113µs19µsYAML::PP::Constructor::::BEGIN@16YAML::PP::Constructor::BEGIN@16
2113µs3µsYAML::PP::Constructor::::default_yaml_versionYAML::PP::Constructor::default_yaml_version
2223µs3µsYAML::PP::Constructor::::docsYAML::PP::Constructor::docs
2113µs3µsYAML::PP::Constructor::::schemasYAML::PP::Constructor::schemas
3213µs3µsYAML::PP::Constructor::::set_anchorsYAML::PP::Constructor::set_anchors
2112µs2µsYAML::PP::Constructor::::set_yaml_versionYAML::PP::Constructor::set_yaml_version
1112µs2µsYAML::PP::Constructor::::stream_end_eventYAML::PP::Constructor::stream_end_event
2112µs2µsYAML::PP::Constructor::::yaml_versionYAML::PP::Constructor::yaml_version
1110s0sYAML::PP::Constructor::::__ANON__YAML::PP::Constructor::__ANON__ (xsub)
0000s0sYAML::PP::Constructor::::alias_eventYAML::PP::Constructor::alias_event
0000s0sYAML::PP::Constructor::::anchorsYAML::PP::Constructor::anchors
0000s0sYAML::PP::Constructor::::cloneYAML::PP::Constructor::clone
0000s0sYAML::PP::Constructor::::cyclic_refsYAML::PP::Constructor::cyclic_refs
0000s0sYAML::PP::Constructor::::duplicate_keysYAML::PP::Constructor::duplicate_keys
0000s0sYAML::PP::Constructor::::set_cyclic_refsYAML::PP::Constructor::set_cyclic_refs
1110s0sYAML::PP::Constructor::::stream_start_eventYAML::PP::Constructor::stream_start_event
0000s0sYAML::PP::Constructor::::stringify_complexYAML::PP::Constructor::stringify_complex
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# ABSTRACT: Construct data structure from Parser Events
2228µs235µs
# spent 31µs (27+4) within YAML::PP::Loader::BEGIN@2.290 which was called: # once (27µs+4µs) by YAML::PP::Loader::BEGIN@9 at line 2
use strict;
# spent 31µs making 1 call to YAML::PP::Loader::BEGIN@2.290 # spent 4µs making 1 call to strict::import
3231µs270µs
# spent 38µs (6+32) within YAML::PP::Loader::BEGIN@3.291 which was called: # once (6µs+32µs) by YAML::PP::Loader::BEGIN@9 at line 3
use warnings;
# spent 38µs making 1 call to YAML::PP::Loader::BEGIN@3.291 # spent 32µs making 1 call to warnings::import
4package YAML::PP::Constructor;
5
611µsour $VERSION = '0.035'; # VERSION
7
8234µs218µs
# spent 18µs within YAML::PP::Constructor::BEGIN@8 which was called: # once (18µs+0s) by YAML::PP::Loader::BEGIN@9 at line 8
use YAML::PP;
# spent 18µs making 1 call to YAML::PP::Constructor::BEGIN@8 # spent 0s making 1 call to YAML::PP::Constructor::__ANON__
910s
# spent 42µs (5+37) within YAML::PP::Constructor::BEGIN@9 which was called: # once (5µs+37µs) by YAML::PP::Loader::BEGIN@9 at line 11
use YAML::PP::Common qw/
10 PRESERVE_ORDER PRESERVE_SCALAR_STYLE PRESERVE_FLOW_STYLE PRESERVE_ALIAS
11117µs279µs/;
# spent 42µs making 1 call to YAML::PP::Constructor::BEGIN@9 # spent 37µs making 1 call to Exporter::import
12217µs228µs
# spent 17µs (6+11) within YAML::PP::Constructor::BEGIN@12 which was called: # once (6µs+11µs) by YAML::PP::Loader::BEGIN@9 at line 12
use Scalar::Util qw/ reftype /;
# spent 17µs making 1 call to YAML::PP::Constructor::BEGIN@12 # spent 11µs making 1 call to Exporter::import
13225µs220µs
# spent 12µs (4+8) within YAML::PP::Constructor::BEGIN@13 which was called: # once (4µs+8µs) by YAML::PP::Loader::BEGIN@9 at line 13
use Carp qw/ croak /;
# spent 12µs making 1 call to YAML::PP::Constructor::BEGIN@13 # spent 8µs making 1 call to Exporter::import
14
15225µs2107µs
# spent 56µs (5+51) within YAML::PP::Constructor::BEGIN@15 which was called: # once (5µs+51µs) by YAML::PP::Loader::BEGIN@9 at line 15
use constant DEBUG => ($ENV{YAML_PP_LOAD_DEBUG} or $ENV{YAML_PP_LOAD_TRACE}) ? 1 : 0;
# spent 56µs making 1 call to YAML::PP::Constructor::BEGIN@15 # spent 51µs making 1 call to constant::import
1621.83ms235µs
# spent 19µs (3+16) within YAML::PP::Constructor::BEGIN@16 which was called: # once (3µs+16µs) by YAML::PP::Loader::BEGIN@9 at line 16
use constant TRACE => $ENV{YAML_PP_LOAD_TRACE} ? 1 : 0;
# spent 19µs making 1 call to YAML::PP::Constructor::BEGIN@16 # spent 16µs making 1 call to constant::import
17
1814µsmy %cyclic_refs = qw/ allow 1 ignore 1 warn 1 fatal 1 /;
19
20
# spent 67µs (22+45) within YAML::PP::Constructor::new which was called: # once (22µs+45µs) by YAML::PP::Loader::new at line 26 of YAML/PP/Loader.pm
sub new {
2112µs my ($class, %args) = @_;
22
2311µs my $default_yaml_version = delete $args{default_yaml_version};
2411µs my $duplicate_keys = delete $args{duplicate_keys};
2511µs unless (defined $duplicate_keys) {
26 $duplicate_keys = 0;
27 }
2811µs my $preserve = delete $args{preserve} || 0;
2911µs if ($preserve == 1) {
30 $preserve = PRESERVE_ORDER | PRESERVE_SCALAR_STYLE | PRESERVE_FLOW_STYLE | PRESERVE_ALIAS;
31 }
3211µs my $cyclic_refs = delete $args{cyclic_refs} || 'allow';
33 die "Invalid value for cyclic_refs: $cyclic_refs"
3411µs unless $cyclic_refs{ $cyclic_refs };
3511µs my $schemas = delete $args{schemas};
36
3711µs if (keys %args) {
38 die "Unexpected arguments: " . join ', ', sort keys %args;
39 }
40
4113µs my $self = bless {
42 default_yaml_version => $default_yaml_version,
43 schemas => $schemas,
44 cyclic_refs => $cyclic_refs,
45 preserve => $preserve,
46 duplicate_keys => $duplicate_keys,
47 }, $class;
4812µs145µs $self->init;
# spent 45µs making 1 call to YAML::PP::Constructor::init
4914µs return $self;
50}
51
52sub clone {
53 my ($self) = @_;
54 my $clone = {
55 schemas => $self->{schemas},
56 schema => $self->{schema},
57 default_yaml_version => $self->{default_yaml_version},
58 cyclic_refs => $self->cyclic_refs,
59 preserve => $self->{preserve},
60 };
61 return bless $clone, ref $self;
62}
63
64
# spent 79µs (53+26) within YAML::PP::Constructor::init which was called 2 times, avg 40µs/call: # once (31µs+14µs) by YAML::PP::Constructor::new at line 48 # once (22µs+12µs) by YAML::PP::Loader::load at line 93 of YAML/PP/Loader.pm
sub init {
6521µs my ($self) = @_;
6626µs28µs $self->set_docs([]);
# spent 8µs making 2 calls to YAML::PP::Constructor::set_docs, avg 4µs/call
6722µs23µs $self->set_stack([]);
# spent 3µs making 2 calls to YAML::PP::Constructor::set_stack, avg 2µs/call
6822µs21µs $self->set_anchors({});
# spent 1µs making 2 calls to YAML::PP::Constructor::set_anchors, avg 500ns/call
6925µs45µs $self->set_yaml_version($self->default_yaml_version);
# spent 3µs making 2 calls to YAML::PP::Constructor::default_yaml_version, avg 2µs/call # spent 2µs making 2 calls to YAML::PP::Constructor::set_yaml_version, avg 1µs/call
70215µs69µs $self->set_schema($self->schemas->{ $self->yaml_version } );
# spent 4µs making 2 calls to YAML::PP::Constructor::set_schema, avg 2µs/call # spent 3µs making 2 calls to YAML::PP::Constructor::schemas, avg 2µs/call # spent 2µs making 2 calls to YAML::PP::Constructor::yaml_version, avg 1µs/call
71}
72
7324µs
# spent 3µs within YAML::PP::Constructor::docs which was called 2 times, avg 2µs/call: # once (2µs+0s) by YAML::PP::Constructor::document_end_event at line 120 # once (1µs+0s) by YAML::PP::Loader::load at line 96 of YAML/PP/Loader.pm
sub docs { return $_[0]->{docs} }
743611155.3ms
# spent 21.4ms within YAML::PP::Constructor::stack which was called 36111 times, avg 592ns/call: # 20941 times (13.5ms+0s) by YAML::PP::Constructor::scalar_event at line 288, avg 645ns/call # 6939 times (4.23ms+0s) by YAML::PP::Constructor::mapping_start_event at line 136, avg 610ns/call # 6939 times (2.97ms+0s) by YAML::PP::Constructor::mapping_end_event at line 164, avg 427ns/call # 645 times (388µs+0s) by YAML::PP::Constructor::sequence_start_event at line 237, avg 602ns/call # 645 times (270µs+0s) by YAML::PP::Constructor::sequence_end_event at line 262, avg 419ns/call # once (2µs+0s) by YAML::PP::Constructor::document_start_event at line 95 # once (1µs+0s) by YAML::PP::Constructor::document_end_event at line 114
sub stack { return $_[0]->{stack} }
75sub anchors { return $_[0]->{anchors} }
76211µs
# spent 8µs within YAML::PP::Constructor::set_docs which was called 2 times, avg 4µs/call: # 2 times (8µs+0s) by YAML::PP::Constructor::init at line 66, avg 4µs/call
sub set_docs { $_[0]->{docs} = $_[1] }
7738µs
# spent 4µs within YAML::PP::Constructor::set_stack which was called 3 times, avg 1µs/call: # 2 times (3µs+0s) by YAML::PP::Constructor::init at line 67, avg 2µs/call # once (1µs+0s) by YAML::PP::Constructor::document_end_event at line 123
sub set_stack { $_[0]->{stack} = $_[1] }
7839µs
# spent 3µs within YAML::PP::Constructor::set_anchors which was called 3 times, avg 1µs/call: # 2 times (1µs+0s) by YAML::PP::Constructor::init at line 68, avg 500ns/call # once (2µs+0s) by YAML::PP::Constructor::document_end_event at line 122
sub set_anchors { $_[0]->{anchors} = $_[1] }
7925µs
# spent 3µs within YAML::PP::Constructor::schemas which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by YAML::PP::Constructor::init at line 70, avg 2µs/call
sub schemas { return $_[0]->{schemas} }
802852544.3ms
# spent 19.7ms within YAML::PP::Constructor::schema which was called 28525 times, avg 692ns/call: # 20941 times (13.8ms+0s) by YAML::PP::Constructor::scalar_event at line 287, avg 658ns/call # 6939 times (5.52ms+0s) by YAML::PP::Constructor::mapping_start_event at line 128, avg 795ns/call # 645 times (435µs+0s) by YAML::PP::Constructor::sequence_start_event at line 229, avg 674ns/call
sub schema { return $_[0]->{schema} }
8127µs
# spent 4µs within YAML::PP::Constructor::set_schema which was called 2 times, avg 2µs/call: # 2 times (4µs+0s) by YAML::PP::Constructor::init at line 70, avg 2µs/call
sub set_schema { $_[0]->{schema} = $_[1] }
82sub cyclic_refs { return $_[0]->{cyclic_refs} }
83sub set_cyclic_refs { $_[0]->{cyclic_refs} = $_[1] }
8424µs
# spent 2µs within YAML::PP::Constructor::yaml_version which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by YAML::PP::Constructor::init at line 70, avg 1µs/call
sub yaml_version { return $_[0]->{yaml_version} }
8524µs
# spent 2µs within YAML::PP::Constructor::set_yaml_version which was called 2 times, avg 1µs/call: # 2 times (2µs+0s) by YAML::PP::Constructor::init at line 69, avg 1µs/call
sub set_yaml_version { $_[0]->{yaml_version} = $_[1] }
86210µs
# spent 3µs within YAML::PP::Constructor::default_yaml_version which was called 2 times, avg 2µs/call: # 2 times (3µs+0s) by YAML::PP::Constructor::init at line 69, avg 2µs/call
sub default_yaml_version { return $_[0]->{default_yaml_version} }
87693914.3ms
# spent 7.60ms within YAML::PP::Constructor::preserve_order which was called 6939 times, avg 1µs/call: # 6939 times (7.60ms+0s) by YAML::PP::Constructor::mapping_start_event at line 138, avg 1µs/call
sub preserve_order { return $_[0]->{preserve} & PRESERVE_ORDER }
882094134.1ms
# spent 16.2ms within YAML::PP::Constructor::preserve_scalar_style which was called 20941 times, avg 771ns/call: # 20941 times (16.2ms+0s) by YAML::PP::Constructor::scalar_event at line 290, avg 771ns/call
sub preserve_scalar_style { return $_[0]->{preserve} & PRESERVE_SCALAR_STYLE }
89758413.0ms
# spent 8.05ms within YAML::PP::Constructor::preserve_flow_style which was called 7584 times, avg 1µs/call: # 6939 times (7.37ms+0s) by YAML::PP::Constructor::mapping_start_event at line 139, avg 1µs/call # 645 times (677µs+0s) by YAML::PP::Constructor::sequence_start_event at line 239, avg 1µs/call
sub preserve_flow_style { return $_[0]->{preserve} & PRESERVE_FLOW_STYLE }
902852545.9ms
# spent 20.8ms within YAML::PP::Constructor::preserve_alias which was called 28525 times, avg 729ns/call: # 20941 times (16.5ms+0s) by YAML::PP::Constructor::scalar_event at line 289, avg 786ns/call # 6939 times (3.98ms+0s) by YAML::PP::Constructor::mapping_start_event at line 140, avg 574ns/call # 645 times (334µs+0s) by YAML::PP::Constructor::sequence_start_event at line 240, avg 518ns/call
sub preserve_alias { return $_[0]->{preserve} & PRESERVE_ALIAS }
91sub duplicate_keys { return $_[0]->{duplicate_keys} }
92
93
# spent 11µs (9+2) within YAML::PP::Constructor::document_start_event which was called: # once (9µs+2µs) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm
sub document_start_event {
9411µs my ($self, $event) = @_;
9512µs12µs my $stack = $self->stack;
# spent 2µs making 1 call to YAML::PP::Constructor::stack
9610s if ($event->{version_directive}) {
97 my $version = $event->{version_directive};
98 $version = "$version->{major}.$version->{minor}";
99 if ($self->{schemas}->{ $version }) {
100 $self->set_yaml_version($version);
101 $self->set_schema($self->schemas->{ $version });
102 }
103 else {
104 $self->set_yaml_version($self->default_yaml_version);
105 $self->set_schema($self->schemas->{ $self->default_yaml_version });
106 }
107 }
10810s my $ref = [];
10915µs push @$stack, { type => 'document', ref => $ref, data => $ref, event => $event };
110}
111
112
# spent 23µs (17+6) within YAML::PP::Constructor::document_end_event which was called: # once (17µs+6µs) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm
sub document_end_event {
11311µs my ($self, $event) = @_;
11412µs11µs my $stack = $self->stack;
# spent 1µs making 1 call to YAML::PP::Constructor::stack
11510s my $last = pop @$stack;
11611µs $last->{type} eq 'document' or die "Expected mapping, but got $last->{type}";
11710s if (@$stack) {
118 die "Got unexpected end of document";
119 }
12011µs12µs my $docs = $self->docs;
# spent 2µs making 1 call to YAML::PP::Constructor::docs
12110s push @$docs, $last->{ref}->[0];
12212µs12µs $self->set_anchors({});
# spent 2µs making 1 call to YAML::PP::Constructor::set_anchors
12314µs11µs $self->set_stack([]);
# spent 1µs making 1 call to YAML::PP::Constructor::set_stack
124}
125
126
# spent 188ms (120+68.1) within YAML::PP::Constructor::mapping_start_event which was called 6939 times, avg 27µs/call: # 6939 times (120ms+68.1ms) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm, avg 27µs/call
sub mapping_start_event {
12769392.14ms my ($self, $event) = @_;
128693919.2ms1387844.9ms my ($data, $on_data) = $self->schema->create_mapping($self, $event);
# spent 39.3ms making 6939 calls to YAML::PP::Schema::create_mapping, avg 6µs/call # spent 5.52ms making 6939 calls to YAML::PP::Constructor::schema, avg 795ns/call
129693919.1ms my $ref = {
130 type => 'mapping',
131 ref => [],
132 data => \$data,
133 event => $event,
134 on_data => $on_data,
135 };
13669396.41ms69394.23ms my $stack = $self->stack;
# spent 4.23ms making 6939 calls to YAML::PP::Constructor::stack, avg 610ns/call
137
13869398.51ms69397.60ms my $preserve_order = $self->preserve_order;
# spent 7.60ms making 6939 calls to YAML::PP::Constructor::preserve_order, avg 1µs/call
13969397.57ms69397.37ms my $preserve_style = $self->preserve_flow_style;
# spent 7.37ms making 6939 calls to YAML::PP::Constructor::preserve_flow_style, avg 1µs/call
14069395.94ms69393.98ms my $preserve_alias = $self->preserve_alias;
# spent 3.98ms making 6939 calls to YAML::PP::Constructor::preserve_alias, avg 574ns/call
14169391.97ms if (($preserve_order or $preserve_style or $preserve_alias) and not tied(%$data)) {
142 tie %$data, 'YAML::PP::Preserve::Hash', %$data;
143 }
14469391.40ms if ($preserve_style) {
145 my $t = tied %$data;
146 $t->{style} = $event->{style};
147 }
148
14969392.18ms push @$stack, $ref;
150693916.4ms if (defined(my $anchor = $event->{anchor})) {
151 if ($preserve_alias) {
152 my $t = tied %$data;
153 unless (exists $self->anchors->{ $anchor }) {
154 # Repeated anchors cannot be preserved
155 $t->{alias} = $anchor;
156 }
157 }
158 $self->anchors->{ $anchor } = { data => $ref->{data} };
159 }
160}
161
162
# spent 223ms (159+63.3) within YAML::PP::Constructor::mapping_end_event which was called 6939 times, avg 32µs/call: # 6939 times (159ms+63.3ms) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm, avg 32µs/call
sub mapping_end_event {
16369391.57ms my ($self, $event) = @_;
16469395.21ms69392.97ms my $stack = $self->stack;
# spent 2.97ms making 6939 calls to YAML::PP::Constructor::stack, avg 427ns/call
165
16669391.98ms my $last = pop @$stack;
16769395.09ms my ($ref, $data) = @{ $last }{qw/ ref data /};
16869392.64ms $last->{type} eq 'mapping' or die "Expected mapping, but got $last->{type}";
169
17069391.56ms my @merge_keys;
171 my @ref;
17269399.92ms for (my $i = 0; $i < @$ref; $i += 2) {
173134446.93ms my $key = $ref->[ $i ];
174134444.59ms if (ref $key eq 'YAML::PP::Type::MergeKey') {
175 my $merge = $ref->[ $i + 1 ];
176 if ((reftype($merge) || '') eq 'HASH') {
177 push @merge_keys, $merge;
178 }
179 elsif ((reftype($merge) || '') eq 'ARRAY') {
180 for my $item (@$merge) {
181 if ((reftype($item) || '') eq 'HASH') {
182 push @merge_keys, $item;
183 }
184 else {
185 die "Expected hash for merge key";
186 }
187 }
188 }
189 else {
190 die "Expected hash or array for merge key";
191 }
192 }
193 else {
194134446.99ms push @ref, $key, $ref->[ $i + 1 ];
195 }
196 }
19769393.63ms for my $merge (@merge_keys) {
198 for my $key (keys %$merge) {
199 unless (exists $$data->{ $key }) {
200 $$data->{ $key } = $merge->{ $key };
201 }
202 }
203 }
204
# spent 60.3ms within YAML::PP::Constructor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Constructor.pm:218] which was called 6939 times, avg 9µs/call: # 6939 times (60.3ms+0s) by YAML::PP::Constructor::mapping_end_event at line 219, avg 9µs/call
my $on_data = $last->{on_data} || sub {
20569391.76ms my ($self, $hash, $items) = @_;
20669391.29ms my %seen;
207693943.7ms for (my $i = 0; $i < @$items; $i += 2) {
208134447.84ms my ($key, $value) = @$items[ $i, $i + 1 ];
209134441.99ms $key = '' unless defined $key;
210134441.31ms if (ref $key) {
211 $key = $self->stringify_complex($key);
212 }
2131344417.4ms if ($seen{ $key }++ and not $self->duplicate_keys) {
214 croak "Duplicate key '$key'";
215 }
2161344410.7ms $$hash->{ $key } = $value;
217 }
218693920.5ms };
21969397.37ms693960.3ms $on_data->($self, $data, \@ref);
# spent 60.3ms making 6939 calls to YAML::PP::Constructor::__ANON__[YAML/PP/Constructor.pm:218], avg 9µs/call
22069396.89ms push @{ $stack->[-1]->{ref} }, $$data;
22169393.50ms if (defined(my $anchor = $last->{event}->{anchor})) {
222 $self->anchors->{ $anchor }->{finished} = 1;
223 }
224693946.2ms return;
225}
226
227
# spent 16.8ms (10.8+5.99) within YAML::PP::Constructor::sequence_start_event which was called 645 times, avg 26µs/call: # 645 times (10.8ms+5.99ms) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm, avg 26µs/call
sub sequence_start_event {
228645292µs my ($self, $event) = @_;
2296451.95ms12904.59ms my ($data, $on_data) = $self->schema->create_sequence($self, $event);
# spent 4.15ms making 645 calls to YAML::PP::Schema::create_sequence, avg 6µs/call # spent 435µs making 645 calls to YAML::PP::Constructor::schema, avg 674ns/call
2306451.87ms my $ref = {
231 type => 'sequence',
232 ref => [],
233 data => \$data,
234 event => $event,
235 on_data => $on_data,
236 };
237645637µs645388µs my $stack = $self->stack;
# spent 388µs making 645 calls to YAML::PP::Constructor::stack, avg 602ns/call
238
239645968µs645677µs my $preserve_style = $self->preserve_flow_style;
# spent 677µs making 645 calls to YAML::PP::Constructor::preserve_flow_style, avg 1µs/call
240645603µs645334µs my $preserve_alias = $self->preserve_alias;
# spent 334µs making 645 calls to YAML::PP::Constructor::preserve_alias, avg 518ns/call
241645384µs if ($preserve_style or $preserve_alias and not tied(@$data)) {
242 tie @$data, 'YAML::PP::Preserve::Array', @$data;
243 my $t = tied @$data;
244 $t->{style} = $event->{style};
245 }
246
247645281µs push @$stack, $ref;
2486451.76ms if (defined(my $anchor = $event->{anchor})) {
249 if ($preserve_alias) {
250 my $t = tied @$data;
251 unless (exists $self->anchors->{ $anchor }) {
252 # Repeated anchors cannot be preserved
253 $t->{alias} = $anchor;
254 }
255 }
256 $self->anchors->{ $anchor } = { data => $ref->{data} };
257 }
258}
259
260
# spent 12.8ms (11.0+1.79) within YAML::PP::Constructor::sequence_end_event which was called 645 times, avg 20µs/call: # 645 times (11.0ms+1.79ms) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm, avg 20µs/call
sub sequence_end_event {
261645347µs my ($self, $event) = @_;
262645685µs645270µs my $stack = $self->stack;
# spent 270µs making 645 calls to YAML::PP::Constructor::stack, avg 419ns/call
263645356µs my $last = pop @$stack;
264645503µs $last->{type} eq 'sequence' or die "Expected mapping, but got $last->{type}";
265645644µs my ($ref, $data) = @{ $last }{qw/ ref data /};
266
267
# spent 1.52ms within YAML::PP::Constructor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Constructor.pm:270] which was called 645 times, avg 2µs/call: # 645 times (1.52ms+0s) by YAML::PP::Constructor::sequence_end_event at line 271, avg 2µs/call
my $on_data = $last->{on_data} || sub {
268645154µs my ($self, $array, $items) = @_;
2696452.74ms push @$$array, @$items;
2706451.95ms };
271645702µs6451.52ms $on_data->($self, $data, $ref);
# spent 1.52ms making 645 calls to YAML::PP::Constructor::__ANON__[YAML/PP/Constructor.pm:270], avg 2µs/call
272645535µs push @{ $stack->[-1]->{ref} }, $$data;
273645386µs if (defined(my $anchor = $last->{event}->{anchor})) {
274 my $test = $self->anchors->{ $anchor };
275 $self->anchors->{ $anchor }->{finished} = 1;
276 }
2776453.44ms return;
278}
279
28013µs
# spent 0s within YAML::PP::Constructor::stream_start_event which was called: # once (0s+0s) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm
sub stream_start_event {}
281
28212µs
# spent 2µs within YAML::PP::Constructor::stream_end_event which was called: # once (2µs+0s) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm
sub stream_end_event {}
283
284
# spent 1.05s (247ms+807ms) within YAML::PP::Constructor::scalar_event which was called 20941 times, avg 50µs/call: # 20941 times (247ms+807ms) by YAML::PP::Parser::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Parser.pm:62] at line 61 of YAML/PP/Parser.pm, avg 50µs/call
sub scalar_event {
285209414.59ms my ($self, $event) = @_;
286 DEBUG and warn "CONTENT $event->{value} ($event->{style})\n";
2872094144.4ms41882761ms my $value = $self->schema->load_scalar($self, $event);
# spent 747ms making 20941 calls to YAML::PP::Schema::load_scalar, avg 36µs/call # spent 13.8ms making 20941 calls to YAML::PP::Constructor::schema, avg 658ns/call
2882094122.9ms2094113.5ms my $last = $self->stack->[-1];
# spent 13.5ms making 20941 calls to YAML::PP::Constructor::stack, avg 645ns/call
2892094117.8ms2094116.5ms my $preserve_alias = $self->preserve_alias;
# spent 16.5ms making 20941 calls to YAML::PP::Constructor::preserve_alias, avg 786ns/call
2902094120.3ms2094116.2ms my $preserve_style = $self->preserve_scalar_style;
# spent 16.2ms making 20941 calls to YAML::PP::Constructor::preserve_scalar_style, avg 771ns/call
291209415.57ms if (($preserve_style or $preserve_alias) and not ref $value) {
292 my %args = (
293 value => $value,
294 tag => $event->{tag},
295 );
296 if ($preserve_style) {
297 $args{style} = $event->{style};
298 }
299 if ($preserve_alias and defined $event->{anchor}) {
300 my $anchor = $event->{anchor};
301 unless (exists $self->anchors->{ $anchor }) {
302 # Repeated anchors cannot be preserved
303 $args{alias} = $event->{anchor};
304 }
305 }
306 $value = YAML::PP::Preserve::Scalar->new( %args );
307 }
308209418.32ms if (defined (my $name = $event->{anchor})) {
309 $self->anchors->{ $name } = { data => \$value, finished => 1 };
310 }
3112094155.6ms push @{ $last->{ref} }, $value;
312}
313
314sub alias_event {
315 my ($self, $event) = @_;
316 my $value;
317 my $name = $event->{value};
318 if (my $anchor = $self->anchors->{ $name }) {
319 # We know this is a cyclic ref since the node hasn't
320 # been constructed completely yet
321 unless ($anchor->{finished} ) {
322 my $cyclic_refs = $self->cyclic_refs;
323 if ($cyclic_refs ne 'allow') {
324 if ($cyclic_refs eq 'fatal') {
325 die "Found cyclic ref for alias '$name'";
326 }
327 if ($cyclic_refs eq 'warn') {
328 $anchor = { data => \undef };
329 warn "Found cyclic ref for alias '$name'";
330 }
331 elsif ($cyclic_refs eq 'ignore') {
332 $anchor = { data => \undef };
333 }
334 }
335 }
336 $value = $anchor->{data};
337 }
338 else {
339 croak "No anchor defined for alias '$name'";
340 }
341 my $last = $self->stack->[-1];
342 push @{ $last->{ref} }, $$value;
343}
344
345sub stringify_complex {
346 my ($self, $data) = @_;
347 return $data if (
348 ref $data eq 'YAML::PP::Preserve::Scalar'
349 and ($self->preserve_scalar_style or $self->preserve_alias)
350 );
351 require Data::Dumper;
352 local $Data::Dumper::Quotekeys = 0;
353 local $Data::Dumper::Terse = 1;
354 local $Data::Dumper::Indent = 0;
355 local $Data::Dumper::Useqq = 0;
356 local $Data::Dumper::Sortkeys = 1;
357 my $string = Data::Dumper->Dump([$data], ['data']);
358 $string =~ s/^\$data = //;
359 return $string;
360}
361
36215µs1;
363
364__END__
 
# spent 0s within YAML::PP::Constructor::__ANON__ which was called: # once (0s+0s) by YAML::PP::Constructor::BEGIN@8 at line 8
sub YAML::PP::Constructor::__ANON__; # xsub