← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:33:55 2022
Reported on Wed Dec 14 15:40:04 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Utilities.pm
StatementsExecuted 4032517 statements in 5.67s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
168591541.74s8.21sJSON::Schema::Modern::Utilities::::canonical_uriJSON::Schema::Modern::Utilities::canonical_uri
72039741.48s17.8sJSON::Schema::Modern::Utilities::::AJSON::Schema::Modern::Utilities::A
3140391341.22s1.38sJSON::Schema::Modern::Utilities::::jsonpJSON::Schema::Modern::Utilities::jsonp
374711499ms805msJSON::Schema::Modern::Utilities::::local_annotationsJSON::Schema::Modern::Utilities::local_annotations
16318054445ms612msJSON::Schema::Modern::Utilities::::get_typeJSON::Schema::Modern::Utilities::get_type
74094235241ms338msJSON::Schema::Modern::Utilities::::is_typeJSON::Schema::Modern::Utilities::is_type
46997811156ms156msJSON::Schema::Modern::Utilities::::CORE:substJSON::Schema::Modern::Utilities::CORE:subst (opcode)
3221411147ms7.88sJSON::Schema::Modern::Utilities::::annotate_selfJSON::Schema::Modern::Utilities::annotate_self
421752113ms1.14sJSON::Schema::Modern::Utilities::::EJSON::Schema::Modern::Utilities::E
165406292.5ms331msJSON::Schema::Modern::Utilities::::is_equalJSON::Schema::Modern::Utilities::is_equal (recurses: max depth 2, inclusive time 93µs)
7015118.4ms147msJSON::Schema::Modern::Utilities::::is_elements_uniqueJSON::Schema::Modern::Utilities::is_elements_unique
358524818.2ms44.3msJSON::Schema::Modern::Utilities::::assert_keyword_typeJSON::Schema::Modern::Utilities::assert_keyword_type
7392112.3ms158msJSON::Schema::Modern::Utilities::::assert_uri_referenceJSON::Schema::Modern::Utilities::assert_uri_reference
3869415.13ms5.13msJSON::Schema::Modern::Utilities::::CORE:matchJSON::Schema::Modern::Utilities::CORE:match (opcode)
76111.92ms1.92msJSON::Schema::Modern::Utilities::::CORE:regcompJSON::Schema::Modern::Utilities::CORE:regcomp (opcode)
76221.23ms3.22msJSON::Schema::Modern::Utilities::::assert_patternJSON::Schema::Modern::Utilities::assert_pattern
4621634µs7.05msJSON::Schema::Modern::Utilities::::assert_uriJSON::Schema::Modern::Utilities::assert_uri
11162µs923µsJSON::Schema::Modern::Utilities::::BEGIN@10JSON::Schema::Modern::Utilities::BEGIN@10
761160µs60µsJSON::Schema::Modern::Utilities::::CORE:qrJSON::Schema::Modern::Utilities::CORE:qr (opcode)
11128µs31µsJSON::Schema::Modern::::BEGIN@1.158 JSON::Schema::Modern::BEGIN@1.158
11122µs23µsJSON::Schema::Modern::Utilities::::BEGIN@23JSON::Schema::Modern::Utilities::BEGIN@23
11116µs16µsJSON::Schema::Modern::Utilities::::BEGIN@24JSON::Schema::Modern::Utilities::BEGIN@24
11115µs53µsJSON::Schema::Modern::Utilities::::BEGIN@12JSON::Schema::Modern::Utilities::BEGIN@12
11115µs57µsJSON::Schema::Modern::Utilities::::BEGIN@18JSON::Schema::Modern::Utilities::BEGIN@18
11115µs77µsJSON::Schema::Modern::Utilities::::BEGIN@53JSON::Schema::Modern::Utilities::BEGIN@53
11113µs32µsJSON::Schema::Modern::Utilities::::BEGIN@13JSON::Schema::Modern::Utilities::BEGIN@13
11112µs24µsJSON::Schema::Modern::Utilities::::BEGIN@14JSON::Schema::Modern::Utilities::BEGIN@14
11111µs125µsJSON::Schema::Modern::Utilities::::BEGIN@11JSON::Schema::Modern::Utilities::BEGIN@11
11111µs11µsJSON::Schema::Modern::Utilities::::BEGIN@9JSON::Schema::Modern::Utilities::BEGIN@9
11110µs22µsJSON::Schema::Modern::Utilities::::BEGIN@15JSON::Schema::Modern::Utilities::BEGIN@15
11110µs37µsJSON::Schema::Modern::Utilities::::BEGIN@19JSON::Schema::Modern::Utilities::BEGIN@19
11110µs19µsJSON::Schema::Modern::Utilities::::BEGIN@21JSON::Schema::Modern::Utilities::BEGIN@21
1118µs36µsJSON::Schema::Modern::::BEGIN@2.159 JSON::Schema::Modern::BEGIN@2.159
1118µs10µsJSON::Schema::Modern::Utilities::::BEGIN@16JSON::Schema::Modern::Utilities::BEGIN@16
1118µs15µsJSON::Schema::Modern::Utilities::::BEGIN@27JSON::Schema::Modern::Utilities::BEGIN@27
1117µs30µsJSON::Schema::Modern::Utilities::::BEGIN@22JSON::Schema::Modern::Utilities::BEGIN@22
1117µs194µsJSON::Schema::Modern::Utilities::::BEGIN@25JSON::Schema::Modern::Utilities::BEGIN@25
1116µs39µsJSON::Schema::Modern::Utilities::::BEGIN@17JSON::Schema::Modern::Utilities::BEGIN@17
1116µs19µsJSON::Schema::Modern::Utilities::::BEGIN@20JSON::Schema::Modern::Utilities::BEGIN@20
1116µs6µsJSON::Schema::Modern::Utilities::::assert_keyword_existsJSON::Schema::Modern::Utilities::assert_keyword_exists
1113µs3µsJSON::Schema::Modern::Utilities::::BEGIN@52JSON::Schema::Modern::Utilities::BEGIN@52
3211µs1µsJSON::Schema::Modern::Utilities::::CORE:sortJSON::Schema::Modern::Utilities::CORE:sort (opcode)
2211µs1µsJSON::Schema::Modern::Utilities::::__ANON__JSON::Schema::Modern::Utilities::__ANON__ (xsub)
0000s0sJSON::Schema::Modern::Utilities::::__ANON__[:293]JSON::Schema::Modern::Utilities::__ANON__[:293]
0000s0sJSON::Schema::Modern::Utilities::::abortJSON::Schema::Modern::Utilities::abort
0000s0sJSON::Schema::Modern::Utilities::::sprintf_numJSON::Schema::Modern::Utilities::sprintf_num
0000s0sJSON::Schema::Modern::Utilities::::unjsonpJSON::Schema::Modern::Utilities::unjsonp
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1235µs234µs
# spent 31µs (28+3) within JSON::Schema::Modern::BEGIN@1.158 which was called: # once (28µs+3µs) by JSON::Schema::Modern::BEGIN@36 at line 1
use strict;
# spent 31µs making 1 call to JSON::Schema::Modern::BEGIN@1.158 # spent 3µs making 1 call to strict::import
2245µs264µs
# spent 36µs (8+28) within JSON::Schema::Modern::BEGIN@2.159 which was called: # once (8µs+28µs) by JSON::Schema::Modern::BEGIN@36 at line 2
use warnings;
# spent 36µs making 1 call to JSON::Schema::Modern::BEGIN@2.159 # spent 28µs making 1 call to warnings::import
3package JSON::Schema::Modern::Utilities;
4# vim: set ts=8 sts=2 sw=2 tw=100 et :
5# ABSTRACT: Internal utilities for JSON::Schema::Modern
6
710sour $VERSION = '0.552';
8
9239µs111µs
# spent 11µs within JSON::Schema::Modern::Utilities::BEGIN@9 which was called: # once (11µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 9
use 5.020;
# spent 11µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@9
10339µs31.78ms
# spent 923µs (62+861) within JSON::Schema::Modern::Utilities::BEGIN@10 which was called: # once (62µs+861µs) by JSON::Schema::Modern::BEGIN@36 at line 10
use strictures 2;
# spent 923µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@10 # spent 839µs making 1 call to strictures::import # spent 21µs making 1 call to strictures::VERSION
11246µs2239µs
# spent 125µs (11+114) within JSON::Schema::Modern::Utilities::BEGIN@11 which was called: # once (11µs+114µs) by JSON::Schema::Modern::BEGIN@36 at line 11
use experimental qw(signatures postderef);
# spent 125µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@11 # spent 114µs making 1 call to experimental::import
12233µs256µs
# spent 53µs (15+38) within JSON::Schema::Modern::Utilities::BEGIN@12 which was called: # once (15µs+38µs) by JSON::Schema::Modern::BEGIN@36 at line 12
use if "$]" >= 5.022, experimental => 're_strict';
# spent 53µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@12 # spent 3µs making 1 call to if::import
13228µs234µs
# spent 32µs (13+19) within JSON::Schema::Modern::Utilities::BEGIN@13 which was called: # once (13µs+19µs) by JSON::Schema::Modern::BEGIN@36 at line 13
no if "$]" >= 5.031009, feature => 'indirect';
# spent 32µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@13 # spent 2µs making 1 call to if::unimport
14226µs225µs
# spent 24µs (12+12) within JSON::Schema::Modern::Utilities::BEGIN@14 which was called: # once (12µs+12µs) by JSON::Schema::Modern::BEGIN@36 at line 14
no if "$]" >= 5.033001, feature => 'multidimensional';
# spent 24µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@14 # spent 1µs making 1 call to if::unimport
15223µs224µs
# spent 22µs (10+12) within JSON::Schema::Modern::Utilities::BEGIN@15 which was called: # once (10µs+12µs) by JSON::Schema::Modern::BEGIN@36 at line 15
no if "$]" >= 5.033006, feature => 'bareword_filehandles';
# spent 22µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@15 # spent 2µs making 1 call to if::unimport
16221µs212µs
# spent 10µs (8+2) within JSON::Schema::Modern::Utilities::BEGIN@16 which was called: # once (8µs+2µs) by JSON::Schema::Modern::BEGIN@36 at line 16
use B;
# spent 10µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@16 # spent 2µs making 1 call to B::import
17224µs272µs
# spent 39µs (6+33) within JSON::Schema::Modern::Utilities::BEGIN@17 which was called: # once (6µs+33µs) by JSON::Schema::Modern::BEGIN@36 at line 17
use Carp 'croak';
# spent 39µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@17 # spent 33µs making 1 call to Exporter::import
18343µs399µs
# spent 57µs (15+42) within JSON::Schema::Modern::Utilities::BEGIN@18 which was called: # once (15µs+42µs) by JSON::Schema::Modern::BEGIN@36 at line 18
use JSON::MaybeXS 1.004001 'is_bool';
# spent 57µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@18 # spent 34µs making 1 call to Exporter::import # spent 8µs making 1 call to UNIVERSAL::VERSION
19332µs364µs
# spent 37µs (10+27) within JSON::Schema::Modern::Utilities::BEGIN@19 which was called: # once (10µs+27µs) by JSON::Schema::Modern::BEGIN@36 at line 19
use Ref::Util 0.100 qw(is_ref is_plain_arrayref is_plain_hashref);
# spent 37µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@19 # spent 22µs making 1 call to Exporter::import # spent 5µs making 1 call to UNIVERSAL::VERSION
20216µs232µs
# spent 19µs (6+13) within JSON::Schema::Modern::Utilities::BEGIN@20 which was called: # once (6µs+13µs) by JSON::Schema::Modern::BEGIN@36 at line 20
use Scalar::Util 'blessed';
# spent 19µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@20 # spent 13µs making 1 call to Exporter::import
21221µs228µs
# spent 19µs (10+9) within JSON::Schema::Modern::Utilities::BEGIN@21 which was called: # once (10µs+9µs) by JSON::Schema::Modern::BEGIN@36 at line 21
use Storable 'dclone';
# spent 19µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@21 # spent 9µs making 1 call to Exporter::import
22225µs253µs
# spent 30µs (7+23) within JSON::Schema::Modern::Utilities::BEGIN@22 which was called: # once (7µs+23µs) by JSON::Schema::Modern::BEGIN@36 at line 22
use Feature::Compat::Try;
# spent 30µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@22 # spent 23µs making 1 call to Feature::Compat::Try::import
23239µs224µs
# spent 23µs (22+1) within JSON::Schema::Modern::Utilities::BEGIN@23 which was called: # once (22µs+1µs) by JSON::Schema::Modern::BEGIN@36 at line 23
use JSON::Schema::Modern::Error;
# spent 23µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@23 # spent 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__
24231µs216µs
# spent 16µs within JSON::Schema::Modern::Utilities::BEGIN@24 which was called: # once (16µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 24
use JSON::Schema::Modern::Annotation;
# spent 16µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@24 # spent 0s making 1 call to JSON::Schema::Modern::Utilities::__ANON__
25230µs2381µs
# spent 194µs (7+187) within JSON::Schema::Modern::Utilities::BEGIN@25 which was called: # once (7µs+187µs) by JSON::Schema::Modern::BEGIN@36 at line 25
use namespace::clean;
# spent 194µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@25 # spent 187µs making 1 call to namespace::clean::import
26
27253µs222µs
# spent 15µs (8+7) within JSON::Schema::Modern::Utilities::BEGIN@27 which was called: # once (8µs+7µs) by JSON::Schema::Modern::BEGIN@36 at line 27
use Exporter 'import';
# spent 15µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@27 # spent 7µs making 1 call to Exporter::import
28
2912µsour @EXPORT_OK = qw(
30 is_type
31 get_type
32 is_equal
33 is_elements_unique
34 jsonp
35 unjsonp
36 local_annotations
37 canonical_uri
38 E
39 A
40 abort
41 assert_keyword_exists
42 assert_keyword_type
43 assert_pattern
44 assert_uri_reference
45 assert_uri
46 annotate_self
47 sprintf_num
48 true
49 false
50);
51
52226µs13µs
# spent 3µs within JSON::Schema::Modern::Utilities::BEGIN@52 which was called: # once (3µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 52
use JSON::PP ();
# spent 3µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@52
5322.65ms4139µs
# spent 77µs (15+62) within JSON::Schema::Modern::Utilities::BEGIN@53 which was called: # once (15µs+62µs) by JSON::Schema::Modern::BEGIN@36 at line 53
use constant { true => JSON::PP::true, false => JSON::PP::false };
# spent 77µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@53 # spent 59µs making 1 call to constant::import # spent 2µs making 1 call to JSON::PP::false # spent 1µs making 1 call to JSON::PP::true
54
5522228247.7ms
# spent 338ms (241+97.6) within JSON::Schema::Modern::Utilities::is_type which was called 74094 times, avg 5µs/call: # 32492 times (100ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 405 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 10587 times (34.1ms+56.4ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 414 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call # 4795 times (12.4ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 270 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call # 3747 times (7.72ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 122 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 2µs/call # 3616 times (11.1ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 452 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 3585 times (19.1ms+6.97ms) by JSON::Schema::Modern::Utilities::assert_keyword_type at line 286, avg 7µs/call # 2269 times (7.32ms+14.5ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 460 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 10µs/call # 1835 times (6.20ms+9.44ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 501 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call # 1758 times (5.85ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 328 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 1632 times (5.41ms+7.25ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 336 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 1604 times (14.0ms+1.79ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 181 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 10µs/call # 1403 times (2.02ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 212 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 1µs/call # 1244 times (3.08ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems at line 201 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call # 977 times (2.43ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 490 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call # 775 times (3.31ms+531µs) by List::Util::any at line 264 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call # 627 times (1.74ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 530 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 485 times (1.12ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties at line 255 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call # 305 times (580µs+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 172 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call # 262 times (2.08ms+596µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 184 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 10µs/call # 79 times (867µs+69µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum at line 147 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call # 15 times (21µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_maxProperties at line 246 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 1µs/call # once (5µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 287 of JSON/Schema/Modern/Vocabulary/Validation.pm # once (1µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 283 of JSON/Schema/Modern/Vocabulary/Validation.pm
sub is_type ($type, $value) {
567409418.6ms if ($type eq 'null') {
57 return !(defined $value);
58 }
5974094102ms1650789.2ms if ($type eq 'boolean') {
# spent 89.2ms making 16507 calls to JSON::MaybeXS::is_bool, avg 5µs/call
60 return is_bool($value);
61 }
6257587128ms if ($type eq 'object') {
63 return is_plain_hashref($value);
64 }
651010112.9ms if ($type eq 'array') {
66 return is_plain_arrayref($value);
67 }
68
6952821.90ms if ($type eq 'string' or $type eq 'number' or $type eq 'integer') {
7052821.28ms return 0 if not defined $value;
71528226.3ms105648.34ms my $flags = B::svref_2object(\$value)->FLAGS;
# spent 5.77ms making 5282 calls to B::svref_2object, avg 1µs/call # spent 2.57ms making 5282 calls to B::SV::FLAGS, avg 486ns/call
72
73528211.3ms if ($type eq 'string') {
74 return !is_ref($value) && $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK));
75 }
76
77196129µs if ($type eq 'number') {
78109461µs10928µs return ref($value) =~ /^Math::Big(?:Int|Float)$/
# spent 28µs making 109 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 257ns/call
79 || !($flags & B::SVf_POK) && ($flags & (B::SVf_IOK | B::SVf_NOK));
80 }
81
828727µs if ($type eq 'integer') {
8387357µs8720µs return ref($value) =~ /^Math::Big(?:Int|Float)$/ && $value->is_int
# spent 20µs making 87 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 230ns/call
84 || !($flags & B::SVf_POK) && ($flags & (B::SVf_IOK | B::SVf_NOK)) && int($value) == $value;
85 }
86 }
87
88 if ($type =~ /^reference to (.+)$/) {
89 return !blessed($value) && ref($value) eq $1;
90 }
91
92 return ref($value) eq $type;
93}
94
9532636051.7ms
# spent 612ms (445+167) within JSON::Schema::Modern::Utilities::get_type which was called 163180 times, avg 4µs/call: # 91595 times (179ms+0s) by JSON::Schema::Modern::_eval_subschema at line 513 of JSON/Schema/Modern.pm, avg 2µs/call # 35648 times (113ms+73.0ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 62 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call # 33080 times (147ms+90.8ms) by JSON::Schema::Modern::Utilities::is_equal at line 120, avg 7µs/call # 2856 times (5.81ms+3.22ms) by JSON::Schema::Modern::_traverse_subschema at line 435 of JSON/Schema/Modern.pm, avg 3µs/call # once (4µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 89 of JSON/Schema/Modern/Document/OpenAPI.pm
sub get_type ($value) {
9616318031.3ms return 'null' if not defined $value;
97163158257ms return 'object' if is_plain_hashref($value);
98427977.76ms return 'array' if is_plain_arrayref($value);
994169043.0ms41690123ms return 'boolean' if is_bool($value);
# spent 123ms making 41690 calls to JSON::MaybeXS::is_bool, avg 3µs/call
100
101368834.57ms return ref($value) =~ /^Math::Big(?:Int|Float)$/ ? ($value->is_int ? 'integer' : 'number')
102 : (blessed($value) ? '' : 'reference to ').ref($value)
103 if is_ref($value);
104
10536883134ms7376644.2ms my $flags = B::svref_2object(\$value)->FLAGS;
# spent 30.7ms making 36883 calls to B::svref_2object, avg 833ns/call # spent 13.5ms making 36883 calls to B::SV::FLAGS, avg 365ns/call
1063688356.8ms return 'string' if $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK));
107139428µs return int($value) == $value ? 'integer' : 'number'
108 if !($flags & B::SVf_POK) && ($flags & (B::SVf_IOK | B::SVf_NOK));
109
110 croak sprintf('ambiguous type for %s',
111 JSON::MaybeXS->new(allow_nonref => 1, canonical => 1, utf8 => 0, allow_bignum => 1, convert_blessed => 1)->encode($value));
112}
113
114# compares two arbitrary data payloads for equality, as per
115# https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.4.2.2
116# if provided with a state hashref with a 'path' key, any differences are recorded within
1176616011.3ms
# spent 331ms (92.5+238) within JSON::Schema::Modern::Utilities::is_equal which was called 16540 times, avg 20µs/call: # 7835 times (36.1ms+93.0ms) by JSON::Schema::Modern::Utilities::is_elements_unique at line 160, avg 16µs/call # 7494 times (43.1ms+115ms) by List::Util::any at line 86 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 21µs/call # 1208 times (13.3ms+29.9ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 96 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 36µs/call # once (17µs+-17µs) by JSON::Schema::Modern::Utilities::is_equal at line 135 # once (6µs+-6µs) by JSON::Schema::Modern::Utilities::is_equal at line 138 # once (4µs+-4µs) by JSON::Schema::Modern::Utilities::is_equal at line 147
sub is_equal ($x, $y, $state = undef) {
118165405.66ms $state->{path} //= '';
119
1201654023.9ms33080238ms my @types = map get_type($_), $x, $y;
# spent 238ms making 33080 calls to JSON::Schema::Modern::Utilities::get_type, avg 7µs/call
121
122165404.13ms if ($state->{scalarref_booleans}) {
1237836814µs ($x, $types[0]) = (0+!!$$x, 'boolean') if $types[0] eq 'reference to SCALAR';
1247836789µs ($y, $types[1]) = (0+!!$$y, 'boolean') if $types[1] eq 'reference to SCALAR';
125 }
126
127165403.87ms return 0 if $types[0] ne $types[1];
128160302.28ms return 1 if $types[0] eq 'null';
1291603025.2ms return $x eq $y if $types[0] eq 'string';
1301811.34ms348499µs return $x == $y if grep $types[0] eq $_, qw(boolean number integer);
# spent 499µs making 348 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:7], avg 1µs/call
131
132215µs my $path = $state->{path};
13323µs if ($types[0] eq 'object') {
13417µs return 0 if keys %$x != keys %$y;
135113µs31µs return 0 if not is_equal([ sort keys %$x ], [ sort keys %$y ]);
# spent 1µs making 2 calls to JSON::Schema::Modern::Utilities::CORE:sort, avg 500ns/call # spent 48µs making 1 call to JSON::Schema::Modern::Utilities::is_equal, recursion: max depth 1, sum of overlapping time 48µs
13612µs10s foreach my $property (sort keys %$x) {
# spent 0s making 1 call to JSON::Schema::Modern::Utilities::CORE:sort
13711µs18µs $state->{path} = jsonp($path, $property);
# spent 8µs making 1 call to JSON::Schema::Modern::Utilities::jsonp
13814µs10s return 0 if not is_equal($x->{$property}, $y->{$property}, $state);
# spent 17µs making 1 call to JSON::Schema::Modern::Utilities::is_equal, recursion: max depth 1, sum of overlapping time 17µs
139 }
140 return 1;
141 }
142
14311µs if ($types[0] eq 'array') {
14410s return 0 if @$x != @$y;
14511µs foreach my $idx (0 .. $x->$#*) {
14611µs $state->{path} = $path.'/'.$idx;
14711µs10s return 0 if not is_equal($x->[$idx], $y->[$idx], $state);
# spent 28µs making 1 call to JSON::Schema::Modern::Utilities::is_equal, recursion: max depth 2, sum of overlapping time 28µs
148 }
14913µs return 1;
150 }
151
152 return 0; # should never get here
153}
154
155# checks array elements for uniqueness. short-circuits on first pair of matching elements
156# if second arrayref is provided, it is populated with the indices of identical items
1572103396µs
# spent 147ms (18.4+129) within JSON::Schema::Modern::Utilities::is_elements_unique which was called 701 times, avg 210µs/call: # 288 times (8.32ms+60.1ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 214 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 238µs/call # 276 times (7.68ms+56.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 265 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 233µs/call # 76 times (746µs+2.41ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 51 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 42µs/call # 60 times (1.64ms+9.88ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum at line 79 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 192µs/call # once (3µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 291 of JSON/Schema/Modern/Vocabulary/Validation.pm
sub is_elements_unique ($array, $equal_indices = undef) {
1587011.26ms foreach my $idx0 (0 .. $array->$#*-1) {
15913001.28ms foreach my $idx1 ($idx0+1 .. $array->$#*) {
16078359.54ms7835129ms if (is_equal($array->[$idx0], $array->[$idx1], { scalarref_booleans => 1 })) {
# spent 129ms making 7835 calls to JSON::Schema::Modern::Utilities::is_equal, avg 16µs/call
161 push @$equal_indices, $idx0, $idx1 if defined $equal_indices;
162 return 0;
163 }
164 }
165 }
1667011.41ms return 1;
167}
168
169# shorthand for creating and appending json pointers
170
# spent 1.38s (1.22+156ms) within JSON::Schema::Modern::Utilities::jsonp which was called 314039 times, avg 4µs/call: # 168591 times (505ms+54.9ms) by JSON::Schema::Modern::Utilities::canonical_uri at line 189, avg 3µs/call # 72037 times (262ms+31.3ms) by JSON::Schema::Modern::Utilities::A at line 245, avg 4µs/call # 41707 times (273ms+33.9ms) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 89 of JSON/Schema/Modern/Vocabulary.pm, avg 7µs/call # 20884 times (126ms+12.5ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 421 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call # 4217 times (14.9ms+1.83ms) by JSON::Schema::Modern::Utilities::E at line 211, avg 4µs/call # 2416 times (14.6ms+3.51ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 467 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 1835 times (10.8ms+3.45ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 508 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 1340 times (10.00ms+1.66ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 55 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call # 713 times (4.15ms+13.0ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 537 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 24µs/call # 290 times (2.08ms+288µs) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 181 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 7 times (50µs+8µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 64 of JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call # once (10µs+1000ns) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 123 of JSON/Schema/Modern/Vocabulary/Core.pm # once (7µs+1000ns) by JSON::Schema::Modern::Utilities::is_equal at line 137
sub jsonp {
1713140391.59s469978156ms return join('/', shift, map s/~/~0/gr =~ s!/!~1!gr, map +(is_plain_arrayref($_) ? @$_ : $_), grep defined, @_);
# spent 156ms making 469978 calls to JSON::Schema::Modern::Utilities::CORE:subst, avg 333ns/call
172}
173
174# splits a json pointer apart into its path segments
175sub unjsonp ($path) {
176 return map s!~0!~!gr =~ s!~1!/!gr, split m!/!, $path;
177}
178
179# get all annotations produced for the current instance data location (that are visible to this
180# schema location)
18174941.30ms
# spent 805ms (499+306) within JSON::Schema::Modern::Utilities::local_annotations which was called 3747 times, avg 215µs/call: # 3747 times (499ms+306ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 125 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 215µs/call
sub local_annotations ($state) {
1823747251ms372479306ms grep $_->instance_location eq $state->{data_path}, $state->{annotations}->@*;
# spent 306ms making 372479 calls to JSON::Schema::Modern::Annotation::instance_location, avg 821ns/call
183}
184
185# shorthand for finding the canonical uri of the present schema location
186505773111ms
# spent 8.21s (1.74+6.47) within JSON::Schema::Modern::Utilities::canonical_uri which was called 168591 times, avg 49µs/call: # 91595 times (940ms+3.27s) by JSON::Schema::Modern::_eval_subschema at line 506 of JSON/Schema/Modern.pm, avg 46µs/call # 72037 times (742ms+2.98s) by JSON::Schema::Modern::Utilities::A at line 242, avg 52µs/call # 4217 times (44.2ms+181ms) by JSON::Schema::Modern::Utilities::E at line 208, avg 53µs/call # 727 times (11.5ms+33.5ms) by JSON::Schema::Modern::Document::OpenAPI::_traverse_schema at line 218 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 62µs/call # 15 times (197µs+623µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 153 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 55µs/call
sub canonical_uri ($state, @extra_path) {
18716859144.0ms splice(@extra_path, -1, 1, $extra_path[-1]->@*) if @extra_path and is_plain_arrayref($extra_path[-1]);
188168591191ms1685915.47s my $uri = $state->{initial_schema_uri}->clone;
# spent 5.47s making 168591 calls to Mojo::URL::clone, avg 32µs/call
189168591507ms505773903ms $uri->fragment(($uri->fragment//'').jsonp($state->{schema_path}, @extra_path));
# spent 560ms making 168591 calls to JSON::Schema::Modern::Utilities::jsonp, avg 3µs/call # spent 343ms making 337182 calls to Mojo::URL::fragment, avg 1µs/call
190168591139ms19446498.4ms $uri->fragment(undef) if not length($uri->fragment);
# spent 98.4ms making 194464 calls to Mojo::URL::fragment, avg 506ns/call
191168591324ms $uri;
192}
193
194# shorthand for creating error objects
195# uses these keys from $state:
196# - initial_schema_uri
197# - keyword
198# - data_path
199# - traversed_schema_path
200# - schema_path
201# - _schema_path_suffix
202# - errors
203168685.06ms
# spent 1.14s (113ms+1.03) within JSON::Schema::Modern::Utilities::E which was called 4217 times, avg 270µs/call: # 1438 times (41.6ms+341ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 274 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 266µs/call # 1115 times (34.2ms+278ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 73 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 280µs/call # 799 times (19.4ms+197ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 98 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 271µs/call # 799 times (15.6ms+195ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 436 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 264µs/call # 66 times (1.79ms+16.4ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum at line 89 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 275µs/call
sub E ($state, $error_string, @args) {
20442171.54ms croak 'E called in void context' if not defined wantarray;
205
206 # sometimes the keyword shouldn't be at the very end of the schema path
207 my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix})
208421723.6ms8434380ms ->to_abs($state->{effective_base_uri});
# spent 225ms making 4217 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 53µs/call # spent 155ms making 4217 calls to Mojo::URL::to_abs, avg 37µs/call
209
210 my $keyword_location = $state->{traversed_schema_path}
21142178.36ms421716.7ms .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix});
# spent 16.7ms making 4217 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call
212
213421714.4ms8434394ms undef $uri if $uri eq '' and $keyword_location eq ''
# spent 391ms making 4217 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 93µs/call # spent 2.35ms making 4217 calls to Mojo::URL::fragment, avg 557ns/call
214 or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq '';
215
216 push $state->{errors}->@*, JSON::Schema::Modern::Error->new(
217 keyword => $state->{keyword},
218 instance_location => $state->{data_path},
219 keyword_location => $keyword_location,
220 defined $uri ? ( absolute_keyword_location => $uri ) : (),
221 error => @args ? sprintf($error_string, @args) : $error_string,
222421728.8ms4217237ms $state->{exception} ? ( exception => $state->{exception} ) : (),
# spent 237ms making 4217 calls to JSON::Schema::Modern::Error::new, avg 56µs/call
223 );
224
225421711.5ms return 0;
226}
227
228# shorthand for creating annotations
229# uses these keys from $state:
230# - initial_schema_uri
231# - keyword
232# - data_path
233# - traversed_schema_path
234# - schema_path
235# - _schema_path_suffix
236# - annotations
237# - collect_annotations
23821611739.3ms
# spent 17.8s (1.48+16.3) within JSON::Schema::Modern::Utilities::A which was called 72039 times, avg 247µs/call: # 32214 times (608ms+7.09s) by JSON::Schema::Modern::Utilities::annotate_self at line 340, avg 239µs/call # 28612 times (628ms+6.57s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 435 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 252µs/call # 3747 times (69.4ms+885ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 158 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 255µs/call # 3616 times (88.6ms+902ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 482 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 274µs/call # 2230 times (54.5ms+535ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 183 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 264µs/call # 977 times (18.0ms+213ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 522 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 237µs/call # 643 times (14.6ms+150ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 360 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 255µs/call
sub A ($state, $annotation) {
2397203948.3ms return 1 if not $state->{collect_annotations} or $state->{spec_version} eq 'draft7';
240
241 my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix})
24272037327ms1440746.24s ->to_abs($state->{effective_base_uri});
# spent 3.73s making 72037 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 52µs/call # spent 2.52s making 72037 calls to Mojo::URL::to_abs, avg 35µs/call
243
244 my $keyword_location = $state->{traversed_schema_path}
24572037147ms72037293ms .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix});
# spent 293ms making 72037 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call
246
24772037218ms1440746.66s undef $uri if $uri eq '' and $keyword_location eq ''
# spent 6.62s making 72037 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 92µs/call # spent 41.7ms making 72037 calls to Mojo::URL::fragment, avg 579ns/call
248 or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq '';
249
250 push $state->{annotations}->@*, JSON::Schema::Modern::Annotation->new(
251 keyword => $state->{keyword},
252 instance_location => $state->{data_path},
253 keyword_location => $keyword_location,
254 defined $uri ? ( absolute_keyword_location => $uri ) : (),
255 annotation => $annotation,
25672037235ms720373.14s $state->{_unknown} ? ( unknown => 1 ) : (),
# spent 3.14s making 72037 calls to JSON::Schema::Modern::Annotation::new, avg 44µs/call
257 );
258
25972037163ms return 1;
260}
261
262# creates an error object, but also aborts evaluation immediately
263# only this error is returned, because other errors on the stack might not actually be "real"
264# errors (consider if we were in the middle of evaluating a "not" or "if").
265# Therefore this is only appropriate during the evaluation phase, not the traverse phase.
266sub abort ($state, $error_string, @args) {
267 ()= E({ %$state, exception => 1 }, $error_string, @args);
268 croak 'abort() called during traverse' if $state->{traverse};
269 die pop $state->{errors}->@*;
270}
271
27230s
# spent 6µs within JSON::Schema::Modern::Utilities::assert_keyword_exists which was called: # once (6µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm
sub assert_keyword_exists ($state, $schema) {
27311µs croak 'assert_keyword_exists called in void context' if not defined wantarray;
27412µs return E($state, '%s keyword is required', $state->{keyword}) if not exists $schema->{$state->{keyword}};
27514µs return 1;
276}
277
278143401.93ms
# spent 44.3ms (18.2+26.1) within JSON::Schema::Modern::Utilities::assert_keyword_type which was called 3585 times, avg 12µs/call: # 1305 times (6.42ms+11.4ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 54 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call # 725 times (4.43ms+6.38ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 194 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 15µs/call # 401 times (2.30ms+914µs) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 50 of JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call # 276 times (940µs+417µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 262 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call # 150 times (490µs+1.54ms) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_deprecated at line 55 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 14µs/call # 131 times (501µs+732µs) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_title at line 38 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 9µs/call # 118 times (834µs+976µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_comment at line 276 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 15µs/call # 87 times (253µs+829µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer at line 319 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call # 77 times (504µs+171µs) by JSON::Schema::Modern::Vocabulary::traverse_array_schemas at line 38 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call # 69 times (372µs+494µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 179 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 13µs/call # 60 times (290µs+93µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum at line 78 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 6µs/call # 50 times (211µs+309µs) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_traverse_keyword_format at line 35 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 10µs/call # 31 times (145µs+418µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 256 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 18µs/call # 30 times (101µs+220µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_number at line 314 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 11µs/call # 15 times (85µs+190µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 103 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 18µs/call # 15 times (86µs+114µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 144 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 13µs/call # 14 times (111µs+698µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 58µs/call # 11 times (49µs+25µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 247 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 7µs/call # 7 times (27µs+13µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 441 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 6µs/call # 7 times (28µs+7µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 61 of JSON/Schema/Modern/Vocabulary.pm, avg 5µs/call # 3 times (5µs+61µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems at line 207 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 22µs/call # once (8µs+32µs) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm # once (4µs+6µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding at line 39 of JSON/Schema/Modern/Vocabulary/Content.pm # once (5µs+1000ns) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 278 of JSON/Schema/Modern/Vocabulary/Validation.pm
sub assert_keyword_type ($state, $schema, $type) {
2793585768µs croak 'assert_keyword_type called in void context' if not defined wantarray;
28035854.91ms my $value = $schema->{$state->{keyword}};
2813585746µs my $thing = 'value';
282 ($value, $thing) = is_plain_hashref($value) ? ($value->{$state->{_schema_path_suffix}}, 'value at "'.$state->{_schema_path_suffix}.'"')
283 : is_plain_arrayref($value) ? ($value->[$state->{_schema_path_suffix}], 'item '.$state->{_schema_path_suffix})
284 : die 'unknown type'
2853585768µs if exists $state->{_schema_path_suffix};
28635859.38ms358526.1ms return 1 if is_type($type, $value);
# spent 26.1ms making 3585 calls to JSON::Schema::Modern::Utilities::is_type, avg 7µs/call
287 E($state, '%s %s is not a%s %s', $state->{keyword}, $thing, ($type =~ /^[aeiou]/ ? 'n' : ''), $type);
288}
289
29022843µs
# spent 3.22ms (1.23+1.98) within JSON::Schema::Modern::Utilities::assert_pattern which was called 76 times, avg 42µs/call: # 69 times (1.13ms+1.78ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 179 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 42µs/call # 7 times (104µs+208µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 445 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 45µs/call
sub assert_pattern ($state, $pattern) {
2917627µs croak 'assert_pattern called in void context' if not defined wantarray;
2927659µs try {
29376512µs local $SIG{__WARN__} = sub { die @_ };
294762.47ms1521.98ms qr/$pattern/;
# spent 1.92ms making 76 calls to JSON::Schema::Modern::Utilities::CORE:regcomp, avg 25µs/call # spent 60µs making 76 calls to JSON::Schema::Modern::Utilities::CORE:qr, avg 789ns/call
295 }
296 catch ($e) { return E($state, $e); };
29776145µs return 1;
298}
299
300# this is only suitable for checking URIs within schemas themselves
3012217331µs
# spent 158ms (12.3+146) within JSON::Schema::Modern::Utilities::assert_uri_reference which was called 739 times, avg 214µs/call: # 725 times (12.1ms+144ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 194 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 215µs/call # 14 times (203µs+2.07ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 162µs/call
sub assert_uri_reference ($state, $schema) {
302739193µs croak 'assert_uri_reference called in void context' if not defined wantarray;
303
304739498µs my $string = $schema->{$state->{keyword}};
305 return E($state, '%s value is not a valid URI reference', $state->{keyword})
306 # see also uri-reference format sub
30773912.3ms5059146ms if fc(Mojo::URL->new($string)->to_unsafe_string) ne fc($string)
# spent 81.8ms making 739 calls to Mojo::URL::new, avg 111µs/call # spent 59.2ms making 739 calls to Mojo::URL::to_unsafe_string, avg 80µs/call # spent 5.05ms making 3581 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 1µs/call
308 or $string =~ /[^[:ascii:]]/
309 or $string =~ /#/
310 and $string !~ m{#$} # empty fragment
311 and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment
312 and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment
313
3147391.64ms return 1;
315}
316
317# this is only suitable for checking URIs within schemas themselves
31818432µs
# spent 7.05ms (634µs+6.42) within JSON::Schema::Modern::Utilities::assert_uri which was called 46 times, avg 153µs/call: # 31 times (391µs+4.36ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 257 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 153µs/call # 15 times (243µs+2.06ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 103 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 154µs/call
sub assert_uri ($state, $schema, $override = undef) {
3194611µs croak 'assert_uri called in void context' if not defined wantarray;
320
3214623µs my $string = $override // $schema->{$state->{keyword}};
3224653µs462.03ms my $uri = Mojo::URL->new($string);
# spent 2.03ms making 46 calls to Mojo::URL::new, avg 44µs/call
323
32446302µs1844.39ms return E($state, '"%s" is not a valid URI', $string)
# spent 4.21ms making 46 calls to Mojo::URL::to_unsafe_string, avg 92µs/call # spent 145µs making 46 calls to Mojo::URL::is_abs, avg 3µs/call # spent 31µs making 92 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 337ns/call
325 # see also uri format sub
326 if fc($uri->to_unsafe_string) ne fc($string)
327 or $string =~ /[^[:ascii:]]/
328 or not $uri->is_abs
329 or $string =~ /#/
330 and $string !~ m{#$} # empty fragment
331 and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment
332 and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment
333
33446155µs return 1;
335}
336
337# produces an annotation whose value is the same as that of the current keyword
3389664217.0ms
# spent 7.88s (147ms+7.73) within JSON::Schema::Modern::Utilities::annotate_self which was called 32214 times, avg 245µs/call: # 32214 times (147ms+7.73s) by JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_title at line 43 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 245µs/call
sub annotate_self ($state, $schema) {
339 A($state, is_ref($schema->{$state->{keyword}}) ? dclone($schema->{$state->{keyword}})
34032214156ms333277.73s : $schema->{$state->{keyword}});
# spent 7.69s making 32214 calls to JSON::Schema::Modern::Utilities::A, avg 239µs/call # spent 40.8ms making 1113 calls to Storable::dclone, avg 37µs/call
341}
342
343sub sprintf_num ($value) {
344 # use original value as stored in the NV, without losing precision
345 ref($value) =~ /^Math::Big(?:Int|Float)$/ ? $value->bstr : sprintf('%s', $value);
346}
347
34816µs1;
349
350138µs1260µs__END__
 
# spent 5.13ms within JSON::Schema::Modern::Utilities::CORE:match which was called 3869 times, avg 1µs/call: # 3581 times (5.05ms+0s) by JSON::Schema::Modern::Utilities::assert_uri_reference at line 307, avg 1µs/call # 109 times (28µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 78, avg 257ns/call # 92 times (31µs+0s) by JSON::Schema::Modern::Utilities::assert_uri at line 324, avg 337ns/call # 87 times (20µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 83, avg 230ns/call
sub JSON::Schema::Modern::Utilities::CORE:match; # opcode
# spent 60µs within JSON::Schema::Modern::Utilities::CORE:qr which was called 76 times, avg 789ns/call: # 76 times (60µs+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 294, avg 789ns/call
sub JSON::Schema::Modern::Utilities::CORE:qr; # opcode
# spent 1.92ms within JSON::Schema::Modern::Utilities::CORE:regcomp which was called 76 times, avg 25µs/call: # 76 times (1.92ms+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 294, avg 25µs/call
sub JSON::Schema::Modern::Utilities::CORE:regcomp; # opcode
# spent 1µs within JSON::Schema::Modern::Utilities::CORE:sort which was called 3 times, avg 333ns/call: # 2 times (1µs+0s) by JSON::Schema::Modern::Utilities::is_equal at line 135, avg 500ns/call # once (0s+0s) by JSON::Schema::Modern::Utilities::is_equal at line 136
sub JSON::Schema::Modern::Utilities::CORE:sort; # opcode
# spent 156ms within JSON::Schema::Modern::Utilities::CORE:subst which was called 469978 times, avg 333ns/call: # 469978 times (156ms+0s) by JSON::Schema::Modern::Utilities::jsonp at line 171, avg 333ns/call
sub JSON::Schema::Modern::Utilities::CORE:subst; # opcode
# spent 1µs within JSON::Schema::Modern::Utilities::__ANON__ which was called 2 times, avg 500ns/call: # once (1µs+0s) by JSON::Schema::Modern::Utilities::BEGIN@23 at line 23 # once (0s+0s) by JSON::Schema::Modern::Utilities::BEGIN@24 at line 24
sub JSON::Schema::Modern::Utilities::__ANON__; # xsub