Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Constructor.pm |
Statements | Executed 600278 statements in 543ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
20764 | 1 | 1 | 200ms | 709ms | scalar_event | YAML::PP::Constructor::
6900 | 1 | 1 | 103ms | 152ms | mapping_end_event | YAML::PP::Constructor::
6900 | 1 | 1 | 101ms | 147ms | mapping_start_event | YAML::PP::Constructor::
6900 | 1 | 1 | 45.9ms | 45.9ms | __ANON__[:218] | YAML::PP::Constructor::
35838 | 7 | 1 | 15.4ms | 15.4ms | stack | YAML::PP::Constructor::
28300 | 3 | 1 | 14.4ms | 14.4ms | preserve_alias | YAML::PP::Constructor::
28300 | 3 | 1 | 13.8ms | 13.8ms | schema | YAML::PP::Constructor::
20764 | 1 | 1 | 10.2ms | 10.2ms | preserve_scalar_style | YAML::PP::Constructor::
636 | 1 | 1 | 8.30ms | 12.7ms | sequence_start_event | YAML::PP::Constructor::
636 | 1 | 1 | 7.63ms | 9.04ms | sequence_end_event | YAML::PP::Constructor::
6900 | 1 | 1 | 4.75ms | 4.75ms | preserve_order | YAML::PP::Constructor::
7536 | 2 | 1 | 4.56ms | 4.56ms | preserve_flow_style | YAML::PP::Constructor::
636 | 1 | 1 | 1.18ms | 1.18ms | __ANON__[:270] | YAML::PP::Constructor::
2 | 2 | 2 | 38µs | 55µs | init | YAML::PP::Constructor::
1 | 1 | 1 | 27µs | 31µs | BEGIN@2.291 | YAML::PP::Loader::
1 | 1 | 1 | 17µs | 19µs | document_end_event | YAML::PP::Constructor::
1 | 1 | 1 | 14µs | 52µs | new | YAML::PP::Constructor::
1 | 1 | 1 | 11µs | 11µs | BEGIN@8 | YAML::PP::Constructor::
1 | 1 | 1 | 8µs | 9µs | document_start_event | YAML::PP::Constructor::
1 | 1 | 1 | 7µs | 45µs | BEGIN@15 | YAML::PP::Constructor::
1 | 1 | 1 | 6µs | 18µs | BEGIN@12 | YAML::PP::Constructor::
1 | 1 | 1 | 6µs | 32µs | BEGIN@9 | YAML::PP::Constructor::
2 | 1 | 1 | 6µs | 6µs | set_docs | YAML::PP::Constructor::
1 | 1 | 1 | 6µs | 34µs | BEGIN@3.292 | YAML::PP::Loader::
1 | 1 | 1 | 5µs | 21µs | BEGIN@16 | YAML::PP::Constructor::
1 | 1 | 1 | 3µs | 11µs | BEGIN@13 | YAML::PP::Constructor::
2 | 1 | 1 | 2µs | 2µs | schemas | YAML::PP::Constructor::
3 | 2 | 1 | 2µs | 2µs | set_anchors | YAML::PP::Constructor::
2 | 1 | 1 | 2µs | 2µs | set_schema | YAML::PP::Constructor::
2 | 1 | 1 | 2µs | 2µs | set_yaml_version | YAML::PP::Constructor::
2 | 1 | 1 | 2µs | 2µs | yaml_version | YAML::PP::Constructor::
2 | 1 | 1 | 1µs | 1µs | default_yaml_version | YAML::PP::Constructor::
2 | 2 | 2 | 1µs | 1µs | docs | YAML::PP::Constructor::
3 | 2 | 1 | 1µs | 1µs | set_stack | YAML::PP::Constructor::
1 | 1 | 1 | 1µs | 1µs | stream_end_event | YAML::PP::Constructor::
1 | 1 | 1 | 1µs | 1µs | stream_start_event | YAML::PP::Constructor::
1 | 1 | 1 | 0s | 0s | __ANON__ (xsub) | YAML::PP::Constructor::
0 | 0 | 0 | 0s | 0s | alias_event | YAML::PP::Constructor::
0 | 0 | 0 | 0s | 0s | anchors | YAML::PP::Constructor::
0 | 0 | 0 | 0s | 0s | clone | YAML::PP::Constructor::
0 | 0 | 0 | 0s | 0s | cyclic_refs | YAML::PP::Constructor::
0 | 0 | 0 | 0s | 0s | duplicate_keys | YAML::PP::Constructor::
0 | 0 | 0 | 0s | 0s | set_cyclic_refs | YAML::PP::Constructor::
0 | 0 | 0 | 0s | 0s | stringify_complex | YAML::PP::Constructor::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # ABSTRACT: Construct data structure from Parser Events | ||||
2 | 2 | 30µs | 2 | 35µs | # spent 31µs (27+4) within YAML::PP::Loader::BEGIN@2.291 which was called:
# once (27µs+4µs) by YAML::PP::Loader::BEGIN@9 at line 2 # spent 31µs making 1 call to YAML::PP::Loader::BEGIN@2.291
# spent 4µs making 1 call to strict::import |
3 | 2 | 35µs | 2 | 62µs | # spent 34µs (6+28) within YAML::PP::Loader::BEGIN@3.292 which was called:
# once (6µs+28µs) by YAML::PP::Loader::BEGIN@9 at line 3 # spent 34µs making 1 call to YAML::PP::Loader::BEGIN@3.292
# spent 28µs making 1 call to warnings::import |
4 | package YAML::PP::Constructor; | ||||
5 | |||||
6 | 1 | 1µs | our $VERSION = '0.035'; # VERSION | ||
7 | |||||
8 | 2 | 27µs | 2 | 11µs | # spent 11µs within YAML::PP::Constructor::BEGIN@8 which was called:
# once (11µs+0s) by YAML::PP::Loader::BEGIN@9 at line 8 # spent 11µs making 1 call to YAML::PP::Constructor::BEGIN@8
# spent 0s making 1 call to YAML::PP::Constructor::__ANON__ |
9 | 1 | 1µs | # spent 32µs (6+26) within YAML::PP::Constructor::BEGIN@9 which was called:
# once (6µs+26µs) by YAML::PP::Loader::BEGIN@9 at line 11 | ||
10 | PRESERVE_ORDER PRESERVE_SCALAR_STYLE PRESERVE_FLOW_STYLE PRESERVE_ALIAS | ||||
11 | 1 | 24µs | 2 | 58µs | /; # spent 32µs making 1 call to YAML::PP::Constructor::BEGIN@9
# spent 26µs making 1 call to Exporter::import |
12 | 2 | 13µs | 2 | 30µs | # spent 18µs (6+12) within YAML::PP::Constructor::BEGIN@12 which was called:
# once (6µs+12µs) by YAML::PP::Loader::BEGIN@9 at line 12 # spent 18µs making 1 call to YAML::PP::Constructor::BEGIN@12
# spent 12µs making 1 call to Exporter::import |
13 | 2 | 25µs | 2 | 19µs | # spent 11µs (3+8) within YAML::PP::Constructor::BEGIN@13 which was called:
# once (3µs+8µs) by YAML::PP::Loader::BEGIN@9 at line 13 # spent 11µs making 1 call to YAML::PP::Constructor::BEGIN@13
# spent 8µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 24µs | 2 | 83µs | # spent 45µs (7+38) within YAML::PP::Constructor::BEGIN@15 which was called:
# once (7µs+38µs) by YAML::PP::Loader::BEGIN@9 at line 15 # spent 45µs making 1 call to YAML::PP::Constructor::BEGIN@15
# spent 38µs making 1 call to constant::import |
16 | 2 | 1.64ms | 2 | 37µs | # spent 21µs (5+16) within YAML::PP::Constructor::BEGIN@16 which was called:
# once (5µs+16µs) by YAML::PP::Loader::BEGIN@9 at line 16 # spent 21µs making 1 call to YAML::PP::Constructor::BEGIN@16
# spent 16µs making 1 call to constant::import |
17 | |||||
18 | 1 | 3µs | my %cyclic_refs = qw/ allow 1 ignore 1 warn 1 fatal 1 /; | ||
19 | |||||
20 | # spent 52µs (14+38) within YAML::PP::Constructor::new which was called:
# once (14µs+38µs) by YAML::PP::Loader::new at line 26 of YAML/PP/Loader.pm | ||||
21 | 1 | 2µs | my ($class, %args) = @_; | ||
22 | |||||
23 | 1 | 0s | my $default_yaml_version = delete $args{default_yaml_version}; | ||
24 | 1 | 1µs | my $duplicate_keys = delete $args{duplicate_keys}; | ||
25 | 1 | 1µs | unless (defined $duplicate_keys) { | ||
26 | $duplicate_keys = 0; | ||||
27 | } | ||||
28 | 1 | 0s | my $preserve = delete $args{preserve} || 0; | ||
29 | 1 | 0s | if ($preserve == 1) { | ||
30 | $preserve = PRESERVE_ORDER | PRESERVE_SCALAR_STYLE | PRESERVE_FLOW_STYLE | PRESERVE_ALIAS; | ||||
31 | } | ||||
32 | 1 | 1µs | my $cyclic_refs = delete $args{cyclic_refs} || 'allow'; | ||
33 | die "Invalid value for cyclic_refs: $cyclic_refs" | ||||
34 | 1 | 1µs | unless $cyclic_refs{ $cyclic_refs }; | ||
35 | 1 | 0s | my $schemas = delete $args{schemas}; | ||
36 | |||||
37 | 1 | 0s | if (keys %args) { | ||
38 | die "Unexpected arguments: " . join ', ', sort keys %args; | ||||
39 | } | ||||
40 | |||||
41 | 1 | 2µ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; | ||||
48 | 1 | 2µs | 1 | 38µs | $self->init; # spent 38µs making 1 call to YAML::PP::Constructor::init |
49 | 1 | 3µs | return $self; | ||
50 | } | ||||
51 | |||||
52 | sub 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 55µs (38+17) within YAML::PP::Constructor::init which was called 2 times, avg 28µs/call:
# once (26µs+12µs) by YAML::PP::Constructor::new at line 48
# once (12µs+5µs) by YAML::PP::Loader::load at line 93 of YAML/PP/Loader.pm | ||||
65 | 2 | 0s | my ($self) = @_; | ||
66 | 2 | 6µs | 2 | 6µs | $self->set_docs([]); # spent 6µs making 2 calls to YAML::PP::Constructor::set_docs, avg 3µs/call |
67 | 2 | 1µs | 2 | 1µs | $self->set_stack([]); # spent 1µs making 2 calls to YAML::PP::Constructor::set_stack, avg 500ns/call |
68 | 2 | 2µs | 2 | 1µs | $self->set_anchors({}); # spent 1µs making 2 calls to YAML::PP::Constructor::set_anchors, avg 500ns/call |
69 | 2 | 5µs | 4 | 3µs | $self->set_yaml_version($self->default_yaml_version); # spent 2µs making 2 calls to YAML::PP::Constructor::set_yaml_version, avg 1µs/call
# spent 1µs making 2 calls to YAML::PP::Constructor::default_yaml_version, avg 500ns/call |
70 | 2 | 9µs | 6 | 6µs | $self->set_schema($self->schemas->{ $self->yaml_version } ); # spent 2µs making 2 calls to YAML::PP::Constructor::schemas, avg 1µs/call
# spent 2µs making 2 calls to YAML::PP::Constructor::set_schema, avg 1µs/call
# spent 2µs making 2 calls to YAML::PP::Constructor::yaml_version, avg 1µs/call |
71 | } | ||||
72 | |||||
73 | 2 | 5µs | # spent 1µs within YAML::PP::Constructor::docs which was called 2 times, avg 500ns/call:
# once (1µs+0s) by YAML::PP::Constructor::document_end_event at line 120
# once (0s+0s) by YAML::PP::Loader::load at line 96 of YAML/PP/Loader.pm | ||
74 | 35838 | 59.1ms | # spent 15.4ms within YAML::PP::Constructor::stack which was called 35838 times, avg 430ns/call:
# 20764 times (9.27ms+0s) by YAML::PP::Constructor::scalar_event at line 288, avg 446ns/call
# 6900 times (3.19ms+0s) by YAML::PP::Constructor::mapping_start_event at line 136, avg 462ns/call
# 6900 times (2.43ms+0s) by YAML::PP::Constructor::mapping_end_event at line 164, avg 352ns/call
# 636 times (312µs+0s) by YAML::PP::Constructor::sequence_start_event at line 237, avg 491ns/call
# 636 times (228µs+0s) by YAML::PP::Constructor::sequence_end_event at line 262, avg 358ns/call
# once (1µs+0s) by YAML::PP::Constructor::document_start_event at line 95
# once (0s+0s) by YAML::PP::Constructor::document_end_event at line 114 | ||
75 | sub anchors { return $_[0]->{anchors} } | ||||
76 | 2 | 7µs | # spent 6µs within YAML::PP::Constructor::set_docs which was called 2 times, avg 3µs/call:
# 2 times (6µs+0s) by YAML::PP::Constructor::init at line 66, avg 3µs/call | ||
77 | 3 | 5µs | sub set_stack { $_[0]->{stack} = $_[1] } | ||
78 | 3 | 7µs | sub set_anchors { $_[0]->{anchors} = $_[1] } | ||
79 | 2 | 4µs | # spent 2µs within YAML::PP::Constructor::schemas 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 | ||
80 | 28300 | 33.1ms | # spent 13.8ms within YAML::PP::Constructor::schema which was called 28300 times, avg 488ns/call:
# 20764 times (10.2ms+0s) by YAML::PP::Constructor::scalar_event at line 287, avg 493ns/call
# 6900 times (3.29ms+0s) by YAML::PP::Constructor::mapping_start_event at line 128, avg 477ns/call
# 636 times (289µs+0s) by YAML::PP::Constructor::sequence_start_event at line 229, avg 454ns/call | ||
81 | 2 | 3µs | # spent 2µs within YAML::PP::Constructor::set_schema 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 | ||
82 | sub cyclic_refs { return $_[0]->{cyclic_refs} } | ||||
83 | sub set_cyclic_refs { $_[0]->{cyclic_refs} = $_[1] } | ||||
84 | 2 | 3µ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 | ||
85 | 2 | 5µ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 | ||
86 | 2 | 3µs | # spent 1µs within YAML::PP::Constructor::default_yaml_version which was called 2 times, avg 500ns/call:
# 2 times (1µs+0s) by YAML::PP::Constructor::init at line 69, avg 500ns/call | ||
87 | 6900 | 8.63ms | # spent 4.75ms within YAML::PP::Constructor::preserve_order which was called 6900 times, avg 688ns/call:
# 6900 times (4.75ms+0s) by YAML::PP::Constructor::mapping_start_event at line 138, avg 688ns/call | ||
88 | 20764 | 22.6ms | # spent 10.2ms within YAML::PP::Constructor::preserve_scalar_style which was called 20764 times, avg 490ns/call:
# 20764 times (10.2ms+0s) by YAML::PP::Constructor::scalar_event at line 290, avg 490ns/call | ||
89 | 7536 | 9.48ms | # spent 4.56ms within YAML::PP::Constructor::preserve_flow_style which was called 7536 times, avg 605ns/call:
# 6900 times (4.20ms+0s) by YAML::PP::Constructor::mapping_start_event at line 139, avg 608ns/call
# 636 times (362µs+0s) by YAML::PP::Constructor::sequence_start_event at line 239, avg 569ns/call | ||
90 | 28300 | 32.3ms | # spent 14.4ms within YAML::PP::Constructor::preserve_alias which was called 28300 times, avg 509ns/call:
# 20764 times (11.1ms+0s) by YAML::PP::Constructor::scalar_event at line 289, avg 536ns/call
# 6900 times (2.99ms+0s) by YAML::PP::Constructor::mapping_start_event at line 140, avg 433ns/call
# 636 times (283µs+0s) by YAML::PP::Constructor::sequence_start_event at line 240, avg 445ns/call | ||
91 | sub duplicate_keys { return $_[0]->{duplicate_keys} } | ||||
92 | |||||
93 | # spent 9µs (8+1) within YAML::PP::Constructor::document_start_event which was called:
# once (8µs+1µ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 | ||||
94 | 1 | 0s | my ($self, $event) = @_; | ||
95 | 1 | 2µs | 1 | 1µs | my $stack = $self->stack; # spent 1µs making 1 call to YAML::PP::Constructor::stack |
96 | 1 | 0s | 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 | } | ||||
108 | 1 | 1µs | my $ref = []; | ||
109 | 1 | 4µs | push @$stack, { type => 'document', ref => $ref, data => $ref, event => $event }; | ||
110 | } | ||||
111 | |||||
112 | # spent 19µs (17+2) within YAML::PP::Constructor::document_end_event which was called:
# once (17µ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 | ||||
113 | 1 | 0s | my ($self, $event) = @_; | ||
114 | 1 | 2µs | 1 | 0s | my $stack = $self->stack; # spent 0s making 1 call to YAML::PP::Constructor::stack |
115 | 1 | 0s | my $last = pop @$stack; | ||
116 | 1 | 1µs | $last->{type} eq 'document' or die "Expected mapping, but got $last->{type}"; | ||
117 | 1 | 1µs | if (@$stack) { | ||
118 | die "Got unexpected end of document"; | ||||
119 | } | ||||
120 | 1 | 2µs | 1 | 1µs | my $docs = $self->docs; # spent 1µs making 1 call to YAML::PP::Constructor::docs |
121 | 1 | 0s | push @$docs, $last->{ref}->[0]; | ||
122 | 1 | 2µs | 1 | 1µs | $self->set_anchors({}); # spent 1µs making 1 call to YAML::PP::Constructor::set_anchors |
123 | 1 | 5µs | 1 | 0s | $self->set_stack([]); # spent 0s making 1 call to YAML::PP::Constructor::set_stack |
124 | } | ||||
125 | |||||
126 | # spent 147ms (101+46.7) within YAML::PP::Constructor::mapping_start_event which was called 6900 times, avg 21µs/call:
# 6900 times (101ms+46.7ms) 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 21µs/call | ||||
127 | 6900 | 1.28ms | my ($self, $event) = @_; | ||
128 | 6900 | 11.7ms | 13800 | 31.6ms | my ($data, $on_data) = $self->schema->create_mapping($self, $event); # spent 28.3ms making 6900 calls to YAML::PP::Schema::create_mapping, avg 4µs/call
# spent 3.29ms making 6900 calls to YAML::PP::Constructor::schema, avg 477ns/call |
129 | 6900 | 11.2ms | my $ref = { | ||
130 | type => 'mapping', | ||||
131 | ref => [], | ||||
132 | data => \$data, | ||||
133 | event => $event, | ||||
134 | on_data => $on_data, | ||||
135 | }; | ||||
136 | 6900 | 4.46ms | 6900 | 3.19ms | my $stack = $self->stack; # spent 3.19ms making 6900 calls to YAML::PP::Constructor::stack, avg 462ns/call |
137 | |||||
138 | 6900 | 5.38ms | 6900 | 4.75ms | my $preserve_order = $self->preserve_order; # spent 4.75ms making 6900 calls to YAML::PP::Constructor::preserve_order, avg 688ns/call |
139 | 6900 | 5.10ms | 6900 | 4.20ms | my $preserve_style = $self->preserve_flow_style; # spent 4.20ms making 6900 calls to YAML::PP::Constructor::preserve_flow_style, avg 608ns/call |
140 | 6900 | 4.28ms | 6900 | 2.99ms | my $preserve_alias = $self->preserve_alias; # spent 2.99ms making 6900 calls to YAML::PP::Constructor::preserve_alias, avg 433ns/call |
141 | 6900 | 1.42ms | if (($preserve_order or $preserve_style or $preserve_alias) and not tied(%$data)) { | ||
142 | tie %$data, 'YAML::PP::Preserve::Hash', %$data; | ||||
143 | } | ||||
144 | 6900 | 960µs | if ($preserve_style) { | ||
145 | my $t = tied %$data; | ||||
146 | $t->{style} = $event->{style}; | ||||
147 | } | ||||
148 | |||||
149 | 6900 | 1.67ms | push @$stack, $ref; | ||
150 | 6900 | 12.2ms | 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 152ms (103+48.4) within YAML::PP::Constructor::mapping_end_event which was called 6900 times, avg 22µs/call:
# 6900 times (103ms+48.4ms) 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 22µs/call | ||||
163 | 6900 | 1.19ms | my ($self, $event) = @_; | ||
164 | 6900 | 3.92ms | 6900 | 2.43ms | my $stack = $self->stack; # spent 2.43ms making 6900 calls to YAML::PP::Constructor::stack, avg 352ns/call |
165 | |||||
166 | 6900 | 1.76ms | my $last = pop @$stack; | ||
167 | 6900 | 3.45ms | my ($ref, $data) = @{ $last }{qw/ ref data /}; | ||
168 | 6900 | 1.88ms | $last->{type} eq 'mapping' or die "Expected mapping, but got $last->{type}"; | ||
169 | |||||
170 | 6900 | 896µs | my @merge_keys; | ||
171 | my @ref; | ||||
172 | 6900 | 6.96ms | for (my $i = 0; $i < @$ref; $i += 2) { | ||
173 | 13349 | 4.20ms | my $key = $ref->[ $i ]; | ||
174 | 13349 | 4.11ms | 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 { | ||||
194 | 13349 | 5.70ms | push @ref, $key, $ref->[ $i + 1 ]; | ||
195 | } | ||||
196 | } | ||||
197 | 6900 | 2.59ms | 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 45.9ms within YAML::PP::Constructor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Constructor.pm:218] which was called 6900 times, avg 7µs/call:
# 6900 times (45.9ms+0s) by YAML::PP::Constructor::mapping_end_event at line 219, avg 7µs/call | ||||
205 | 6900 | 1.42ms | my ($self, $hash, $items) = @_; | ||
206 | 6900 | 932µs | my %seen; | ||
207 | 6900 | 19.0ms | for (my $i = 0; $i < @$items; $i += 2) { | ||
208 | 13349 | 6.36ms | my ($key, $value) = @$items[ $i, $i + 1 ]; | ||
209 | 13349 | 1.35ms | $key = '' unless defined $key; | ||
210 | 13349 | 1.07ms | if (ref $key) { | ||
211 | $key = $self->stringify_complex($key); | ||||
212 | } | ||||
213 | 13349 | 13.5ms | if ($seen{ $key }++ and not $self->duplicate_keys) { | ||
214 | croak "Duplicate key '$key'"; | ||||
215 | } | ||||
216 | 13349 | 7.64ms | $$hash->{ $key } = $value; | ||
217 | } | ||||
218 | 6900 | 14.4ms | }; | ||
219 | 6900 | 6.01ms | 6900 | 45.9ms | $on_data->($self, $data, \@ref); # spent 45.9ms making 6900 calls to YAML::PP::Constructor::__ANON__[YAML/PP/Constructor.pm:218], avg 7µs/call |
220 | 6900 | 5.29ms | push @{ $stack->[-1]->{ref} }, $$data; | ||
221 | 6900 | 2.55ms | if (defined(my $anchor = $last->{event}->{anchor})) { | ||
222 | $self->anchors->{ $anchor }->{finished} = 1; | ||||
223 | } | ||||
224 | 6900 | 33.3ms | return; | ||
225 | } | ||||
226 | |||||
227 | # spent 12.7ms (8.30+4.39) within YAML::PP::Constructor::sequence_start_event which was called 636 times, avg 20µs/call:
# 636 times (8.30ms+4.39ms) 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 | ||||
228 | 636 | 222µs | my ($self, $event) = @_; | ||
229 | 636 | 1.29ms | 1272 | 3.44ms | my ($data, $on_data) = $self->schema->create_sequence($self, $event); # spent 3.15ms making 636 calls to YAML::PP::Schema::create_sequence, avg 5µs/call
# spent 289µs making 636 calls to YAML::PP::Constructor::schema, avg 454ns/call |
230 | 636 | 1.31ms | my $ref = { | ||
231 | type => 'sequence', | ||||
232 | ref => [], | ||||
233 | data => \$data, | ||||
234 | event => $event, | ||||
235 | on_data => $on_data, | ||||
236 | }; | ||||
237 | 636 | 583µs | 636 | 312µs | my $stack = $self->stack; # spent 312µs making 636 calls to YAML::PP::Constructor::stack, avg 491ns/call |
238 | |||||
239 | 636 | 469µs | 636 | 362µs | my $preserve_style = $self->preserve_flow_style; # spent 362µs making 636 calls to YAML::PP::Constructor::preserve_flow_style, avg 569ns/call |
240 | 636 | 479µs | 636 | 283µs | my $preserve_alias = $self->preserve_alias; # spent 283µs making 636 calls to YAML::PP::Constructor::preserve_alias, avg 445ns/call |
241 | 636 | 175µ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 | |||||
247 | 636 | 247µs | push @$stack, $ref; | ||
248 | 636 | 1.64ms | 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 9.04ms (7.63+1.41) within YAML::PP::Constructor::sequence_end_event which was called 636 times, avg 14µs/call:
# 636 times (7.63ms+1.41ms) 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 14µs/call | ||||
261 | 636 | 191µs | my ($self, $event) = @_; | ||
262 | 636 | 440µs | 636 | 228µs | my $stack = $self->stack; # spent 228µs making 636 calls to YAML::PP::Constructor::stack, avg 358ns/call |
263 | 636 | 286µs | my $last = pop @$stack; | ||
264 | 636 | 418µs | $last->{type} eq 'sequence' or die "Expected mapping, but got $last->{type}"; | ||
265 | 636 | 369µs | my ($ref, $data) = @{ $last }{qw/ ref data /}; | ||
266 | |||||
267 | # spent 1.18ms within YAML::PP::Constructor::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Constructor.pm:270] which was called 636 times, avg 2µs/call:
# 636 times (1.18ms+0s) by YAML::PP::Constructor::sequence_end_event at line 271, avg 2µs/call | ||||
268 | 636 | 176µs | my ($self, $array, $items) = @_; | ||
269 | 636 | 1.58ms | push @$$array, @$items; | ||
270 | 636 | 1.54ms | }; | ||
271 | 636 | 599µs | 636 | 1.18ms | $on_data->($self, $data, $ref); # spent 1.18ms making 636 calls to YAML::PP::Constructor::__ANON__[YAML/PP/Constructor.pm:270], avg 2µs/call |
272 | 636 | 367µs | push @{ $stack->[-1]->{ref} }, $$data; | ||
273 | 636 | 312µs | if (defined(my $anchor = $last->{event}->{anchor})) { | ||
274 | my $test = $self->anchors->{ $anchor }; | ||||
275 | $self->anchors->{ $anchor }->{finished} = 1; | ||||
276 | } | ||||
277 | 636 | 2.63ms | return; | ||
278 | } | ||||
279 | |||||
280 | 1 | 2µs | # spent 1µs within YAML::PP::Constructor::stream_start_event which was called:
# once (1µ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 | ||
281 | |||||
282 | 1 | 2µs | # spent 1µs within YAML::PP::Constructor::stream_end_event which was called:
# once (1µ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 | ||
283 | |||||
284 | # spent 709ms (200+509) within YAML::PP::Constructor::scalar_event which was called 20764 times, avg 34µs/call:
# 20764 times (200ms+509ms) 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 34µs/call | ||||
285 | 20764 | 3.17ms | my ($self, $event) = @_; | ||
286 | DEBUG and warn "CONTENT $event->{value} ($event->{style})\n"; | ||||
287 | 20764 | 29.6ms | 41528 | 478ms | my $value = $self->schema->load_scalar($self, $event); # spent 468ms making 20764 calls to YAML::PP::Schema::load_scalar, avg 23µs/call
# spent 10.2ms making 20764 calls to YAML::PP::Constructor::schema, avg 493ns/call |
288 | 20764 | 40.6ms | 20764 | 9.27ms | my $last = $self->stack->[-1]; # spent 9.27ms making 20764 calls to YAML::PP::Constructor::stack, avg 446ns/call |
289 | 20764 | 13.1ms | 20764 | 11.1ms | my $preserve_alias = $self->preserve_alias; # spent 11.1ms making 20764 calls to YAML::PP::Constructor::preserve_alias, avg 536ns/call |
290 | 20764 | 13.4ms | 20764 | 10.2ms | my $preserve_style = $self->preserve_scalar_style; # spent 10.2ms making 20764 calls to YAML::PP::Constructor::preserve_scalar_style, avg 490ns/call |
291 | 20764 | 4.01ms | 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 | } | ||||
308 | 20764 | 6.43ms | if (defined (my $name = $event->{anchor})) { | ||
309 | $self->anchors->{ $name } = { data => \$value, finished => 1 }; | ||||
310 | } | ||||
311 | 20764 | 41.1ms | push @{ $last->{ref} }, $value; | ||
312 | } | ||||
313 | |||||
314 | sub 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 | |||||
345 | sub 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 | |||||
362 | 1 | 4µs | 1; | ||
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 |