| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Vocabulary/Content.pm |
| Statements | Executed 376348 statements in 222ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 94075 | 2 | 1 | 160ms | 160ms | JSON::Schema::Modern::Vocabulary::Content::keywords |
| 1 | 1 | 1 | 34µs | 37µs | Module::Runtime::BEGIN@1.316 |
| 1 | 1 | 1 | 27µs | 181µs | JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentSchema |
| 1 | 1 | 1 | 23µs | 963µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@11 |
| 1 | 1 | 1 | 20µs | 50µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@13 |
| 1 | 1 | 1 | 15µs | 25µs | JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding |
| 1 | 1 | 1 | 14µs | 31µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@14 |
| 1 | 1 | 1 | 12µs | 24µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@15 |
| 1 | 1 | 1 | 12µs | 12µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@9 |
| 1 | 1 | 1 | 11µs | 36µs | JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType |
| 1 | 1 | 1 | 10µs | 23µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@16 |
| 1 | 1 | 1 | 9µs | 151µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@12 |
| 1 | 1 | 1 | 9µs | 34µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@18 |
| 1 | 1 | 1 | 8µs | 37µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@17 |
| 1 | 1 | 1 | 8µs | 37µs | Module::Runtime::BEGIN@2.317 |
| 1 | 1 | 1 | 7µs | 261µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@10 |
| 1 | 1 | 1 | 7µs | 39µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@19 |
| 1 | 1 | 1 | 7µs | 240µs | JSON::Schema::Modern::Vocabulary::Content::BEGIN@20 |
| 3 | 1 | 1 | 2µs | 2µs | JSON::Schema::Modern::Vocabulary::Content::evaluation_order |
| 1 | 1 | 1 | 1µs | 1µs | JSON::Schema::Modern::Vocabulary::Content::vocabulary |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Vocabulary::Content::_eval_keyword_contentEncoding |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Vocabulary::Content::_eval_keyword_contentMediaType |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Vocabulary::Content::_eval_keyword_contentSchema |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 35µs | 2 | 40µs | # spent 37µs (34+3) within Module::Runtime::BEGIN@1.316 which was called:
# once (34µs+3µs) by Module::Runtime::require_module at line 1 # spent 37µs making 1 call to Module::Runtime::BEGIN@1.316
# spent 3µs making 1 call to strict::import |
| 2 | 2 | 52µs | 2 | 66µs | # spent 37µs (8+29) within Module::Runtime::BEGIN@2.317 which was called:
# once (8µs+29µs) by Module::Runtime::require_module at line 2 # spent 37µs making 1 call to Module::Runtime::BEGIN@2.317
# spent 29µs making 1 call to warnings::import |
| 3 | package JSON::Schema::Modern::Vocabulary::Content; | ||||
| 4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||
| 5 | # ABSTRACT: Implementation of the JSON Schema Content vocabulary | ||||
| 6 | |||||
| 7 | 1 | 0s | our $VERSION = '0.552'; | ||
| 8 | |||||
| 9 | 2 | 38µs | 1 | 12µs | # spent 12µs within JSON::Schema::Modern::Vocabulary::Content::BEGIN@9 which was called:
# once (12µs+0s) by Module::Runtime::require_module at line 9 # spent 12µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@9 |
| 10 | 2 | 31µs | 2 | 515µs | # spent 261µs (7+254) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@10 which was called:
# once (7µs+254µs) by Module::Runtime::require_module at line 10 # spent 261µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@10
# spent 254µs making 1 call to Moo::import |
| 11 | 3 | 36µs | 3 | 1.90ms | # spent 963µs (23+940) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@11 which was called:
# once (23µs+940µs) by Module::Runtime::require_module at line 11 # spent 963µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@11
# spent 920µs making 1 call to strictures::import
# spent 19µs making 1 call to strictures::VERSION |
| 12 | 2 | 44µs | 2 | 293µs | # spent 151µs (9+142) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@12 which was called:
# once (9µs+142µs) by Module::Runtime::require_module at line 12 # spent 151µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@12
# spent 142µs making 1 call to experimental::import |
| 13 | 2 | 34µs | 2 | 53µs | # spent 50µs (20+30) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@13 which was called:
# once (20µs+30µs) by Module::Runtime::require_module at line 13 # spent 50µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@13
# spent 3µs making 1 call to if::import |
| 14 | 2 | 33µs | 2 | 33µs | # spent 31µs (14+17) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@14 which was called:
# once (14µs+17µs) by Module::Runtime::require_module at line 14 # spent 31µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@14
# spent 2µs making 1 call to if::unimport |
| 15 | 2 | 25µs | 2 | 26µs | # spent 24µs (12+12) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@15 which was called:
# once (12µs+12µs) by Module::Runtime::require_module at line 15 # spent 24µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@15
# spent 2µs making 1 call to if::unimport |
| 16 | 2 | 20µs | 2 | 24µs | # spent 23µs (10+13) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@16 which was called:
# once (10µs+13µs) by Module::Runtime::require_module at line 16 # spent 23µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@16
# spent 1µs making 1 call to if::unimport |
| 17 | 2 | 27µs | 2 | 66µs | # spent 37µs (8+29) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@17 which was called:
# once (8µs+29µs) by Module::Runtime::require_module at line 17 # spent 37µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@17
# spent 29µs making 1 call to Exporter::import |
| 18 | 2 | 23µs | 2 | 59µs | # spent 34µs (9+25) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@18 which was called:
# once (9µs+25µs) by Module::Runtime::require_module at line 18 # spent 34µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@18
# spent 25µs making 1 call to Feature::Compat::Try::import |
| 19 | 2 | 21µs | 2 | 71µs | # spent 39µs (7+32) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@19 which was called:
# once (7µs+32µs) by Module::Runtime::require_module at line 19 # spent 39µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@19
# spent 32µs making 1 call to Exporter::import |
| 20 | 2 | 660µs | 2 | 473µs | # spent 240µs (7+233) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@20 which was called:
# once (7µs+233µs) by Module::Runtime::require_module at line 20 # spent 240µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@20
# spent 233µs making 1 call to namespace::clean::import |
| 21 | |||||
| 22 | 1 | 2µs | 1 | 512µs | with 'JSON::Schema::Modern::Vocabulary'; # spent 512µs making 1 call to Moo::with |
| 23 | |||||
| 24 | # spent 1µs within JSON::Schema::Modern::Vocabulary::Content::vocabulary which was called:
# once (1µs+0s) by JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:670] at line 666 of JSON/Schema/Modern.pm | ||||
| 25 | 1 | 2µs | 'https://json-schema.org/draft/2019-09/vocab/content' => 'draft2019-09', | ||
| 26 | 'https://json-schema.org/draft/2020-12/vocab/content' => 'draft2020-12'; | ||||
| 27 | } | ||||
| 28 | |||||
| 29 | 3 | 6µs | # spent 2µs within JSON::Schema::Modern::Vocabulary::Content::evaluation_order which was called 3 times, avg 667ns/call:
# 3 times (2µs+0s) by JSON::Schema::Modern::Vocabulary::Core::CORE:sort at line 322 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 667ns/call | ||
| 30 | |||||
| 31 | 282225 | 42.1ms | # spent 160ms within JSON::Schema::Modern::Vocabulary::Content::keywords which was called 94075 times, avg 2µs/call:
# 91595 times (155ms+0s) by JSON::Schema::Modern::_eval_subschema at line 535 of JSON/Schema/Modern.pm, avg 2µs/call
# 2480 times (5.03ms+0s) by JSON::Schema::Modern::_traverse_subschema at line 447 of JSON/Schema/Modern.pm, avg 2µs/call | ||
| 32 | return ( | ||||
| 33 | 94075 | 179ms | qw(contentEncoding contentMediaType), | ||
| 34 | $spec_version ne 'draft7' ? 'contentSchema' : (), | ||||
| 35 | ); | ||||
| 36 | } | ||||
| 37 | |||||
| 38 | 4 | 1µs | # spent 25µs (15+10) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding which was called:
# once (15µs+10µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType at line 59 | ||
| 39 | 1 | 1µs | 1 | 10µs | return if not assert_keyword_type($state, $schema, 'string'); # spent 10µs making 1 call to JSON::Schema::Modern::Utilities::assert_keyword_type |
| 40 | 1 | 8µs | return 1; | ||
| 41 | } | ||||
| 42 | |||||
| 43 | sub _eval_keyword_contentEncoding ($self, $data, $schema, $state) { | ||||
| 44 | return 1 if not is_type('string', $data); | ||||
| 45 | |||||
| 46 | if ($state->{validate_content_schemas}) { | ||||
| 47 | my $decoder = $state->{evaluator}->get_encoding($schema->{contentEncoding}); | ||||
| 48 | abort($state, 'cannot find decoder for contentEncoding "%s"', $schema->{contentEncoding}) | ||||
| 49 | if not $decoder; | ||||
| 50 | |||||
| 51 | # decode the data now, so we can report errors for the right keyword | ||||
| 52 | try { $state->{_content_ref} = $decoder->(\$data) } | ||||
| 53 | catch ($e) { return E($state, $e) } | ||||
| 54 | } | ||||
| 55 | |||||
| 56 | return A($state, $schema->{$state->{keyword}}) | ||||
| 57 | } | ||||
| 58 | |||||
| 59 | 1 | 14µs | 1 | 25µs | # spent 36µs (11+25) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType which was called:
# once (11µs+25µs) by JSON::Schema::Modern::_traverse_subschema at line 457 of JSON/Schema/Modern.pm # spent 25µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding |
| 60 | |||||
| 61 | sub _eval_keyword_contentMediaType ($self, $data, $schema, $state) { | ||||
| 62 | return 1 if not is_type('string', $data); | ||||
| 63 | |||||
| 64 | if ($state->{validate_content_schemas}) { | ||||
| 65 | my $decoder = $state->{evaluator}->get_media_type($schema->{contentMediaType}); | ||||
| 66 | abort($state, 'cannot find decoder for contentMediaType "%s"', $schema->{contentMediaType}) | ||||
| 67 | if not $decoder; | ||||
| 68 | |||||
| 69 | # contentEncoding failed to decode the content | ||||
| 70 | return 1 if exists $schema->{contentEncoding} and not exists $state->{_content_ref}; | ||||
| 71 | |||||
| 72 | # decode the data now, so we can report errors for the right keyword | ||||
| 73 | try { $state->{_content_ref} = $decoder->($state->{_content_ref} // \$data) } | ||||
| 74 | catch ($e) { return E($state, $e) } | ||||
| 75 | } | ||||
| 76 | |||||
| 77 | return A($state, $schema->{$state->{keyword}}) | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | 4 | 2µs | # spent 181µs (27+154) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentSchema which was called:
# once (27µs+154µs) by JSON::Schema::Modern::_traverse_subschema at line 457 of JSON/Schema/Modern.pm | ||
| 81 | # since contentSchema should never be assumed to be evaluated in the context of the containing | ||||
| 82 | # schema, it is not appropriate to gather identifiers found therein -- but we can still validate | ||||
| 83 | # the subschema. | ||||
| 84 | 1 | 18µs | 1 | 154µs | $self->traverse_subschema($schema, +{ %$state, identifiers => [] }); # spent 154µs making 1 call to JSON::Schema::Modern::Vocabulary::traverse_subschema |
| 85 | } | ||||
| 86 | |||||
| 87 | sub _eval_keyword_contentSchema ($self, $data, $schema, $state) { | ||||
| 88 | return 1 if not exists $schema->{contentMediaType}; | ||||
| 89 | return 1 if not is_type('string', $data); | ||||
| 90 | |||||
| 91 | return A($state, dclone($schema->{contentSchema})) if not $state->{validate_content_schemas}; | ||||
| 92 | |||||
| 93 | return 1 if not exists $state->{_content_ref}; # contentMediaType failed to decode the content | ||||
| 94 | |||||
| 95 | return 1 if $self->eval($state->{_content_ref}->$*, $schema->{contentSchema}, | ||||
| 96 | { %$state, schema_path => $state->{schema_path}.'/contentSchema' }); | ||||
| 97 | return E($state, 'subschema is not valid'); | ||||
| 98 | } | ||||
| 99 | |||||
| 100 | 1 | 8µs | 1; | ||
| 101 | |||||
| 102 | 1 | 31µs | 1 | 375µs | __END__ # spent 375µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |