← 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/OpenAPI.pm
StatementsExecuted 36 statements in 838µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
331219µs219µsModule::Runtime::::CORE:regcomp Module::Runtime::CORE:regcomp (opcode)
3521112µs112µsModule::Runtime::::CORE:match Module::Runtime::CORE:match (opcode)
301164µs64µsModule::Runtime::::CORE:subst Module::Runtime::CORE:subst (opcode)
11148µs51µsModule::Runtime::::BEGIN@1.321 Module::Runtime::BEGIN@1.321
11147µs641µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@11JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@11
51118µs18µsJSON::Schema::Modern::Vocabulary::OpenAPI::::_traverse_keyword_externalDocsJSON::Schema::Modern::Vocabulary::OpenAPI::_traverse_keyword_externalDocs
11114µs33µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@13JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@13
11111µs50µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@17JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@17
66111µs11µsModule::Runtime::::CORE:qr Module::Runtime::CORE:qr (opcode)
11110µs19µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@15JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@15
11110µs10µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@9JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@9
1118µs24µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@14JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@14
1117µs17µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@16JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@16
1115µs188µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@10JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@10
1115µs144µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@18JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@18
1115µs36µsModule::Runtime::::BEGIN@2.322 Module::Runtime::BEGIN@2.322
1114µs90µsJSON::Schema::Modern::Vocabulary::OpenAPI::::BEGIN@12JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@12
1113µs3µsJSON::Schema::Modern::Vocabulary::OpenAPI::::keywordsJSON::Schema::Modern::Vocabulary::OpenAPI::keywords
0000s0sJSON::Schema::Modern::Vocabulary::OpenAPI::::_eval_keyword_discriminatorJSON::Schema::Modern::Vocabulary::OpenAPI::_eval_keyword_discriminator
0000s0sJSON::Schema::Modern::Vocabulary::OpenAPI::::_eval_keyword_exampleJSON::Schema::Modern::Vocabulary::OpenAPI::_eval_keyword_example
0000s0sJSON::Schema::Modern::Vocabulary::OpenAPI::::_eval_keyword_externalDocsJSON::Schema::Modern::Vocabulary::OpenAPI::_eval_keyword_externalDocs
0000s0sJSON::Schema::Modern::Vocabulary::OpenAPI::::_eval_keyword_xmlJSON::Schema::Modern::Vocabulary::OpenAPI::_eval_keyword_xml
0000s0sJSON::Schema::Modern::Vocabulary::OpenAPI::::_traverse_keyword_discriminatorJSON::Schema::Modern::Vocabulary::OpenAPI::_traverse_keyword_discriminator
0000s0sJSON::Schema::Modern::Vocabulary::OpenAPI::::_traverse_keyword_exampleJSON::Schema::Modern::Vocabulary::OpenAPI::_traverse_keyword_example
0000s0sJSON::Schema::Modern::Vocabulary::OpenAPI::::_traverse_keyword_xmlJSON::Schema::Modern::Vocabulary::OpenAPI::_traverse_keyword_xml
1110s0sJSON::Schema::Modern::Vocabulary::OpenAPI::::vocabularyJSON::Schema::Modern::Vocabulary::OpenAPI::vocabulary
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1231µs254µs
# spent 51µs (48+3) within Module::Runtime::BEGIN@1.321 which was called: # once (48µs+3µs) by Module::Runtime::require_module at line 1
use strict;
# spent 51µs making 1 call to Module::Runtime::BEGIN@1.321 # spent 3µs making 1 call to strict::import
2240µs267µs
# spent 36µs (5+31) within Module::Runtime::BEGIN@2.322 which was called: # once (5µs+31µs) by Module::Runtime::require_module at line 2
use warnings;
# spent 36µs making 1 call to Module::Runtime::BEGIN@2.322 # spent 31µs making 1 call to warnings::import
3package JSON::Schema::Modern::Vocabulary::OpenAPI;
4# vim: set ts=8 sts=2 sw=2 tw=100 et :
5# ABSTRACT: Implementation of the JSON Schema OpenAPI vocabulary
6
710sour $VERSION = '0.037';
8
9227µs110µs
# spent 10µs within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@9 which was called: # once (10µs+0s) by Module::Runtime::require_module at line 9
use 5.020;
10221µs2371µs
# spent 188µs (5+183) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@10 which was called: # once (5µs+183µs) by Module::Runtime::require_module at line 10
use Moo;
# spent 188µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@10 # spent 183µs making 1 call to Moo::import
11326µs31.23ms
# spent 641µs (47+594) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@11 which was called: # once (47µs+594µs) by Module::Runtime::require_module at line 11
use strictures 2;
# spent 641µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@11 # spent 576µs making 1 call to strictures::import # spent 18µs making 1 call to strictures::VERSION
12229µs2176µs
# spent 90µs (4+86) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@12 which was called: # once (4µs+86µs) by Module::Runtime::require_module at line 12
use experimental qw(signatures postderef);
# spent 90µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@12 # spent 86µs making 1 call to experimental::import
13223µs235µs
# spent 33µs (14+19) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@13 which was called: # once (14µs+19µs) by Module::Runtime::require_module at line 13
use if "$]" >= 5.022, experimental => 're_strict';
# spent 33µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@13 # spent 2µs making 1 call to if::import
14217µs226µs
# spent 24µs (8+16) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@14 which was called: # once (8µs+16µs) by Module::Runtime::require_module at line 14
no if "$]" >= 5.031009, feature => 'indirect';
# spent 24µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@14 # spent 2µs making 1 call to if::unimport
15216µs219µs
# spent 19µs (10+9) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@15 which was called: # once (10µs+9µs) by Module::Runtime::require_module at line 15
no if "$]" >= 5.033001, feature => 'multidimensional';
# spent 19µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@15 # spent 0s making 1 call to if::unimport
16217µs217µs
# spent 17µs (7+10) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@16 which was called: # once (7µs+10µs) by Module::Runtime::require_module at line 16
no if "$]" >= 5.033006, feature => 'bareword_filehandles';
# spent 17µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@16 # spent 0s making 1 call to if::unimport
17327µs389µs
# spent 50µs (11+39) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@17 which was called: # once (11µs+39µs) by Module::Runtime::require_module at line 17
use JSON::Schema::Modern::Utilities 0.524 qw(assert_keyword_type annotate_self E is_type jsonp);
# spent 50µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@17 # spent 35µs making 1 call to Exporter::import # spent 4µs making 1 call to UNIVERSAL::VERSION
182527µs2283µs
# spent 144µs (5+139) within JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@18 which was called: # once (5µs+139µs) by Module::Runtime::require_module at line 18
use namespace::clean;
# spent 144µs making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::BEGIN@18 # spent 139µs making 1 call to namespace::clean::import
19
2011µs1299µswith 'JSON::Schema::Modern::Vocabulary';
# spent 299µs making 1 call to Moo::with
21
22
# spent 0s within JSON::Schema::Modern::Vocabulary::OpenAPI::vocabulary which was called: # once (0s+0s) by JSON::Schema::Modern::add_vocabulary at line 709 of JSON/Schema/Modern.pm
sub vocabulary {
2312µs 'https://spec.openapis.org/oas/3.1/vocab/base' => 'draft2020-12',
24}
25
26
# spent 3µs within JSON::Schema::Modern::Vocabulary::OpenAPI::keywords which was called: # once (3µs+0s) by JSON::Schema::Modern::_traverse_subschema at line 475 of JSON/Schema/Modern.pm
sub keywords {
2713µs qw(discriminator example externalDocs xml);
28}
29
30sub _traverse_keyword_discriminator ($self, $schema, $state) {
31 return if not assert_keyword_type($state, $schema, 'object');
32
33 # "the discriminator field MUST be a required field"
34 return E($state, 'missing required field propertyName')
35 if not exists $schema->{discriminator}{propertyName};
36 return E({ %$state, _schema_path_suffix => 'propertyName' }, 'discriminator propertyName is not a string')
37 if not is_type('string', $schema->{discriminator}{propertyName});
38
39 my $valid = 1;
40 if (exists $schema->{discriminator}{mapping}) {
41 return if not assert_keyword_type({ %$state, _schema_path_suffix => 'mapping' }, $schema, 'object');
42 return E({ %$state, _schema_path_suffix => 'mapping' }, 'discriminator mapping is not an object ')
43 if not is_type('object', $schema->{discriminator}{mapping});
44 foreach my $mapping_key (sort keys $schema->{discriminator}{mapping}->%*) {
45 my $uri = $schema->{discriminator}{mapping}{$mapping_key};
46 $valid = E({ %$state, _schema_path_suffix => [ 'mapping', $mapping_key ] }, 'discriminator mapping value for "%s" is not a string', $mapping_key), next if not is_type('string', $uri);
47 }
48 }
49
50 $valid = E($state, 'missing sibling keyword: one of oneOf, anyOf, allOf')
51 if not grep exists $schema->{$_}, qw(oneOf anyOf allOf);
52
53 return 1;
54}
55
56sub _eval_keyword_discriminator ($self, $data, $schema, $state) {
57 # Note: the spec is unclear of the expected behaviour when the data instance is not an object
58 return 1 if not is_type('object', $data);
59
60 my $discriminator_key = $schema->{discriminator}{propertyName};
61
62 # property with name <propertyName> MUST be present in the data payload
63 return E($state, 'missing required discriminator field "%s"', $discriminator_key)
64 if not exists $data->{$discriminator_key};
65
66 my $discriminator_value = $data->{$discriminator_key};
67
68 # if /components/$discriminator_value exists, that schema must validate
69 my $uri = Mojo::URL->new->fragment(jsonp('', qw(components schemas), $discriminator_value))
70 ->to_abs($state->{initial_schema_uri});
71 if (my $component_schema_info = $state->{evaluator}->_fetch_from_uri($uri)) {
72 $state = { %$state, _schema_path_suffix => 'propertyName' };
73 }
74 elsif (exists $schema->{discriminator}{mapping} and exists $schema->{discriminator}{mapping}{$discriminator_value}) {
75 # use 'mapping' to determine which schema to use.
76 $uri = Mojo::URL->new($schema->{discriminator}{mapping}{$discriminator_value});
77 $state = { %$state, _schema_path_suffix => [ 'mapping', $discriminator_value ] };
78 }
79 else {
80 # If the discriminator value does not match an implicit or explicit mapping, no schema can be
81 # determined and validation SHOULD fail.
82 return E($state, 'invalid %s: "%s"', $discriminator_key, $discriminator_value);
83 }
84
85 return E($state, 'subschema for %s: %s is invalid', $discriminator_key, $discriminator_value)
86 if not $self->eval_subschema_at_uri($data, $schema, $state, $uri);
87 return 1;
88}
89
90sub _traverse_keyword_example { 1 }
91
92sub _eval_keyword_example ($self, $data, $schema, $state) {
93 annotate_self($state, $schema);
94}
95
96# until we do something with these values, we do not bother checking the structure
97513µs
# spent 18µs within JSON::Schema::Modern::Vocabulary::OpenAPI::_traverse_keyword_externalDocs which was called 5 times, avg 4µs/call: # 5 times (18µs+0s) by JSON::Schema::Modern::_traverse_subschema at line 487 of JSON/Schema/Modern.pm, avg 4µs/call
sub _traverse_keyword_externalDocs { 1 }
98
99sub _eval_keyword_externalDocs { goto \&_eval_keyword_example }
100
101# until we do something with these values, we do not bother checking the structure
102sub _traverse_keyword_xml { 1 }
103
104sub _eval_keyword_xml { goto \&_eval_keyword_example }
105
10614µs1;
107
108114µs1285µs__END__
 
