| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/YAML/PP/Schema.pm |
| Statements | Executed 570494 statements in 491ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 20764 | 1 | 1 | 307ms | 468ms | YAML::PP::Schema::load_scalar |
| 70425 | 1 | 1 | 68.7ms | 68.7ms | YAML::PP::Schema::CORE:regcomp (opcode) |
| 70427 | 3 | 1 | 62.2ms | 62.2ms | YAML::PP::Schema::CORE:match (opcode) |
| 6900 | 1 | 1 | 24.7ms | 28.3ms | YAML::PP::Schema::create_mapping |
| 28328 | 4 | 1 | 13.3ms | 13.3ms | YAML::PP::Schema::resolvers |
| 636 | 1 | 1 | 2.90ms | 3.15ms | YAML::PP::Schema::create_sequence |
| 566 | 1 | 1 | 1.80ms | 2.86ms | YAML::PP::Schema::_bool_jsonpp_true |
| 403 | 1 | 1 | 1.56ms | 2.37ms | YAML::PP::Schema::_bool_jsonpp_false |
| 1 | 1 | 1 | 1.37ms | 1.54ms | YAML::PP::Schema::BEGIN@5 |
| 1 | 1 | 1 | 1.32ms | 1.73ms | YAML::PP::Schema::BEGIN@9 |
| 28 | 11 | 1 | 178µs | 187µs | YAML::PP::Schema::add_resolver |
| 28 | 6 | 1 | 99µs | 111µs | YAML::PP::Schema::add_representer |
| 1 | 1 | 1 | 52µs | 54µs | YAML::PP::BEGIN@1 |
| 1 | 1 | 1 | 32µs | 1.81ms | YAML::PP::Schema::load_subschemas |
| 1 | 1 | 1 | 27µs | 27µs | YAML::PP::Schema::new |
| 28 | 1 | 1 | 12µs | 12µs | YAML::PP::Schema::representers |
| 1 | 1 | 1 | 5µs | 16µs | YAML::PP::Schema::BEGIN@11 |
| 1 | 1 | 1 | 4µs | 19µs | YAML::PP::BEGIN@2 |
| 1 | 1 | 1 | 3µs | 5µs | YAML::PP::Schema::BEGIN@4 |
| 1 | 1 | 1 | 3µs | 3µs | YAML::PP::Schema::yaml_version |
| 2 | 1 | 1 | 2µs | 2µs | YAML::PP::Schema::bool_class |
| 3 | 1 | 1 | 1µs | 1µs | YAML::PP::Schema::false |
| 3 | 1 | 1 | 1µs | 1µs | YAML::PP::Schema::true |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Schema::_bool_booleanpm_false |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Schema::_bool_booleanpm_true |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Schema::_bool_perl_false |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Schema::_bool_perl_true |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Schema::add_collection_resolver |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Schema::add_mapping_resolver |
| 0 | 0 | 0 | 0s | 0s | YAML::PP::Schema::add_sequence_resolver |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 23µs | 2 | 56µs | # spent 54µs (52+2) within YAML::PP::BEGIN@1 which was called:
# once (52µs+2µs) by YAML::PP::BEGIN@8 at line 1 # spent 54µs making 1 call to YAML::PP::BEGIN@1
# spent 2µs making 1 call to strict::import |
| 2 | 2 | 26µs | 2 | 34µs | # spent 19µs (4+15) within YAML::PP::BEGIN@2 which was called:
# once (4µs+15µs) by YAML::PP::BEGIN@8 at line 2 # spent 19µs making 1 call to YAML::PP::BEGIN@2
# spent 15µs making 1 call to warnings::import |
| 3 | package YAML::PP::Schema; | ||||
| 4 | 2 | 13µs | 2 | 7µs | # spent 5µs (3+2) within YAML::PP::Schema::BEGIN@4 which was called:
# once (3µs+2µs) by YAML::PP::BEGIN@8 at line 4 # spent 5µs making 1 call to YAML::PP::Schema::BEGIN@4
# spent 2µs making 1 call to B::import |
| 5 | 2 | 614µs | 1 | 1.54ms | # spent 1.54ms (1.37+169µs) within YAML::PP::Schema::BEGIN@5 which was called:
# once (1.37ms+169µs) by YAML::PP::BEGIN@8 at line 5 # spent 1.54ms making 1 call to YAML::PP::Schema::BEGIN@5 |
| 6 | |||||
| 7 | 1 | 0s | our $VERSION = '0.035'; # VERSION | ||
| 8 | |||||
| 9 | 2 | 570µs | 2 | 1.78ms | # spent 1.73ms (1.32+408µs) within YAML::PP::Schema::BEGIN@9 which was called:
# once (1.32ms+408µs) by YAML::PP::BEGIN@8 at line 9 # spent 1.73ms making 1 call to YAML::PP::Schema::BEGIN@9
# spent 45µs making 1 call to Exporter::import |
| 10 | |||||
| 11 | 2 | 1.83ms | 2 | 27µs | # spent 16µs (5+11) within YAML::PP::Schema::BEGIN@11 which was called:
# once (5µs+11µs) by YAML::PP::BEGIN@8 at line 11 # spent 16µs making 1 call to YAML::PP::Schema::BEGIN@11
# spent 11µs making 1 call to Exporter::import |
| 12 | |||||
| 13 | # spent 27µs within YAML::PP::Schema::new which was called:
# once (27µs+0s) by YAML::PP::new at line 55 of YAML/PP.pm | ||||
| 14 | 1 | 1µs | my ($class, %args) = @_; | ||
| 15 | |||||
| 16 | 1 | 1µs | my $yaml_version = delete $args{yaml_version}; | ||
| 17 | 1 | 0s | my $bool = delete $args{boolean}; | ||
| 18 | 1 | 0s | $bool = 'perl' unless defined $bool; | ||
| 19 | 1 | 0s | if (keys %args) { | ||
| 20 | die "Unexpected arguments: " . join ', ', sort keys %args; | ||||
| 21 | } | ||||
| 22 | 1 | 0s | my $true; | ||
| 23 | my $false; | ||||
| 24 | my @bool_class; | ||||
| 25 | 1 | 2µs | my @bools = split m/,/, $bool; | ||
| 26 | 1 | 1µs | for my $b (@bools) { | ||
| 27 | 1 | 1µs | if ($b eq '*') { | ||
| 28 | push @bool_class, ('boolean', 'JSON::PP::Boolean'); | ||||
| 29 | last; | ||||
| 30 | } | ||||
| 31 | elsif ($b eq 'JSON::PP') { | ||||
| 32 | 1 | 1µs | require JSON::PP; | ||
| 33 | 1 | 0s | $true ||= \&_bool_jsonpp_true; | ||
| 34 | 1 | 1µs | $false ||= \&_bool_jsonpp_false; | ||
| 35 | 1 | 0s | push @bool_class, 'JSON::PP::Boolean'; | ||
| 36 | } | ||||
| 37 | elsif ($b eq 'boolean') { | ||||
| 38 | require boolean; | ||||
| 39 | $true ||= \&_bool_booleanpm_true; | ||||
| 40 | $false ||= \&_bool_booleanpm_false; | ||||
| 41 | push @bool_class, 'boolean'; | ||||
| 42 | } | ||||
| 43 | elsif ($b eq 'perl') { | ||||
| 44 | $true ||= \&_bool_perl_true; | ||||
| 45 | $false ||= \&_bool_perl_false; | ||||
| 46 | } | ||||
| 47 | elsif ($b eq 'perl_experimental') { | ||||
| 48 | $true ||= \&_bool_perl_true; | ||||
| 49 | $false ||= \&_bool_perl_false; | ||||
| 50 | push @bool_class, 'perl_experimental'; | ||||
| 51 | } | ||||
| 52 | else { | ||||
| 53 | die "Invalid value for 'boolean': '$b'. Allowed: ('perl', 'boolean', 'JSON::PP')"; | ||||
| 54 | } | ||||
| 55 | } | ||||
| 56 | |||||
| 57 | 1 | 12µs | my %representers = ( | ||
| 58 | 'undef' => undef, | ||||
| 59 | flags => [], | ||||
| 60 | equals => {}, | ||||
| 61 | regex => [], | ||||
| 62 | class_equals => {}, | ||||
| 63 | class_matches => [], | ||||
| 64 | class_isa => [], | ||||
| 65 | scalarref => undef, | ||||
| 66 | refref => undef, | ||||
| 67 | coderef => undef, | ||||
| 68 | glob => undef, | ||||
| 69 | tied_equals => {}, | ||||
| 70 | ); | ||||
| 71 | 1 | 4µs | my $self = bless { | ||
| 72 | yaml_version => $yaml_version, | ||||
| 73 | resolvers => {}, | ||||
| 74 | representers => \%representers, | ||||
| 75 | true => $true, | ||||
| 76 | false => $false, | ||||
| 77 | bool_class => \@bool_class, | ||||
| 78 | }, $class; | ||||
| 79 | 1 | 5µs | return $self; | ||
| 80 | } | ||||
| 81 | |||||
| 82 | 28328 | 33.6ms | # spent 13.3ms within YAML::PP::Schema::resolvers which was called 28328 times, avg 468ns/call:
# 20764 times (9.33ms+0s) by YAML::PP::Schema::load_scalar at line 308, avg 449ns/call
# 6900 times (3.66ms+0s) by YAML::PP::Schema::create_mapping at line 392, avg 531ns/call
# 636 times (252µs+0s) by YAML::PP::Schema::create_sequence at line 362, avg 396ns/call
# 28 times (9µs+0s) by YAML::PP::Schema::add_resolver at line 153, avg 321ns/call | ||
| 83 | 28 | 19µs | # spent 12µs within YAML::PP::Schema::representers which was called 28 times, avg 429ns/call:
# 28 times (12µs+0s) by YAML::PP::Schema::add_representer at line 225, avg 429ns/call | ||
| 84 | |||||
| 85 | 3 | 3µs | # spent 1µs within YAML::PP::Schema::true which was called 3 times, avg 333ns/call:
# 3 times (1µs+0s) by YAML::PP::Schema::Core::register at line 35 of YAML/PP/Schema/Core.pm, avg 333ns/call | ||
| 86 | 3 | 2µs | # spent 1µs within YAML::PP::Schema::false which was called 3 times, avg 333ns/call:
# 3 times (1µs+0s) by YAML::PP::Schema::Core::register at line 39 of YAML/PP/Schema/Core.pm, avg 333ns/call | ||
| 87 | 2 | 4µs | # spent 2µs within YAML::PP::Schema::bool_class which was called 2 times, avg 1µs/call:
# 2 times (2µs+0s) by YAML::PP::Schema::Core::register at line 98 of YAML/PP/Schema/Core.pm, avg 1µs/call | ||
| 88 | 1 | 5µs | # spent 3µs within YAML::PP::Schema::yaml_version which was called:
# once (3µs+0s) by YAML::PP::Schema::load_subschemas at line 100 | ||
| 89 | |||||
| 90 | 1 | 2µs | my %LOADED_SCHEMA = ( | ||
| 91 | JSON => 1, | ||||
| 92 | ); | ||||
| 93 | 1 | 1µs | my %DEFAULT_SCHEMA = ( | ||
| 94 | '1.2' => 'Core', | ||||
| 95 | '1.1' => 'YAML1_1', | ||||
| 96 | ); | ||||
| 97 | |||||
| 98 | # spent 1.81ms (32µs+1.78) within YAML::PP::Schema::load_subschemas which was called:
# once (32µs+1.78ms) by YAML::PP::new at line 59 of YAML/PP.pm | ||||
| 99 | 1 | 1µs | my ($self, @schemas) = @_; | ||
| 100 | 1 | 1µs | 1 | 3µs | my $yaml_version = $self->yaml_version; # spent 3µs making 1 call to YAML::PP::Schema::yaml_version |
| 101 | 1 | 0s | my $i = 0; | ||
| 102 | 1 | 5µs | while ($i < @schemas) { | ||
| 103 | 1 | 1µs | my $item = $schemas[ $i ]; | ||
| 104 | 1 | 1µs | if ($item eq '+') { | ||
| 105 | $item = $DEFAULT_SCHEMA{ $yaml_version }; | ||||
| 106 | } | ||||
| 107 | 1 | 1µs | $i++; | ||
| 108 | 1 | 3µs | 1 | 1µs | if (blessed($item)) { # spent 1µs making 1 call to Scalar::Util::blessed |
| 109 | $item->register( | ||||
| 110 | schema => $self, | ||||
| 111 | ); | ||||
| 112 | next; | ||||
| 113 | } | ||||
| 114 | 1 | 0s | my @options; | ||
| 115 | 1 | 1µs | while ($i < @schemas | ||
| 116 | and ( | ||||
| 117 | $schemas[ $i ] =~ m/^[^A-Za-z]/ | ||||
| 118 | or | ||||
| 119 | $schemas[ $i ] =~ m/^[a-zA-Z0-9]+=/ | ||||
| 120 | ) | ||||
| 121 | ) { | ||||
| 122 | push @options, $schemas[ $i ]; | ||||
| 123 | $i++; | ||||
| 124 | } | ||||
| 125 | |||||
| 126 | 1 | 0s | my $class; | ||
| 127 | 1 | 5µs | 1 | 1µs | if ($item =~ m/^\:(.*)/) { # spent 1µs making 1 call to YAML::PP::Schema::CORE:match |
| 128 | $class = "$1"; | ||||
| 129 | unless ($class =~ m/\A[A-Za-z0-9_:]+\z/) { | ||||
| 130 | die "Module name '$class' is invalid"; | ||||
| 131 | } | ||||
| 132 | Module::Load::load $class; | ||||
| 133 | } | ||||
| 134 | else { | ||||
| 135 | 1 | 1µs | $class = "YAML::PP::Schema::$item"; | ||
| 136 | 1 | 7µs | 1 | 5µs | unless ($class =~ m/\A[A-Za-z0-9_:]+\z/) { # spent 5µs making 1 call to YAML::PP::Schema::CORE:match |
| 137 | die "Module name '$class' is invalid"; | ||||
| 138 | } | ||||
| 139 | 1 | 3µs | 1 | 3µs | $LOADED_SCHEMA{ $item } ||= Module::Load::load $class; # spent 3µs making 1 call to Module::Load::load |
| 140 | } | ||||
| 141 | 1 | 4µs | 1 | 473µs | $class->register( # spent 473µs making 1 call to YAML::PP::Schema::Core::register |
| 142 | schema => $self, | ||||
| 143 | options => \@options, | ||||
| 144 | ); | ||||
| 145 | |||||
| 146 | } | ||||
| 147 | } | ||||
| 148 | |||||
| 149 | # spent 187µs (178+9) within YAML::PP::Schema::add_resolver which was called 28 times, avg 7µs/call:
# 6 times (33µs+2µs) by YAML::PP::Schema::Core::register at line 59 of YAML/PP/Schema/Core.pm, avg 6µs/call
# 5 times (38µs+1000ns) by YAML::PP::Schema::Core::register at line 31 of YAML/PP/Schema/Core.pm, avg 8µs/call
# 3 times (20µs+1000ns) by YAML::PP::Schema::Core::register at line 63 of YAML/PP/Schema/Core.pm, avg 7µs/call
# 3 times (19µs+0s) by YAML::PP::Schema::Core::register at line 67 of YAML/PP/Schema/Core.pm, avg 6µs/call
# 3 times (18µs+1µs) by YAML::PP::Schema::Core::register at line 39 of YAML/PP/Schema/Core.pm, avg 6µs/call
# 3 times (15µs+3µs) by YAML::PP::Schema::Core::register at line 35 of YAML/PP/Schema/Core.pm, avg 6µs/call
# once (9µs+0s) by YAML::PP::Schema::Core::register at line 48 of YAML/PP/Schema/Core.pm
# once (8µs+0s) by YAML::PP::Schema::Core::register at line 52 of YAML/PP/Schema/Core.pm
# once (7µs+0s) by YAML::PP::Schema::Core::register at line 44 of YAML/PP/Schema/Core.pm
# once (6µs+0s) by YAML::PP::Schema::Core::register at line 40 of YAML/PP/Schema/Core.pm
# once (5µs+1000ns) by YAML::PP::Schema::Core::register at line 70 of YAML/PP/Schema/Core.pm | ||||
| 150 | 28 | 9µs | my ($self, %args) = @_; | ||
| 151 | 28 | 3µs | my $tag = $args{tag}; | ||
| 152 | 28 | 4µs | my $rule = $args{match}; | ||
| 153 | 28 | 13µs | 28 | 9µs | my $resolvers = $self->resolvers; # spent 9µs making 28 calls to YAML::PP::Schema::resolvers, avg 321ns/call |
| 154 | 28 | 6µs | my ($type, @rule) = @$rule; | ||
| 155 | 28 | 5µs | my $implicit = $args{implicit}; | ||
| 156 | 28 | 4µs | $implicit = 1 unless defined $implicit; | ||
| 157 | 28 | 6µs | my $resolver_list = []; | ||
| 158 | 28 | 5µs | if ($tag) { | ||
| 159 | 28 | 4µs | if (ref $tag eq 'Regexp') { | ||
| 160 | my $res = $resolvers->{tags} ||= []; | ||||
| 161 | push @$res, [ $tag, {} ]; | ||||
| 162 | push @$resolver_list, $res->[-1]->[1]; | ||||
| 163 | } | ||||
| 164 | else { | ||||
| 165 | 28 | 5µs | my $res = $resolvers->{tag}->{ $tag } ||= {}; | ||
| 166 | 28 | 4µs | push @$resolver_list, $res; | ||
| 167 | } | ||||
| 168 | } | ||||
| 169 | 28 | 6µs | if ($implicit) { | ||
| 170 | push @$resolver_list, $resolvers->{value} ||= {}; | ||||
| 171 | } | ||||
| 172 | 28 | 55µs | for my $res (@$resolver_list) { | ||
| 173 | 56 | 7µs | if ($type eq 'equals') { | ||
| 174 | 46 | 4µs | my ($match, $value) = @rule; | ||
| 175 | 46 | 27µs | unless (exists $res->{equals}->{ $match }) { | ||
| 176 | $res->{equals}->{ $match } = $value; | ||||
| 177 | } | ||||
| 178 | 46 | 6µs | next; | ||
| 179 | } | ||||
| 180 | elsif ($type eq 'regex') { | ||||
| 181 | 8 | 2µs | my ($match, $value) = @rule; | ||
| 182 | 8 | 5µs | push @{ $res->{regex} }, [ $match => $value ]; | ||
| 183 | } | ||||
| 184 | elsif ($type eq 'all') { | ||||
| 185 | 2 | 0s | my ($value) = @rule; | ||
| 186 | 2 | 0s | $res->{all} = $value; | ||
| 187 | } | ||||
| 188 | } | ||||
| 189 | } | ||||
| 190 | |||||
| 191 | sub add_sequence_resolver { | ||||
| 192 | my ($self, %args) = @_; | ||||
| 193 | return $self->add_collection_resolver(sequence => %args); | ||||
| 194 | } | ||||
| 195 | |||||
| 196 | sub add_mapping_resolver { | ||||
| 197 | my ($self, %args) = @_; | ||||
| 198 | return $self->add_collection_resolver(mapping => %args); | ||||
| 199 | } | ||||
| 200 | |||||
| 201 | sub add_collection_resolver { | ||||
| 202 | my ($self, $type, %args) = @_; | ||||
| 203 | my $tag = $args{tag}; | ||||
| 204 | my $implicit = $args{implicit}; | ||||
| 205 | my $resolvers = $self->resolvers; | ||||
| 206 | |||||
| 207 | if ($tag and ref $tag eq 'Regexp') { | ||||
| 208 | my $res = $resolvers->{ $type }->{tags} ||= []; | ||||
| 209 | push @$res, [ $tag, { | ||||
| 210 | on_create => $args{on_create}, | ||||
| 211 | on_data => $args{on_data}, | ||||
| 212 | } ]; | ||||
| 213 | } | ||||
| 214 | elsif ($tag) { | ||||
| 215 | my $res = $resolvers->{ $type }->{tag}->{ $tag } ||= { | ||||
| 216 | on_create => $args{on_create}, | ||||
| 217 | on_data => $args{on_data}, | ||||
| 218 | }; | ||||
| 219 | } | ||||
| 220 | } | ||||
| 221 | |||||
| 222 | # spent 111µs (99+12) within YAML::PP::Schema::add_representer which was called 28 times, avg 4µs/call:
# 23 times (72µs+8µs) by YAML::PP::Schema::Core::register at line 89 of YAML/PP/Schema/Core.pm, avg 3µs/call
# once (8µs+1µs) by YAML::PP::Schema::Core::register at line 75 of YAML/PP/Schema/Core.pm
# once (7µs+1000ns) by YAML::PP::Schema::Core::register at line 100 of YAML/PP/Schema/Core.pm
# once (6µs+1000ns) by YAML::PP::Schema::Core::register at line 83 of YAML/PP/Schema/Core.pm
# once (3µs+1000ns) by YAML::PP::Schema::Core::register at line 93 of YAML/PP/Schema/Core.pm
# once (3µs+0s) by YAML::PP::Schema::Core::register at line 79 of YAML/PP/Schema/Core.pm | ||||
| 223 | 28 | 7µs | my ($self, %args) = @_; | ||
| 224 | |||||
| 225 | 28 | 20µs | 28 | 12µs | my $representers = $self->representers; # spent 12µs making 28 calls to YAML::PP::Schema::representers, avg 429ns/call |
| 226 | 28 | 2µs | if (my $flags = $args{flags}) { | ||
| 227 | 2 | 1µs | my $rep = $representers->{flags}; | ||
| 228 | 2 | 0s | push @$rep, \%args; | ||
| 229 | 2 | 3µs | return; | ||
| 230 | } | ||||
| 231 | 26 | 1µs | if (my $regex = $args{regex}) { | ||
| 232 | 1 | 1µs | my $rep = $representers->{regex}; | ||
| 233 | 1 | 0s | push @$rep, \%args; | ||
| 234 | 1 | 2µs | return; | ||
| 235 | } | ||||
| 236 | 25 | 6µs | if (my $regex = $args{class_matches}) { | ||
| 237 | my $rep = $representers->{class_matches}; | ||||
| 238 | push @$rep, [ $args{class_matches}, $args{code} ]; | ||||
| 239 | return; | ||||
| 240 | } | ||||
| 241 | 25 | 3µs | if (my $class_equals = $args{class_equals}) { | ||
| 242 | 1 | 1µs | if ($] >= 5.036000 and $class_equals eq 'perl_experimental') { | ||
| 243 | $representers->{bool} = { | ||||
| 244 | code => $args{code}, | ||||
| 245 | }; | ||||
| 246 | return; | ||||
| 247 | } | ||||
| 248 | 1 | 1µs | my $rep = $representers->{class_equals}; | ||
| 249 | $rep->{ $class_equals } = { | ||||
| 250 | code => $args{code}, | ||||
| 251 | 1 | 1µs | }; | ||
| 252 | 1 | 3µs | return; | ||
| 253 | } | ||||
| 254 | 24 | 1µs | if (my $class_isa = $args{class_isa}) { | ||
| 255 | my $rep = $representers->{class_isa}; | ||||
| 256 | push @$rep, [ $args{class_isa}, $args{code} ]; | ||||
| 257 | return; | ||||
| 258 | } | ||||
| 259 | 24 | 3µs | if (my $tied_equals = $args{tied_equals}) { | ||
| 260 | my $rep = $representers->{tied_equals}; | ||||
| 261 | $rep->{ $tied_equals } = { | ||||
| 262 | code => $args{code}, | ||||
| 263 | }; | ||||
| 264 | return; | ||||
| 265 | } | ||||
| 266 | 24 | 6µs | if (defined(my $equals = $args{equals})) { | ||
| 267 | 23 | 4µs | my $rep = $representers->{equals}; | ||
| 268 | $rep->{ $equals } = { | ||||
| 269 | code => $args{code}, | ||||
| 270 | 23 | 12µs | }; | ||
| 271 | 23 | 23µs | return; | ||
| 272 | } | ||||
| 273 | 1 | 1µs | if (defined(my $scalarref = $args{scalarref})) { | ||
| 274 | $representers->{scalarref} = { | ||||
| 275 | code => $args{code}, | ||||
| 276 | }; | ||||
| 277 | return; | ||||
| 278 | } | ||||
| 279 | 1 | 0s | if (defined(my $refref = $args{refref})) { | ||
| 280 | $representers->{refref} = { | ||||
| 281 | code => $args{code}, | ||||
| 282 | }; | ||||
| 283 | return; | ||||
| 284 | } | ||||
| 285 | 1 | 1µs | if (defined(my $coderef = $args{coderef})) { | ||
| 286 | $representers->{coderef} = { | ||||
| 287 | code => $args{code}, | ||||
| 288 | }; | ||||
| 289 | return; | ||||
| 290 | } | ||||
| 291 | 1 | 0s | if (defined(my $glob = $args{glob})) { | ||
| 292 | $representers->{glob} = { | ||||
| 293 | code => $args{code}, | ||||
| 294 | }; | ||||
| 295 | return; | ||||
| 296 | } | ||||
| 297 | 1 | 1µs | if (my $undef = $args{undefined}) { | ||
| 298 | 1 | 0s | $representers->{undef} = $undef; | ||
| 299 | 1 | 2µs | return; | ||
| 300 | } | ||||
| 301 | } | ||||
| 302 | |||||
| 303 | # spent 468ms (307+161) within YAML::PP::Schema::load_scalar which was called 20764 times, avg 23µs/call:
# 20764 times (307ms+161ms) by YAML::PP::Constructor::scalar_event at line 287 of YAML/PP/Constructor.pm, avg 23µs/call | ||||
| 304 | 20764 | 3.34ms | my ($self, $constructor, $event) = @_; | ||
| 305 | 20764 | 4.40ms | my $tag = $event->{tag}; | ||
| 306 | 20764 | 5.35ms | my $value = $event->{value}; | ||
| 307 | |||||
| 308 | 20764 | 12.3ms | 20764 | 9.33ms | my $resolvers = $self->resolvers; # spent 9.33ms making 20764 calls to YAML::PP::Schema::resolvers, avg 449ns/call |
| 309 | 20764 | 2.64ms | my $res; | ||
| 310 | 20764 | 5.19ms | if ($tag) { | ||
| 311 | $res = $resolvers->{tag}->{ $tag }; | ||||
| 312 | if (not $res and my $matches = $resolvers->{tags}) { | ||||
| 313 | for my $match (@$matches) { | ||||
| 314 | my ($re, $rule) = @$match; | ||||
| 315 | if ($tag =~ $re) { | ||||
| 316 | $res = $rule; | ||||
| 317 | last; | ||||
| 318 | } | ||||
| 319 | } | ||||
| 320 | } | ||||
| 321 | } | ||||
| 322 | else { | ||||
| 323 | 20764 | 3.76ms | $res = $resolvers->{value}; | ||
| 324 | 20764 | 8.41ms | if ($event->{style} ne YAML_PLAIN_SCALAR_STYLE) { | ||
| 325 | return $value; | ||||
| 326 | } | ||||
| 327 | } | ||||
| 328 | |||||
| 329 | 18718 | 6.80ms | if (my $equals = $res->{equals}) { | ||
| 330 | 18718 | 12.9ms | if (exists $equals->{ $value }) { | ||
| 331 | 1003 | 472µs | my $res = $equals->{ $value }; | ||
| 332 | 1003 | 2.75ms | 969 | 5.23ms | if (ref $res eq 'CODE') { # spent 2.86ms making 566 calls to YAML::PP::Schema::_bool_jsonpp_true, avg 5µs/call
# spent 2.37ms making 403 calls to YAML::PP::Schema::_bool_jsonpp_false, avg 6µs/call |
| 333 | return $res->($constructor, $event); | ||||
| 334 | } | ||||
| 335 | 34 | 46µs | return $res; | ||
| 336 | } | ||||
| 337 | } | ||||
| 338 | 17715 | 5.70ms | if (my $regex = $res->{regex}) { | ||
| 339 | 17715 | 7.60ms | for my $item (@$regex) { | ||
| 340 | 70425 | 14.0ms | my ($re, $sub) = @$item; | ||
| 341 | 70425 | 258ms | 140850 | 131ms | my @matches = $value =~ $re; # spent 68.7ms making 70425 calls to YAML::PP::Schema::CORE:regcomp, avg 975ns/call
# spent 62.2ms making 70425 calls to YAML::PP::Schema::CORE:match, avg 884ns/call |
| 342 | 70425 | 24.5ms | 145 | 355µs | if (@matches) { # spent 355µs making 145 calls to YAML::PP::Schema::JSON::_to_int, avg 2µs/call |
| 343 | return $sub->($constructor, $event, \@matches); | ||||
| 344 | } | ||||
| 345 | } | ||||
| 346 | } | ||||
| 347 | 17570 | 4.38ms | if (my $catch_all = $res->{all}) { | ||
| 348 | 17570 | 42.2ms | 17570 | 15.1ms | if (ref $catch_all eq 'CODE') { # spent 15.1ms making 17570 calls to YAML::PP::Schema::Core::__ANON__[YAML/PP/Schema/Core.pm:70], avg 861ns/call |
| 349 | return $catch_all->($constructor, $event); | ||||
| 350 | } | ||||
| 351 | return $catch_all; | ||||
| 352 | } | ||||
| 353 | return $value; | ||||
| 354 | } | ||||
| 355 | |||||
| 356 | # spent 3.15ms (2.90+252µs) within YAML::PP::Schema::create_sequence which was called 636 times, avg 5µs/call:
# 636 times (2.90ms+252µs) by YAML::PP::Constructor::sequence_start_event at line 229 of YAML/PP/Constructor.pm, avg 5µs/call | ||||
| 357 | 636 | 161µs | my ($self, $constructor, $event) = @_; | ||
| 358 | 636 | 309µs | my $tag = $event->{tag}; | ||
| 359 | 636 | 314µs | my $data = []; | ||
| 360 | 636 | 113µs | my $on_data; | ||
| 361 | |||||
| 362 | 636 | 637µs | 636 | 252µs | my $resolvers = $self->resolvers->{sequence}; # spent 252µs making 636 calls to YAML::PP::Schema::resolvers, avg 396ns/call |
| 363 | 636 | 160µs | if ($tag) { | ||
| 364 | if (my $equals = $resolvers->{tag}->{ $tag }) { | ||||
| 365 | my $on_create = $equals->{on_create}; | ||||
| 366 | $on_data = $equals->{on_data}; | ||||
| 367 | $on_create and $data = $on_create->($constructor, $event); | ||||
| 368 | return ($data, $on_data); | ||||
| 369 | } | ||||
| 370 | if (my $matches = $resolvers->{tags}) { | ||||
| 371 | for my $match (@$matches) { | ||||
| 372 | my ($re, $actions) = @$match; | ||||
| 373 | my $on_create = $actions->{on_create}; | ||||
| 374 | if ($tag =~ $re) { | ||||
| 375 | $on_data = $actions->{on_data}; | ||||
| 376 | $on_create and $data = $on_create->($constructor, $event); | ||||
| 377 | return ($data, $on_data); | ||||
| 378 | } | ||||
| 379 | } | ||||
| 380 | } | ||||
| 381 | } | ||||
| 382 | |||||
| 383 | 636 | 1.10ms | return ($data, $on_data); | ||
| 384 | } | ||||
| 385 | |||||
| 386 | # spent 28.3ms (24.7+3.66) within YAML::PP::Schema::create_mapping which was called 6900 times, avg 4µs/call:
# 6900 times (24.7ms+3.66ms) by YAML::PP::Constructor::mapping_start_event at line 128 of YAML/PP/Constructor.pm, avg 4µs/call | ||||
| 387 | 6900 | 1.27ms | my ($self, $constructor, $event) = @_; | ||
| 388 | 6900 | 2.09ms | my $tag = $event->{tag}; | ||
| 389 | 6900 | 1.96ms | my $data = {}; | ||
| 390 | 6900 | 883µs | my $on_data; | ||
| 391 | |||||
| 392 | 6900 | 6.40ms | 6900 | 3.66ms | my $resolvers = $self->resolvers->{mapping}; # spent 3.66ms making 6900 calls to YAML::PP::Schema::resolvers, avg 531ns/call |
| 393 | 6900 | 1.00ms | if ($tag) { | ||
| 394 | if (my $equals = $resolvers->{tag}->{ $tag }) { | ||||
| 395 | my $on_create = $equals->{on_create}; | ||||
| 396 | $on_data = $equals->{on_data}; | ||||
| 397 | $on_create and $data = $on_create->($constructor, $event); | ||||
| 398 | return ($data, $on_data); | ||||
| 399 | } | ||||
| 400 | if (my $matches = $resolvers->{tags}) { | ||||
| 401 | for my $match (@$matches) { | ||||
| 402 | my ($re, $actions) = @$match; | ||||
| 403 | my $on_create = $actions->{on_create}; | ||||
| 404 | if ($tag =~ $re) { | ||||
| 405 | $on_data = $actions->{on_data}; | ||||
| 406 | $on_create and $data = $on_create->($constructor, $event); | ||||
| 407 | return ($data, $on_data); | ||||
| 408 | } | ||||
| 409 | } | ||||
| 410 | } | ||||
| 411 | } | ||||
| 412 | |||||
| 413 | 6900 | 9.63ms | return ($data, $on_data); | ||
| 414 | } | ||||
| 415 | |||||
| 416 | 566 | 2.01ms | 566 | 1.06ms | # spent 2.86ms (1.80+1.06) within YAML::PP::Schema::_bool_jsonpp_true which was called 566 times, avg 5µs/call:
# 566 times (1.80ms+1.06ms) by YAML::PP::Schema::load_scalar at line 332, avg 5µs/call # spent 1.06ms making 566 calls to JSON::PP::true, avg 2µs/call |
| 417 | |||||
| 418 | sub _bool_booleanpm_true { boolean::true() } | ||||
| 419 | |||||
| 420 | sub _bool_perl_true { !!1 } | ||||
| 421 | |||||
| 422 | 403 | 1.57ms | 403 | 815µs | # spent 2.37ms (1.56+815µs) within YAML::PP::Schema::_bool_jsonpp_false which was called 403 times, avg 6µs/call:
# 403 times (1.56ms+815µs) by YAML::PP::Schema::load_scalar at line 332, avg 6µs/call # spent 815µs making 403 calls to JSON::PP::false, avg 2µs/call |
| 423 | |||||
| 424 | sub _bool_booleanpm_false { boolean::false() } | ||||
| 425 | |||||
| 426 | sub _bool_perl_false { !!0 } | ||||
| 427 | |||||
| 428 | 1 | 4µs | 1; | ||
| 429 | |||||
| 430 | __END__ | ||||
# spent 62.2ms within YAML::PP::Schema::CORE:match which was called 70427 times, avg 884ns/call:
# 70425 times (62.2ms+0s) by YAML::PP::Schema::load_scalar at line 341, avg 884ns/call
# once (5µs+0s) by YAML::PP::Schema::load_subschemas at line 136
# once (1µs+0s) by YAML::PP::Schema::load_subschemas at line 127 | |||||
# spent 68.7ms within YAML::PP::Schema::CORE:regcomp which was called 70425 times, avg 975ns/call:
# 70425 times (68.7ms+0s) by YAML::PP::Schema::load_scalar at line 341, avg 975ns/call |