Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Constructor.pm |
Statements | Executed 604683 statements in 683ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
20941 | 1 | 1 | 234ms | 958ms | scalar_event | YAML::PP::Constructor::
6939 | 1 | 1 | 138ms | 198ms | mapping_end_event | YAML::PP::Constructor::
6939 | 1 | 1 | 126ms | 191ms | mapping_start_event | YAML::PP::Constructor::
6939 | 1 | 1 | 56.5ms | 56.5ms | __ANON__[:218] | YAML::PP::Constructor::
36111 | 7 | 1 | 20.8ms | 20.8ms | stack | YAML::PP::Constructor::
28525 | 3 | 1 | 19.3ms | 19.3ms | preserve_alias | YAML::PP::Constructor::
28525 | 3 | 1 | 17.6ms | 17.6ms | schema | YAML::PP::Constructor::
20941 | 1 | 1 | 16.4ms | 16.4ms | preserve_scalar_style | YAML::PP::Constructor::
645 | 1 | 1 | 11.2ms | 17.1ms | sequence_start_event | YAML::PP::Constructor::
645 | 1 | 1 | 11.2ms | 13.0ms | sequence_end_event | YAML::PP::Constructor::
6939 | 1 | 1 | 7.44ms | 7.44ms | preserve_order | YAML::PP::Constructor::
7584 | 2 | 1 | 6.78ms | 6.78ms | preserve_flow_style | YAML::PP::Constructor::
645 | 1 | 1 | 1.51ms | 1.51ms | __ANON__[:270] | YAML::PP::Constructor::
1 | 1 | 1 | 68µs | 72µs | BEGIN@2.291 | YAML::PP::Loader::
2 | 2 | 2 | 51µs | 78µs | init | YAML::PP::Constructor::
1 | 1 | 1 | 39µs | 63µs | document_start_event | YAML::PP::Constructor::
1 | 1 | 1 | 34µs | 34µs | BEGIN@8 | YAML::PP::Constructor::
1 | 1 | 1 | 31µs | 85µs | new | YAML::PP::Constructor::
1 | 1 | 1 | 30µs | 91µs | BEGIN@9 | YAML::PP::Constructor::
1 | 1 | 1 | 24µs | 29µs | document_end_event | YAML::PP::Constructor::
1 | 1 | 1 | 11µs | 67µs | BEGIN@15 | YAML::PP::Constructor::
1 | 1 | 1 | 10µs | 32µs | BEGIN@13 | YAML::PP::Constructor::
2 | 1 | 1 | 9µs | 9µs | set_docs | YAML::PP::Constructor::
1 | 1 | 1 | 8µs | 44µs | BEGIN@3.292 | YAML::PP::Loader::
1 | 1 | 1 | 7µs | 27µs | BEGIN@12 | YAML::PP::Constructor::
1 | 1 | 1 | 7µs | 42µs | BEGIN@16 | YAML::PP::Constructor::
3 | 2 | 1 | 4µs | 4µs | set_anchors | YAML::PP::Constructor::
2 | 1 | 1 | 3µs | 3µs | default_yaml_version | YAML::PP::Constructor::
2 | 1 | 1 | 3µs | 3µs | set_schema | YAML::PP::Constructor::
3 | 2 | 1 | 3µs | 3µs | set_stack | YAML::PP::Constructor::
2 | 1 | 1 | 3µs | 3µs | set_yaml_version | YAML::PP::Constructor::
2 | 1 | 1 | 3µs | 3µs | yaml_version | YAML::PP::Constructor::
2 | 2 | 2 | 2µs | 2µs | docs | YAML::PP::Constructor::
2 | 1 | 1 | 1µs | 1µs | schemas | 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 | 39µs | 2 | 76µs | # spent 72µs (68+4) within YAML::PP::Loader::BEGIN@2.291 which was called:
# once (68µs+4µs) by YAML::PP::Loader::BEGIN@9 at line 2 # spent 72µs making 1 call to YAML::PP::Loader::BEGIN@2.291
# spent 4µs making 1 call to strict::import |
3 | 2 | 69µs | 2 | 80µs | # spent 44µs (8+36) within YAML::PP::Loader::BEGIN@3.292 which was called:
# once (8µs+36µs) by YAML::PP::Loader::BEGIN@9 at line 3 # spent 44µs making 1 call to YAML::PP::Loader::BEGIN@3.292
# spent 36µs making 1 call to warnings::import |
4 | package YAML::PP::Constructor; | ||||
5 | |||||
6 | 1 | 2µs | our $VERSION = '0.035'; # VERSION | ||
7 | |||||
8 | 2 | 86µs | 2 | 34µs | # spent 34µs within YAML::PP::Constructor::BEGIN@8 which was called:
# once (34µs+0s) by YAML::PP::Loader::BEGIN@9 at line 8 # spent 34µs making 1 call to YAML::PP::Constructor::BEGIN@8
# spent 0s making 1 call to YAML::PP::Constructor::__ANON__ |
9 | 1 | 2µs | # spent 91µs (30+61) within YAML::PP::Constructor::BEGIN@9 which was called:
# once (30µs+61µs) by YAML::PP::Loader::BEGIN@9 at line 11 | ||
10 | PRESERVE_ORDER PRESERVE_SCALAR_STYLE PRESERVE_FLOW_STYLE PRESERVE_ALIAS | ||||
11 | 1 | 47µs | 2 | 152µs | /; # spent 91µs making 1 call to YAML::PP::Constructor::BEGIN@9
# spent 61µs making 1 call to Exporter::import |
12 | 2 | 29µs | 2 | 47µs | # spent 27µs (7+20) within YAML::PP::Constructor::BEGIN@12 which was called:
# once (7µs+20µs) by YAML::PP::Loader::BEGIN@9 at line 12 # spent 27µs making 1 call to YAML::PP::Constructor::BEGIN@12
# spent 20µs making 1 call to Exporter::import |
13 | 2 | 57µs | 2 | 54µs | # spent 32µs (10+22) within YAML::PP::Constructor::BEGIN@13 which was called:
# once (10µs+22µs) by YAML::PP::Loader::BEGIN@9 at line 13 # spent 32µs making 1 call to YAML::PP::Constructor::BEGIN@13
# spent 22µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 46µs | 2 | 123µs | # spent 67µs (11+56) within YAML::PP::Constructor::BEGIN@15 which was called:
# once (11µs+56µs) by YAML::PP::Loader::BEGIN@9 at line 15 # spent 67µs making 1 call to YAML::PP::Constructor::BEGIN@15
# spent 56µs making 1 call to constant::import |
16 | 2 | 4.25ms | 2 | 77µs | # spent 42µs (7+35) within YAML::PP::Constructor::BEGIN@16 which was called:
# once (7µs+35µs) by YAML::PP::Loader::BEGIN@9 at line 16 # spent 42µs making 1 call to YAML::PP::Constructor::BEGIN@16
# spent 35µs making 1 call to constant::import |
17 | |||||
18 | 1 | 8µs | my %cyclic_refs = qw/ allow 1 ignore 1 warn 1 fatal 1 /; | ||
19 | |||||
20 | # spent 85µs (31+54) within YAML::PP::Constructor::new which was called:
# once (31µs+54µs) by YAML::PP::Loader::new at line 26 of YAML/PP/Loader.pm | ||||
21 | 1 | 2µs | my ($class, %args) = @_; | ||
22 | |||||
23 | 1 | 1µs | my $default_yaml_version = delete $args{default_yaml_version}; | ||
24 | 1 | 0s | my $duplicate_keys = delete $args{duplicate_keys}; | ||
25 | 1 | 1µs | unless (defined $duplicate_keys) { | ||
26 | $duplicate_keys = 0; | ||||
27 | } | ||||
28 | 1 | 1µs | my $preserve = delete $args{preserve} || 0; | ||
29 | 1 | 1µs | 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 | 54µs | $self->init; # spent 54µs making 1 call to YAML::PP::Constructor::init |
49 | 1 | 19µ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 78µs (51+27) within YAML::PP::Constructor::init which was called 2 times, avg 39µs/call:
# once (34µs+20µs) by YAML::PP::Constructor::new at line 48
# once (17µs+7µs) by YAML::PP::Loader::load at line 93 of YAML/PP/Loader.pm | ||||
65 | 2 | 2µs | my ($self) = @_; | ||
66 | 2 | 4µs | 2 | 9µs | $self->set_docs([]); # spent 9µs making 2 calls to YAML::PP::Constructor::set_docs, avg 4µs/call |
67 | 2 | 2µs | 2 | 2µs | $self->set_stack([]); # spent 2µs making 2 calls to YAML::PP::Constructor::set_stack, avg 1µs/call |
68 | 2 | 2µs | 2 | 3µs | $self->set_anchors({}); # spent 3µs making 2 calls to YAML::PP::Constructor::set_anchors, avg 2µs/call |
69 | 2 | 7µs | 4 | 6µ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 3µs making 2 calls to YAML::PP::Constructor::set_yaml_version, avg 2µs/call |
70 | 2 | 29µs | 6 | 7µs | $self->set_schema($self->schemas->{ $self->yaml_version } ); # spent 3µs making 2 calls to YAML::PP::Constructor::set_schema, avg 2µs/call
# spent 3µs making 2 calls to YAML::PP::Constructor::yaml_version, avg 2µs/call
# spent 1µs making 2 calls to YAML::PP::Constructor::schemas, avg 500ns/call |
71 | } | ||||
72 | |||||
73 | 2 | 8µs | # spent 2µs within YAML::PP::Constructor::docs which was called 2 times, avg 1µs/call:
# once (2µ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 | 36111 | 53.6ms | # spent 20.8ms within YAML::PP::Constructor::stack which was called 36111 times, avg 577ns/call:
# 20941 times (12.4ms+0s) by YAML::PP::Constructor::scalar_event at line 288, avg 591ns/call
# 6939 times (4.42ms+0s) by YAML::PP::Constructor::mapping_start_event at line 136, avg 637ns/call
# 6939 times (3.19ms+0s) by YAML::PP::Constructor::mapping_end_event at line 164, avg 459ns/call
# 645 times (493µs+0s) by YAML::PP::Constructor::sequence_start_event at line 237, avg 764ns/call
# 645 times (326µs+0s) by YAML::PP::Constructor::sequence_end_event at line 262, avg 505ns/call
# once (24µ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 | ||
75 | sub anchors { return $_[0]->{anchors} } | ||||
76 | 2 | 17µs | # spent 9µs within YAML::PP::Constructor::set_docs which was called 2 times, avg 4µs/call:
# 2 times (9µs+0s) by YAML::PP::Constructor::init at line 66, avg 4µs/call | ||
77 | 3 | 7µs | sub set_stack { $_[0]->{stack} = $_[1] } | ||
78 | 3 | 7µs | sub set_anchors { $_[0]->{anchors} = $_[1] } | ||
79 | 2 | 4µs | # spent 1µs within YAML::PP::Constructor::schemas which was called 2 times, avg 500ns/call:
# 2 times (1µs+0s) by YAML::PP::Constructor::init at line 70, avg 500ns/call | ||
80 | 28525 | 43.0ms | # spent 17.6ms within YAML::PP::Constructor::schema which was called 28525 times, avg 617ns/call:
# 20941 times (12.7ms+0s) by YAML::PP::Constructor::scalar_event at line 287, avg 604ns/call
# 6939 times (4.58ms+0s) by YAML::PP::Constructor::mapping_start_event at line 128, avg 660ns/call
# 645 times (383µs+0s) by YAML::PP::Constructor::sequence_start_event at line 229, avg 594ns/call | ||
81 | 2 | 4µs | # spent 3µs within YAML::PP::Constructor::set_schema 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 | ||
82 | sub cyclic_refs { return $_[0]->{cyclic_refs} } | ||||
83 | sub set_cyclic_refs { $_[0]->{cyclic_refs} = $_[1] } | ||||
84 | 2 | 4µs | # spent 3µs within YAML::PP::Constructor::yaml_version 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 | ||
85 | 2 | 4µs | # spent 3µs within YAML::PP::Constructor::set_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 | ||
86 | 2 | 8µ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 | ||
87 | 6939 | 13.5ms | # spent 7.44ms within YAML::PP::Constructor::preserve_order which was called 6939 times, avg 1µs/call:
# 6939 times (7.44ms+0s) by YAML::PP::Constructor::mapping_start_event at line 138, avg 1µs/call | ||
88 | 20941 | 33.9ms | # spent 16.4ms within YAML::PP::Constructor::preserve_scalar_style which was called 20941 times, avg 783ns/call:
# 20941 times (16.4ms+0s) by YAML::PP::Constructor::scalar_event at line 290, avg 783ns/call | ||
89 | 7584 | 13.8ms | # spent 6.78ms within YAML::PP::Constructor::preserve_flow_style which was called 7584 times, avg 894ns/call:
# 6939 times (6.25ms+0s) by YAML::PP::Constructor::mapping_start_event at line 139, avg 900ns/call
# 645 times (534µs+0s) by YAML::PP::Constructor::sequence_start_event at line 239, avg 828ns/call | ||
90 | 28525 | 42.2ms | # spent 19.3ms within YAML::PP::Constructor::preserve_alias which was called 28525 times, avg 676ns/call:
# 20941 times (15.1ms+0s) by YAML::PP::Constructor::scalar_event at line 289, avg 720ns/call
# 6939 times (3.84ms+0s) by YAML::PP::Constructor::mapping_start_event at line 140, avg 554ns/call
# 645 times (373µs+0s) by YAML::PP::Constructor::sequence_start_event at line 240, avg 578ns/call | ||
91 | sub duplicate_keys { return $_[0]->{duplicate_keys} } | ||||
92 | |||||
93 | # spent 63µs (39+24) within YAML::PP::Constructor::document_start_event which was called:
# once (39µs+24µ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 | 1µs | my ($self, $event) = @_; | ||
95 | 1 | 19µs | 1 | 24µs | my $stack = $self->stack; # spent 24µs making 1 call to YAML::PP::Constructor::stack |
96 | 1 | 1µs | 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 | 8µs | push @$stack, { type => 'document', ref => $ref, data => $ref, event => $event }; | ||
110 | } | ||||
111 | |||||
112 | # spent 29µs (24+5) within YAML::PP::Constructor::document_end_event which was called:
# once (24µs+5µ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 | 1µs | my ($self, $event) = @_; | ||
114 | 1 | 1µs | 1 | 1µs | my $stack = $self->stack; # spent 1µs 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 | 0s | if (@$stack) { | ||
118 | die "Got unexpected end of document"; | ||||
119 | } | ||||
120 | 1 | 3µs | 1 | 2µs | my $docs = $self->docs; # spent 2µs making 1 call to YAML::PP::Constructor::docs |
121 | 1 | 1µs | 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 | 6µs | 1 | 1µs | $self->set_stack([]); # spent 1µs making 1 call to YAML::PP::Constructor::set_stack |
124 | } | ||||
125 | |||||
126 | # spent 191ms (126+65.8) within YAML::PP::Constructor::mapping_start_event which was called 6939 times, avg 28µs/call:
# 6939 times (126ms+65.8ms) 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 28µs/call | ||||
127 | 6939 | 3.57ms | my ($self, $event) = @_; | ||
128 | 6939 | 17.2ms | 13878 | 43.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 4.58ms making 6939 calls to YAML::PP::Constructor::schema, avg 660ns/call |
129 | 6939 | 19.7ms | my $ref = { | ||
130 | type => 'mapping', | ||||
131 | ref => [], | ||||
132 | data => \$data, | ||||
133 | event => $event, | ||||
134 | on_data => $on_data, | ||||
135 | }; | ||||
136 | 6939 | 6.42ms | 6939 | 4.42ms | my $stack = $self->stack; # spent 4.42ms making 6939 calls to YAML::PP::Constructor::stack, avg 637ns/call |
137 | |||||
138 | 6939 | 8.62ms | 6939 | 7.44ms | my $preserve_order = $self->preserve_order; # spent 7.44ms making 6939 calls to YAML::PP::Constructor::preserve_order, avg 1µs/call |
139 | 6939 | 7.10ms | 6939 | 6.25ms | my $preserve_style = $self->preserve_flow_style; # spent 6.25ms making 6939 calls to YAML::PP::Constructor::preserve_flow_style, avg 900ns/call |
140 | 6939 | 6.66ms | 6939 | 3.84ms | my $preserve_alias = $self->preserve_alias; # spent 3.84ms making 6939 calls to YAML::PP::Constructor::preserve_alias, avg 554ns/call |
141 | 6939 | 3.07ms | if (($preserve_order or $preserve_style or $preserve_alias) and not tied(%$data)) { | ||
142 | tie %$data, 'YAML::PP::Preserve::Hash', %$data; | ||||
143 | } | ||||
144 | 6939 | 1.43ms | if ($preserve_style) { | ||
145 | my $t = tied %$data; | ||||
146 | $t->{style} = $event->{style}; | ||||
147 | } | ||||
148 | |||||
149 | 6939 | 2.06ms | push @$stack, $ref; | ||
150 | 6939 | 16.7ms | 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 198ms (138+59.7) within YAML::PP::Constructor::mapping_end_event which was called 6939 times, avg 29µs/call:
# 6939 times (138ms+59.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 29µs/call | ||||
163 | 6939 | 1.45ms | my ($self, $event) = @_; | ||
164 | 6939 | 5.30ms | 6939 | 3.19ms | my $stack = $self->stack; # spent 3.19ms making 6939 calls to YAML::PP::Constructor::stack, avg 459ns/call |
165 | |||||
166 | 6939 | 2.15ms | my $last = pop @$stack; | ||
167 | 6939 | 4.81ms | my ($ref, $data) = @{ $last }{qw/ ref data /}; | ||
168 | 6939 | 3.31ms | $last->{type} eq 'mapping' or die "Expected mapping, but got $last->{type}"; | ||
169 | |||||
170 | 6939 | 968µs | my @merge_keys; | ||
171 | my @ref; | ||||
172 | 6939 | 8.47ms | for (my $i = 0; $i < @$ref; $i += 2) { | ||
173 | 13444 | 5.74ms | my $key = $ref->[ $i ]; | ||
174 | 13444 | 4.53ms | 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 | 13444 | 7.27ms | push @ref, $key, $ref->[ $i + 1 ]; | ||
195 | } | ||||
196 | } | ||||
197 | 6939 | 3.27ms | 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 56.5ms 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 8µs/call:
# 6939 times (56.5ms+0s) by YAML::PP::Constructor::mapping_end_event at line 219, avg 8µs/call | ||||
205 | 6939 | 1.62ms | my ($self, $hash, $items) = @_; | ||
206 | 6939 | 1.20ms | my %seen; | ||
207 | 6939 | 25.5ms | for (my $i = 0; $i < @$items; $i += 2) { | ||
208 | 13444 | 7.48ms | my ($key, $value) = @$items[ $i, $i + 1 ]; | ||
209 | 13444 | 1.88ms | $key = '' unless defined $key; | ||
210 | 13444 | 1.32ms | if (ref $key) { | ||
211 | $key = $self->stringify_complex($key); | ||||
212 | } | ||||
213 | 13444 | 16.5ms | if ($seen{ $key }++ and not $self->duplicate_keys) { | ||
214 | croak "Duplicate key '$key'"; | ||||
215 | } | ||||
216 | 13444 | 9.40ms | $$hash->{ $key } = $value; | ||
217 | } | ||||
218 | 6939 | 19.7ms | }; | ||
219 | 6939 | 8.22ms | 6939 | 56.5ms | $on_data->($self, $data, \@ref); # spent 56.5ms making 6939 calls to YAML::PP::Constructor::__ANON__[YAML/PP/Constructor.pm:218], avg 8µs/call |
220 | 6939 | 6.91ms | push @{ $stack->[-1]->{ref} }, $$data; | ||
221 | 6939 | 4.42ms | if (defined(my $anchor = $last->{event}->{anchor})) { | ||
222 | $self->anchors->{ $anchor }->{finished} = 1; | ||||
223 | } | ||||
224 | 6939 | 44.7ms | return; | ||
225 | } | ||||
226 | |||||
227 | # spent 17.1ms (11.2+5.85) within YAML::PP::Constructor::sequence_start_event which was called 645 times, avg 26µs/call:
# 645 times (11.2ms+5.85ms) 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 | ||||
228 | 645 | 241µs | my ($self, $event) = @_; | ||
229 | 645 | 1.81ms | 1290 | 4.45ms | my ($data, $on_data) = $self->schema->create_sequence($self, $event); # spent 4.07ms making 645 calls to YAML::PP::Schema::create_sequence, avg 6µs/call
# spent 383µs making 645 calls to YAML::PP::Constructor::schema, avg 594ns/call |
230 | 645 | 1.98ms | my $ref = { | ||
231 | type => 'sequence', | ||||
232 | ref => [], | ||||
233 | data => \$data, | ||||
234 | event => $event, | ||||
235 | on_data => $on_data, | ||||
236 | }; | ||||
237 | 645 | 822µs | 645 | 493µs | my $stack = $self->stack; # spent 493µs making 645 calls to YAML::PP::Constructor::stack, avg 764ns/call |
238 | |||||
239 | 645 | 757µs | 645 | 534µs | my $preserve_style = $self->preserve_flow_style; # spent 534µs making 645 calls to YAML::PP::Constructor::preserve_flow_style, avg 828ns/call |
240 | 645 | 609µs | 645 | 373µs | my $preserve_alias = $self->preserve_alias; # spent 373µs making 645 calls to YAML::PP::Constructor::preserve_alias, avg 578ns/call |
241 | 645 | 377µ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 | 645 | 260µs | push @$stack, $ref; | ||
248 | 645 | 1.84ms | 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 13.0ms (11.2+1.83) within YAML::PP::Constructor::sequence_end_event which was called 645 times, avg 20µs/call:
# 645 times (11.2ms+1.83ms) 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 | ||||
261 | 645 | 255µs | my ($self, $event) = @_; | ||
262 | 645 | 591µs | 645 | 326µs | my $stack = $self->stack; # spent 326µs making 645 calls to YAML::PP::Constructor::stack, avg 505ns/call |
263 | 645 | 211µs | my $last = pop @$stack; | ||
264 | 645 | 475µs | $last->{type} eq 'sequence' or die "Expected mapping, but got $last->{type}"; | ||
265 | 645 | 612µs | my ($ref, $data) = @{ $last }{qw/ ref data /}; | ||
266 | |||||
267 | # spent 1.51ms 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.51ms+0s) by YAML::PP::Constructor::sequence_end_event at line 271, avg 2µs/call | ||||
268 | 645 | 128µs | my ($self, $array, $items) = @_; | ||
269 | 645 | 2.14ms | push @$$array, @$items; | ||
270 | 645 | 2.31ms | }; | ||
271 | 645 | 768µs | 645 | 1.51ms | $on_data->($self, $data, $ref); # spent 1.51ms making 645 calls to YAML::PP::Constructor::__ANON__[YAML/PP/Constructor.pm:270], avg 2µs/call |
272 | 645 | 843µs | push @{ $stack->[-1]->{ref} }, $$data; | ||
273 | 645 | 550µs | if (defined(my $anchor = $last->{event}->{anchor})) { | ||
274 | my $test = $self->anchors->{ $anchor }; | ||||
275 | $self->anchors->{ $anchor }->{finished} = 1; | ||||
276 | } | ||||
277 | 645 | 3.65ms | return; | ||
278 | } | ||||
279 | |||||
280 | 1 | 1µ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 | 3µ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 958ms (234+725) within YAML::PP::Constructor::scalar_event which was called 20941 times, avg 46µs/call:
# 20941 times (234ms+725ms) 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 46µs/call | ||||
285 | 20941 | 3.63ms | my ($self, $event) = @_; | ||
286 | DEBUG and warn "CONTENT $event->{value} ($event->{style})\n"; | ||||
287 | 20941 | 42.3ms | 41882 | 681ms | my $value = $self->schema->load_scalar($self, $event); # spent 668ms making 20941 calls to YAML::PP::Schema::load_scalar, avg 32µs/call
# spent 12.7ms making 20941 calls to YAML::PP::Constructor::schema, avg 604ns/call |
288 | 20941 | 22.5ms | 20941 | 12.4ms | my $last = $self->stack->[-1]; # spent 12.4ms making 20941 calls to YAML::PP::Constructor::stack, avg 591ns/call |
289 | 20941 | 17.4ms | 20941 | 15.1ms | my $preserve_alias = $self->preserve_alias; # spent 15.1ms making 20941 calls to YAML::PP::Constructor::preserve_alias, avg 720ns/call |
290 | 20941 | 19.1ms | 20941 | 16.4ms | my $preserve_style = $self->preserve_scalar_style; # spent 16.4ms making 20941 calls to YAML::PP::Constructor::preserve_scalar_style, avg 783ns/call |
291 | 20941 | 4.35ms | 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 | 20941 | 6.60ms | if (defined (my $name = $event->{anchor})) { | ||
309 | $self->anchors->{ $name } = { data => \$value, finished => 1 }; | ||||
310 | } | ||||
311 | 20941 | 52.7ms | 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 | 8µ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 |