# spent 112µs within Module::Runtime::CORE:match which was called 35 times, avg 3µs/call: # 30 times (107µs+0s) by Module::Runtime::is_module_name at line 219 of Module/Runtime.pm, avg 4µs/call # 5 times (5µs+0s) by Module::Runtime::import at line 140 of Module/Runtime.pm, avg 1µs/call
sub Module::Runtime::CORE:match; # opcode
# spent 11µs within Module::Runtime::CORE:qr which was called 6 times, avg 2µs/call: # once (3µs+0s) by JSON::Schema::Modern::BEGIN@28 at line 185 of Module/Runtime.pm # once (3µs+0s) by JSON::Schema::Modern::BEGIN@28 at line 176 of Module/Runtime.pm # once (2µs+0s) by JSON::Schema::Modern::BEGIN@28 at line 191 of Module/Runtime.pm # once (1µs+0s) by JSON::Schema::Modern::BEGIN@28 at line 200 of Module/Runtime.pm # once (1µs+0s) by JSON::Schema::Modern::BEGIN@28 at line 188 of Module/Runtime.pm # once (1µs+0s) by JSON::Schema::Modern::BEGIN@28 at line 202 of Module/Runtime.pm
sub Module::Runtime::CORE:qr; # opcode
# spent 219µs within Module::Runtime::CORE:regcomp which was called 3 times, avg 73µs/call: # once (142µs+0s) by JSON::Schema::Modern::BEGIN@28 at line 191 of Module/Runtime.pm # once (57µs+0s) by JSON::Schema::Modern::BEGIN@28 at line 202 of Module/Runtime.pm # once (20µs+0s) by Module::Runtime::is_module_name at line 219 of Module/Runtime.pm
sub Module::Runtime::CORE:regcomp; # opcode
# spent 64µs within Module::Runtime::CORE:subst which was called 30 times, avg 2µs/call: # 30 times (64µs+0s) by Module::Runtime::module_notional_filename at line 263 of Module/Runtime.pm, avg 2µs/call
sub Module::Runtime::CORE:subst; # opcode