← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 16:10:05 2022
Reported on Wed Dec 14 16:12:58 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Vocabulary/Content.pm
StatementsExecuted 56 statements in 845µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11151µs63µsJSON::Schema::Modern::Vocabulary::Content::::_traverse_keyword_contentMediaTypeJSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType
11127µs29µsModule::Runtime::::BEGIN@1.317 Module::Runtime::BEGIN@1.317
11120µs92µsJSON::Schema::Modern::Vocabulary::Content::::_traverse_keyword_contentSchemaJSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentSchema
11113µs21µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@14JSON::Schema::Modern::Vocabulary::Content::BEGIN@14
11111µs569µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@11JSON::Schema::Modern::Vocabulary::Content::BEGIN@11
1119µs24µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@13JSON::Schema::Modern::Vocabulary::Content::BEGIN@13
1118µs8µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@9JSON::Schema::Modern::Vocabulary::Content::BEGIN@9
1116µs25µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@17JSON::Schema::Modern::Vocabulary::Content::BEGIN@17
1116µs20µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@18JSON::Schema::Modern::Vocabulary::Content::BEGIN@18
1115µs189µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@10JSON::Schema::Modern::Vocabulary::Content::BEGIN@10
1115µs13µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@15JSON::Schema::Modern::Vocabulary::Content::BEGIN@15
1115µs16µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@16JSON::Schema::Modern::Vocabulary::Content::BEGIN@16
1115µs138µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@20JSON::Schema::Modern::Vocabulary::Content::BEGIN@20
1115µs12µsJSON::Schema::Modern::Vocabulary::Content::::_traverse_keyword_contentEncodingJSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding
2215µs5µsJSON::Schema::Modern::Vocabulary::Content::::keywordsJSON::Schema::Modern::Vocabulary::Content::keywords
1114µs74µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@12JSON::Schema::Modern::Vocabulary::Content::BEGIN@12
1114µs29µsJSON::Schema::Modern::Vocabulary::Content::::BEGIN@19JSON::Schema::Modern::Vocabulary::Content::BEGIN@19
1114µs25µsModule::Runtime::::BEGIN@2.318 Module::Runtime::BEGIN@2.318
3111µs1µsJSON::Schema::Modern::Vocabulary::Content::::evaluation_orderJSON::Schema::Modern::Vocabulary::Content::evaluation_order
1111µs1µsJSON::Schema::Modern::Vocabulary::Content::::vocabularyJSON::Schema::Modern::Vocabulary::Content::vocabulary
0000s0sJSON::Schema::Modern::Vocabulary::Content::::_eval_keyword_contentEncodingJSON::Schema::Modern::Vocabulary::Content::_eval_keyword_contentEncoding
0000s0sJSON::Schema::Modern::Vocabulary::Content::::_eval_keyword_contentMediaTypeJSON::Schema::Modern::Vocabulary::Content::_eval_keyword_contentMediaType
0000s0sJSON::Schema::Modern::Vocabulary::Content::::_eval_keyword_contentSchemaJSON::Schema::Modern::Vocabulary::Content::_eval_keyword_contentSchema
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1227µs231µs
# spent 29µs (27+2) within Module::Runtime::BEGIN@1.317 which was called: # once (27µs+2µs) by Module::Runtime::require_module at line 1
use strict;
# spent 29µs making 1 call to Module::Runtime::BEGIN@1.317 # spent 2µs making 1 call to strict::import
2234µs246µs
# spent 25µs (4+21) within Module::Runtime::BEGIN@2.318 which was called: # once (4µs+21µs) by Module::Runtime::require_module at line 2
use warnings;
# spent 25µs making 1 call to Module::Runtime::BEGIN@2.318 # spent 21µs making 1 call to warnings::import
3package 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
711µsour $VERSION = '0.558';
8
9226µs18µs
# spent 8µs within JSON::Schema::Modern::Vocabulary::Content::BEGIN@9 which was called: # once (8µs+0s) by Module::Runtime::require_module at line 9
use 5.020;
10221µs2373µs
# spent 189µs (5+184) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@10 which was called: # once (5µs+184µs) by Module::Runtime::require_module at line 10
use Moo;
# spent 189µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@10 # spent 184µs making 1 call to Moo::import
11325µs31.13ms
# spent 569µs (11+558) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@11 which was called: # once (11µs+558µs) by Module::Runtime::require_module at line 11
use strictures 2;
# spent 569µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@11 # spent 545µs making 1 call to strictures::import # spent 13µs making 1 call to strictures::VERSION
12226µs2144µs
# spent 74µs (4+70) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@12 which was called: # once (4µs+70µs) by Module::Runtime::require_module at line 12
use experimental qw(signatures postderef);
# spent 74µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@12 # spent 70µs making 1 call to experimental::import
13223µs224µs
# spent 24µs (9+15) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@13 which was called: # once (9µs+15µs) by Module::Runtime::require_module at line 13
use if "$]" >= 5.022, experimental => 're_strict';
# spent 24µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@13 # spent 0s making 1 call to if::import
14217µs222µs
# spent 21µs (13+8) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@14 which was called: # once (13µs+8µs) by Module::Runtime::require_module at line 14
no if "$]" >= 5.031009, feature => 'indirect';
# spent 21µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@14 # spent 1µs making 1 call to if::unimport
15214µs214µs
# spent 13µs (5+8) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@15 which was called: # once (5µs+8µs) by Module::Runtime::require_module at line 15
no if "$]" >= 5.033001, feature => 'multidimensional';
# spent 13µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@15 # spent 1µs making 1 call to if::unimport
16212µs217µs
# spent 16µs (5+11) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@16 which was called: # once (5µs+11µs) by Module::Runtime::require_module at line 16
no if "$]" >= 5.033006, feature => 'bareword_filehandles';
# spent 16µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@16 # spent 1µs making 1 call to if::unimport
17217µs244µs
# spent 25µs (6+19) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@17 which was called: # once (6µs+19µs) by Module::Runtime::require_module at line 17
use Storable 'dclone';
# spent 25µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@17 # spent 19µs making 1 call to Exporter::import
18215µs234µs
# spent 20µs (6+14) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@18 which was called: # once (6µs+14µs) by Module::Runtime::require_module at line 18
use Feature::Compat::Try;
# spent 20µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@18 # spent 14µs making 1 call to Feature::Compat::Try::import
19216µs254µs
# spent 29µs (4+25) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@19 which was called: # once (4µs+25µs) by Module::Runtime::require_module at line 19
use JSON::Schema::Modern::Utilities qw(is_type A assert_keyword_type E abort);
# spent 29µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@19 # spent 25µs making 1 call to Exporter::import
202452µs2271µs
# spent 138µs (5+133) within JSON::Schema::Modern::Vocabulary::Content::BEGIN@20 which was called: # once (5µs+133µs) by Module::Runtime::require_module at line 20
use namespace::clean;
# spent 138µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::BEGIN@20 # spent 133µs making 1 call to namespace::clean::import
21
2211µs1359µswith 'JSON::Schema::Modern::Vocabulary';
# spent 359µ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:700] at line 696 of JSON/Schema/Modern.pm
sub vocabulary {
2512µ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
2933µs
# spent 1µs within JSON::Schema::Modern::Vocabulary::Content::evaluation_order which was called 3 times, avg 333ns/call: # 3 times (1µs+0s) by JSON::Schema::Modern::Vocabulary::Core::CORE:sort at line 331 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 333ns/call
sub evaluation_order { 4 }
30
3161µs
# spent 5µs within JSON::Schema::Modern::Vocabulary::Content::keywords which was called 2 times, avg 2µs/call: # once (4µs+0s) by JSON::Schema::Modern::_traverse_subschema at line 475 of JSON/Schema/Modern.pm # once (1µs+0s) by JSON::Schema::Modern::_eval_subschema at line 563 of JSON/Schema/Modern.pm
sub keywords ($self, $spec_version) {
32 return (
3325µs qw(contentEncoding contentMediaType),
34 $spec_version ne 'draft7' ? 'contentSchema' : (),
35 );
36}
37
3840s
# spent 12µs (5+7) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding which was called: # once (5µs+7µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType at line 66
sub _traverse_keyword_contentEncoding ($self, $schema, $state) {
3912µs17µs return if not assert_keyword_type($state, $schema, 'string');
4013µs return 1;
41}
42
43sub _eval_keyword_contentEncoding ($self, $data, $schema, $state) {
44 return 1 if not is_type('string', $data);
45
46 A($state, $schema->{$state->{keyword}});
47
48 if ($state->{validate_content_schemas}) {
49 my $decoder = $state->{evaluator}->get_encoding($schema->{contentEncoding});
50 abort($state, 'cannot find decoder for contentEncoding "%s"', $schema->{contentEncoding})
51 if not $decoder;
52
53 # decode the data now, so we can report errors for the right keyword
54 try {
55 $state->{_content_ref} = $decoder->(\$data);
56 }
57 catch ($e) {
58 chomp $e;
59 return E($state, 'could not decode %s string: %s', $schema->{contentEncoding}, $e);
60 };
61 }
62
63 return 1;
64}
65
66136µs112µs
# spent 63µs (51+12) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType which was called: # once (51µs+12µs) by JSON::Schema::Modern::_traverse_subschema at line 487 of JSON/Schema/Modern.pm
sub _traverse_keyword_contentMediaType { shift->_traverse_keyword_contentEncoding(@_) }
67
68sub _eval_keyword_contentMediaType ($self, $data, $schema, $state) {
69 return 1 if not is_type('string', $data);
70
71 A($state, $schema->{$state->{keyword}});
72
73 if ($state->{validate_content_schemas}) {
74 my $decoder = $state->{evaluator}->get_media_type($schema->{contentMediaType});
75 abort($state, 'cannot find decoder for contentMediaType "%s"', $schema->{contentMediaType})
76 if not $decoder;
77
78 # contentEncoding failed to decode the content
79 return 1 if exists $schema->{contentEncoding} and not exists $state->{_content_ref};
80
81 # decode the data now, so we can report errors for the right keyword
82 try {
83 $state->{_content_ref} = $decoder->($state->{_content_ref} // \$data);
84 }
85 catch ($e) {
86 chomp $e;
87 delete $state->{_content_ref};
88 return E($state, 'could not decode %s string: %s', $schema->{contentMediaType}, $e);
89 }
90 }
91
92 return 1;
93}
94
9546µs
# spent 92µs (20+72) within JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentSchema which was called: # once (20µs+72µs) by JSON::Schema::Modern::_traverse_subschema at line 487 of JSON/Schema/Modern.pm
sub _traverse_keyword_contentSchema ($self, $schema, $state) {
96 # since contentSchema should never be assumed to be evaluated in the context of the containing
97 # schema, it is not appropriate to gather identifiers found therein -- but we can still validate
98 # the subschema.
99110µs172µs $self->traverse_subschema($schema, +{ %$state, identifiers => [] });
100}
101
102sub _eval_keyword_contentSchema ($self, $data, $schema, $state) {
103 return 1 if not exists $schema->{contentMediaType};
104 return 1 if not is_type('string', $data);
105
106 A($state, dclone($schema->{contentSchema}));
107 return 1 if not $state->{validate_content_schemas};
108
109 return 1 if not exists $state->{_content_ref}; # contentMediaType failed to decode the content
110
111 return 1 if $self->eval($state->{_content_ref}->$*, $schema->{contentSchema},
112 { %$state, schema_path => $state->{schema_path}.'/contentSchema' });
113 return E($state, 'subschema is not valid');
114}
115
11615µs1;
117
118145µs1229µs__END__