← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:57:08 2022
Reported on Wed Dec 14 16:00:35 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Utilities.pm
StatementsExecuted 3856150 statements in 5.77s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
71792851.64s19.7sJSON::Schema::Modern::Utilities::::AJSON::Schema::Modern::Utilities::A
168344541.46s6.96sJSON::Schema::Modern::Utilities::::canonical_uriJSON::Schema::Modern::Utilities::canonical_uri
2212151241.24s1.41sJSON::Schema::Modern::Utilities::::jsonpJSON::Schema::Modern::Utilities::jsonp
374711575ms886msJSON::Schema::Modern::Utilities::::local_annotationsJSON::Schema::Modern::Utilities::local_annotations
16199954453ms634msJSON::Schema::Modern::Utilities::::get_typeJSON::Schema::Modern::Utilities::get_type
72310235274ms365msJSON::Schema::Modern::Utilities::::is_typeJSON::Schema::Modern::Utilities::is_type
3221411212ms8.95sJSON::Schema::Modern::Utilities::::annotate_selfJSON::Schema::Modern::Utilities::annotate_self
46902011169ms169msJSON::Schema::Modern::Utilities::::CORE:substJSON::Schema::Modern::Utilities::CORE:subst (opcode)
421752117ms1.17sJSON::Schema::Modern::Utilities::::EJSON::Schema::Modern::Utilities::E
159463297.0ms373msJSON::Schema::Modern::Utilities::::is_equalJSON::Schema::Modern::Utilities::is_equal
6404120.9ms163msJSON::Schema::Modern::Utilities::::is_elements_uniqueJSON::Schema::Modern::Utilities::is_elements_unique
359024819.3ms51.3msJSON::Schema::Modern::Utilities::::assert_keyword_typeJSON::Schema::Modern::Utilities::assert_keyword_type
7462112.9ms195msJSON::Schema::Modern::Utilities::::assert_uri_referenceJSON::Schema::Modern::Utilities::assert_uri_reference
3904415.82ms5.82msJSON::Schema::Modern::Utilities::::CORE:matchJSON::Schema::Modern::Utilities::CORE:match (opcode)
75112.16ms2.16msJSON::Schema::Modern::Utilities::::CORE:regcompJSON::Schema::Modern::Utilities::CORE:regcomp (opcode)
75221.30ms3.64msJSON::Schema::Modern::Utilities::::assert_patternJSON::Schema::Modern::Utilities::assert_pattern
4621786µs7.97msJSON::Schema::Modern::Utilities::::assert_uriJSON::Schema::Modern::Utilities::assert_uri
7511183µs183µsJSON::Schema::Modern::Utilities::::CORE:qrJSON::Schema::Modern::Utilities::CORE:qr (opcode)
111103µs1.27msJSON::Schema::Modern::Utilities::::BEGIN@10JSON::Schema::Modern::Utilities::BEGIN@10
11154µs59µsJSON::Schema::Modern::::BEGIN@1.158 JSON::Schema::Modern::BEGIN@1.158
11128µs29µsJSON::Schema::Modern::Utilities::::BEGIN@23JSON::Schema::Modern::Utilities::BEGIN@23
11121µs91µsJSON::Schema::Modern::Utilities::::BEGIN@53JSON::Schema::Modern::Utilities::BEGIN@53
11118µs80µsJSON::Schema::Modern::::BEGIN@2.159 JSON::Schema::Modern::BEGIN@2.159
11117µs67µsJSON::Schema::Modern::Utilities::::BEGIN@18JSON::Schema::Modern::Utilities::BEGIN@18
11116µs48µsJSON::Schema::Modern::Utilities::::BEGIN@12JSON::Schema::Modern::Utilities::BEGIN@12
11116µs33µsJSON::Schema::Modern::Utilities::::BEGIN@14JSON::Schema::Modern::Utilities::BEGIN@14
11115µs16µsJSON::Schema::Modern::Utilities::::BEGIN@24JSON::Schema::Modern::Utilities::BEGIN@24
11115µs24µsJSON::Schema::Modern::Utilities::::BEGIN@27JSON::Schema::Modern::Utilities::BEGIN@27
11114µs30µsJSON::Schema::Modern::Utilities::::BEGIN@13JSON::Schema::Modern::Utilities::BEGIN@13
11112µs150µsJSON::Schema::Modern::Utilities::::BEGIN@11JSON::Schema::Modern::Utilities::BEGIN@11
11112µs29µsJSON::Schema::Modern::Utilities::::BEGIN@15JSON::Schema::Modern::Utilities::BEGIN@15
11112µs42µsJSON::Schema::Modern::Utilities::::BEGIN@19JSON::Schema::Modern::Utilities::BEGIN@19
11112µs12µsJSON::Schema::Modern::Utilities::::BEGIN@9JSON::Schema::Modern::Utilities::BEGIN@9
11110µs24µsJSON::Schema::Modern::Utilities::::BEGIN@20JSON::Schema::Modern::Utilities::BEGIN@20
11110µs10µsJSON::Schema::Modern::Utilities::::BEGIN@52JSON::Schema::Modern::Utilities::BEGIN@52
1118µs10µsJSON::Schema::Modern::Utilities::::BEGIN@16JSON::Schema::Modern::Utilities::BEGIN@16
1118µs36µsJSON::Schema::Modern::Utilities::::BEGIN@22JSON::Schema::Modern::Utilities::BEGIN@22
1118µs444µsJSON::Schema::Modern::Utilities::::BEGIN@25JSON::Schema::Modern::Utilities::BEGIN@25
1117µs43µsJSON::Schema::Modern::Utilities::::BEGIN@17JSON::Schema::Modern::Utilities::BEGIN@17
1117µs23µsJSON::Schema::Modern::Utilities::::BEGIN@21JSON::Schema::Modern::Utilities::BEGIN@21
1115µs5µsJSON::Schema::Modern::Utilities::::assert_keyword_existsJSON::Schema::Modern::Utilities::assert_keyword_exists
2212µs2µsJSON::Schema::Modern::Utilities::::__ANON__JSON::Schema::Modern::Utilities::__ANON__ (xsub)
0000s0sJSON::Schema::Modern::Utilities::::__ANON__[:298]JSON::Schema::Modern::Utilities::__ANON__[:298]
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
1266µs264µs
# spent 59µs (54+5) within JSON::Schema::Modern::BEGIN@1.158 which was called: # once (54µs+5µs) by JSON::Schema::Modern::BEGIN@36 at line 1
use strict;
# spent 59µs making 1 call to JSON::Schema::Modern::BEGIN@1.158 # spent 5µs making 1 call to strict::import
2272µs2142µs
# spent 80µs (18+62) within JSON::Schema::Modern::BEGIN@2.159 which was called: # once (18µs+62µs) by JSON::Schema::Modern::BEGIN@36 at line 2
use warnings;
# spent 80µs making 1 call to JSON::Schema::Modern::BEGIN@2.159 # spent 62µ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
711µsour $VERSION = '0.556';
8
9298µs112µs
# spent 12µs within JSON::Schema::Modern::Utilities::BEGIN@9 which was called: # once (12µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 9
use 5.020;
# spent 12µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@9
103134µs32.44ms
# spent 1.27ms (103µs+1.17) within JSON::Schema::Modern::Utilities::BEGIN@10 which was called: # once (103µs+1.17ms) by JSON::Schema::Modern::BEGIN@36 at line 10
use strictures 2;
# spent 1.27ms making 1 call to JSON::Schema::Modern::Utilities::BEGIN@10 # spent 1.14ms making 1 call to strictures::import # spent 32µs making 1 call to strictures::VERSION
11251µs2288µs
# spent 150µs (12+138) within JSON::Schema::Modern::Utilities::BEGIN@11 which was called: # once (12µs+138µs) by JSON::Schema::Modern::BEGIN@36 at line 11
use experimental qw(signatures postderef);
# spent 150µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@11 # spent 138µs making 1 call to experimental::import
12237µs252µs
# spent 48µs (16+32) within JSON::Schema::Modern::Utilities::BEGIN@12 which was called: # once (16µs+32µs) by JSON::Schema::Modern::BEGIN@36 at line 12
use if "$]" >= 5.022, experimental => 're_strict';
# spent 48µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@12 # spent 4µs making 1 call to if::import
13241µs232µs
# spent 30µs (14+16) within JSON::Schema::Modern::Utilities::BEGIN@13 which was called: # once (14µs+16µs) by JSON::Schema::Modern::BEGIN@36 at line 13
no if "$]" >= 5.031009, feature => 'indirect';
# spent 30µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@13 # spent 2µs making 1 call to if::unimport
14228µs236µs
# spent 33µs (16+17) within JSON::Schema::Modern::Utilities::BEGIN@14 which was called: # once (16µs+17µs) by JSON::Schema::Modern::BEGIN@36 at line 14
no if "$]" >= 5.033001, feature => 'multidimensional';
# spent 33µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@14 # spent 3µs making 1 call to if::unimport
15222µs231µs
# spent 29µs (12+17) within JSON::Schema::Modern::Utilities::BEGIN@15 which was called: # once (12µs+17µs) by JSON::Schema::Modern::BEGIN@36 at line 15
no if "$]" >= 5.033006, feature => 'bareword_filehandles';
# spent 29µ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
17232µs279µs
# spent 43µs (7+36) within JSON::Schema::Modern::Utilities::BEGIN@17 which was called: # once (7µs+36µs) by JSON::Schema::Modern::BEGIN@36 at line 17
use Carp 'croak';
# spent 43µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@17 # spent 36µs making 1 call to Exporter::import
18350µs3117µs
# spent 67µs (17+50) within JSON::Schema::Modern::Utilities::BEGIN@18 which was called: # once (17µs+50µs) by JSON::Schema::Modern::BEGIN@36 at line 18
use JSON::MaybeXS 1.004001 'is_bool';
# spent 67µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@18 # spent 38µs making 1 call to Exporter::import # spent 12µs making 1 call to UNIVERSAL::VERSION
19334µs372µs
# spent 42µs (12+30) within JSON::Schema::Modern::Utilities::BEGIN@19 which was called: # once (12µs+30µ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 42µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@19 # spent 25µs making 1 call to Exporter::import # spent 5µs making 1 call to UNIVERSAL::VERSION
20224µs238µs
# spent 24µs (10+14) within JSON::Schema::Modern::Utilities::BEGIN@20 which was called: # once (10µs+14µs) by JSON::Schema::Modern::BEGIN@36 at line 20
use Scalar::Util 'blessed';
# spent 24µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@20 # spent 14µs making 1 call to Exporter::import
21221µs239µs
# spent 23µs (7+16) within JSON::Schema::Modern::Utilities::BEGIN@21 which was called: # once (7µs+16µs) by JSON::Schema::Modern::BEGIN@36 at line 21
use Storable 'dclone';
# spent 23µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@21 # spent 16µs making 1 call to Exporter::import
22221µs264µs
# spent 36µs (8+28) within JSON::Schema::Modern::Utilities::BEGIN@22 which was called: # once (8µs+28µs) by JSON::Schema::Modern::BEGIN@36 at line 22
use Feature::Compat::Try;
# spent 36µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@22 # spent 28µs making 1 call to Feature::Compat::Try::import
23248µs230µs
# spent 29µs (28+1) within JSON::Schema::Modern::Utilities::BEGIN@23 which was called: # once (28µs+1µs) by JSON::Schema::Modern::BEGIN@36 at line 23
use JSON::Schema::Modern::Error;
# spent 29µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@23 # spent 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__
24230µs217µs
# spent 16µs (15+1000ns) within JSON::Schema::Modern::Utilities::BEGIN@24 which was called: # once (15µs+1000ns) 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 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__
25260µs2880µs
# spent 444µs (8+436) within JSON::Schema::Modern::Utilities::BEGIN@25 which was called: # once (8µs+436µs) by JSON::Schema::Modern::BEGIN@36 at line 25
use namespace::clean;
# spent 444µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@25 # spent 436µs making 1 call to namespace::clean::import
26
27272µs233µs
# spent 24µs (15+9) within JSON::Schema::Modern::Utilities::BEGIN@27 which was called: # once (15µs+9µs) by JSON::Schema::Modern::BEGIN@36 at line 27
use Exporter 'import';
# spent 24µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@27 # spent 9µs making 1 call to Exporter::import
28
2913µ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
52248µs110µs
# spent 10µs within JSON::Schema::Modern::Utilities::BEGIN@52 which was called: # once (10µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 52
use JSON::PP ();
# spent 10µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@52
5323.32ms4161µs
# spent 91µs (21+70) within JSON::Schema::Modern::Utilities::BEGIN@53 which was called: # once (21µs+70µs) by JSON::Schema::Modern::BEGIN@36 at line 53
use constant { true => JSON::PP::true, false => JSON::PP::false };
# spent 91µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@53 # spent 68µs making 1 call to constant::import # spent 2µs making 1 call to JSON::PP::true # spent 0s making 1 call to JSON::PP::false
54
5521693051.0ms
# spent 365ms (274+90.5) within JSON::Schema::Modern::Utilities::is_type which was called 72310 times, avg 5µs/call: # 32492 times (124ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 366 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call # 11057 times (40.2ms+53.7ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 374 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 4795 times (16.1ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 269 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call # 3747 times (8.81ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 116 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 2µs/call # 3590 times (24.2ms+7.87ms) by JSON::Schema::Modern::Utilities::assert_keyword_type at line 291, avg 9µs/call # 3369 times (12.8ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 408 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call # 1835 times (7.59ms+8.91ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 451 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call # 1799 times (7.62ms+11.4ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 415 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 11µs/call # 1758 times (7.00ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 299 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call # 1632 times (5.85ms+7.03ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 305 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 1403 times (2.41ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 211 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call # 1244 times (3.80ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems at line 200 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call # 977 times (3.12ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 441 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 774 times (3.43ms+763µs) by List::Util::any at line 263 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call # 627 times (1.84ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 476 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 485 times (1.26ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties at line 254 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call # 305 times (562µs+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 161 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call # 262 times (2.35ms+667µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 183 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call # 79 times (832µs+89µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum at line 146 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call # 63 times (534µs+62µs) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 181 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 9µs/call # 15 times (48µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_maxProperties at line 245 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call # once (7µs+1000ns) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 286 of JSON/Schema/Modern/Vocabulary/Validation.pm # once (3µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 282 of JSON/Schema/Modern/Vocabulary/Validation.pm
sub is_type ($type, $value) {
567231023.7ms if ($type eq 'null') {
57 return !(defined $value);
58 }
597231080.3ms1650782.6ms if ($type eq 'boolean') {
# spent 82.6ms making 16507 calls to JSON::MaybeXS::is_bool, avg 5µs/call
60 return is_bool($value);
61 }
6255803186ms if ($type eq 'object') {
63 return is_plain_hashref($value);
64 }
65856513.8ms if ($type eq 'array') {
66 return is_plain_arrayref($value);
67 }
68
6937481.42ms if ($type eq 'string' or $type eq 'number' or $type eq 'integer') {
703748696µs return 0 if not defined $value;
71374821.9ms74967.86ms my $flags = B::svref_2object(\$value)->FLAGS;
# spent 5.98ms making 3748 calls to B::svref_2object, avg 2µs/call # spent 1.88ms making 3748 calls to B::SV::FLAGS, avg 501ns/call
72
73374810.0ms if ($type eq 'string') {
74 return !is_ref($value) && $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK));
75 }
76
7719680µs if ($type eq 'number') {
78109547µs10929µs return ref($value) =~ /^Math::Big(?:Int|Float)$/
# spent 29µs making 109 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 266ns/call
79 || !($flags & B::SVf_POK) && ($flags & (B::SVf_IOK | B::SVf_NOK));
80 }
81
828733µs if ($type eq 'integer') {
8387458µs8741µs return ref($value) =~ /^Math::Big(?:Int|Float)$/ && $value->is_int
# spent 41µs making 87 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 471ns/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
9532399848.6ms
# spent 634ms (453+181) within JSON::Schema::Modern::Utilities::get_type which was called 161999 times, avg 4µs/call: # 91595 times (164ms+0s) by JSON::Schema::Modern::_eval_subschema at line 530 of JSON/Schema/Modern.pm, avg 2µs/call # 35648 times (105ms+79.5ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 62 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call # 31892 times (178ms+97.6ms) by JSON::Schema::Modern::Utilities::is_equal at line 120, avg 9µs/call # 2863 times (6.09ms+4.37ms) by JSON::Schema::Modern::_traverse_subschema at line 454 of JSON/Schema/Modern.pm, avg 4µs/call # once (5µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 89 of JSON/Schema/Modern/Document/OpenAPI.pm
sub get_type ($value) {
96161999291ms return 'object' if is_plain_hashref($value);
974163247.5ms41632135ms return 'boolean' if is_bool($value);
# spent 135ms making 41632 calls to JSON::MaybeXS::is_bool, avg 3µs/call
98368465.73ms return 'null' if not defined $value;
99368467.48ms return 'array' if is_plain_arrayref($value);
100
101357414.34ms 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
10535741140ms7148246.1ms my $flags = B::svref_2object(\$value)->FLAGS;
# spent 33.0ms making 35741 calls to B::svref_2object, avg 924ns/call # spent 13.1ms making 35741 calls to B::SV::FLAGS, avg 366ns/call
1063574162.1ms return 'string' if $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK));
107107384µ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
1176378412.1ms
# spent 373ms (97.0+276) within JSON::Schema::Modern::Utilities::is_equal which was called 15946 times, avg 23µs/call: # 7494 times (44.9ms+142ms) by List::Util::any at line 85 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 25µs/call # 7244 times (38.5ms+103ms) by JSON::Schema::Modern::Utilities::is_elements_unique at line 160, avg 20µs/call # 1208 times (13.5ms+30.7ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 95 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 37µs/call
sub is_equal ($x, $y, $state = undef) {
118159465.85ms $state->{path} //= '';
119
1201594625.3ms31892275ms my @types = map get_type($_), $x, $y;
# spent 275ms making 31892 calls to JSON::Schema::Modern::Utilities::get_type, avg 9µs/call
121
122159464.24ms if ($state->{scalarref_booleans}) {
12372441.03ms ($x, $types[0]) = (0+!!$$x, 'boolean') if $types[0] eq 'reference to SCALAR';
1247244823µs ($y, $types[1]) = (0+!!$$y, 'boolean') if $types[1] eq 'reference to SCALAR';
125 }
126
127159463.49ms return 0 if $types[0] ne $types[1];
128154841.97ms return 1 if $types[0] eq 'null';
1291548426.4ms return $x eq $y if $types[0] eq 'string';
1301731.16ms346461µs return $x == $y if grep $types[0] eq $_, qw(boolean number integer);
# spent 461µs making 346 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:7], avg 1µs/call
131
132 my $path = $state->{path};
133 if ($types[0] eq 'object') {
134 return 0 if keys %$x != keys %$y;
135 return 0 if not is_equal([ sort keys %$x ], [ sort keys %$y ]);
136 foreach my $property (sort keys %$x) {
137 $state->{path} = jsonp($path, $property);
138 return 0 if not is_equal($x->{$property}, $y->{$property}, $state);
139 }
140 return 1;
141 }
142
143 if ($types[0] eq 'array') {
144 return 0 if @$x != @$y;
145 foreach my $idx (0 .. $x->$#*) {
146 $state->{path} = $path.'/'.$idx;
147 return 0 if not is_equal($x->[$idx], $y->[$idx], $state);
148 }
149 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
1571920460µs
# spent 163ms (20.9+142) within JSON::Schema::Modern::Utilities::is_elements_unique which was called 640 times, avg 255µs/call: # 288 times (9.47ms+64.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 213 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 257µs/call # 275 times (10.7ms+74.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 264 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 310µs/call # 76 times (795µs+2.78ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 51 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 47µs/call # once (3µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 290 of JSON/Schema/Modern/Vocabulary/Validation.pm
sub is_elements_unique ($array, $equal_indices = undef) {
1586401.19ms foreach my $idx0 (0 .. $array->$#*-1) {
15911411.62ms foreach my $idx1 ($idx0+1 .. $array->$#*) {
160724411.1ms7244142ms if (is_equal($array->[$idx0], $array->[$idx1], { scalarref_booleans => 1 })) {
# spent 142ms making 7244 calls to JSON::Schema::Modern::Utilities::is_equal, avg 20µs/call
161 push @$equal_indices, $idx0, $idx1 if defined $equal_indices;
162 return 0;
163 }
164 }
165 }
1666401.74ms return 1;
167}
168
169# shorthand for creating and appending json pointers
170# the first argument is a a json pointer; remaining arguments are path segments to be encoded and
171# appended
172
# spent 1.41s (1.24+169ms) within JSON::Schema::Modern::Utilities::jsonp which was called 221215 times, avg 6µs/call: # 76007 times (427ms+72.8ms) by JSON::Schema::Modern::Utilities::canonical_uri at line 193, avg 7µs/call # 71790 times (302ms+33.2ms) by JSON::Schema::Modern::Utilities::A at line 250, avg 5µs/call # 41707 times (293ms+35.1ms) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 89 of JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call # 21824 times (159ms+14.7ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 380 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 4217 times (16.7ms+2.02ms) by JSON::Schema::Modern::Utilities::E at line 216, avg 4µs/call # 1835 times (11.4ms+3.94ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 457 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 1476 times (9.21ms+2.43ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 421 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 1349 times (13.7ms+2.03ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 55 of JSON/Schema/Modern/Vocabulary.pm, avg 12µs/call # 713 times (3.92ms+2.47ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 480 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call # 290 times (2.21ms+331µs) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 167 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call # 6 times (47µs+9µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 64 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call # once (9µs+1µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 132 of JSON/Schema/Modern/Vocabulary/Core.pm
sub jsonp {
1732212151.59s469020169ms return join('/', shift, map s/~/~0/gr =~ s!/!~1!gr, map +(is_plain_arrayref($_) ? @$_ : $_), grep defined, @_);
# spent 169ms making 469020 calls to JSON::Schema::Modern::Utilities::CORE:subst, avg 360ns/call
174}
175
176# splits a json pointer apart into its path segments
177sub unjsonp ($path) {
178 return map s!~0!~!gr =~ s!~1!/!gr, split m!/!, $path;
179}
180
181# get all annotations produced for the current instance data location (that are visible to this
182# schema location)
18374941.56ms
# spent 886ms (575+310) within JSON::Schema::Modern::Utilities::local_annotations which was called 3747 times, avg 236µs/call: # 3747 times (575ms+310ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 119 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 236µs/call
sub local_annotations ($state) {
1843747261ms371738310ms grep $_->instance_location eq $state->{data_path}, $state->{annotations}->@*;
# spent 310ms making 371738 calls to JSON::Schema::Modern::Annotation::instance_location, avg 835ns/call
185}
186
187# shorthand for finding the canonical uri of the present schema location
188# last argument can be an arrayref, usually coming from $state->{_schema_path_suffix}
189505032121ms
# spent 6.96s (1.46+5.50) within JSON::Schema::Modern::Utilities::canonical_uri which was called 168344 times, avg 41µs/call: # 91595 times (533ms+2.01s) by JSON::Schema::Modern::_eval_subschema at line 540 of JSON/Schema/Modern.pm, avg 28µs/call # 71790 times (857ms+3.27s) by JSON::Schema::Modern::Utilities::A at line 247, avg 58µs/call # 4217 times (52.0ms+181ms) by JSON::Schema::Modern::Utilities::E at line 213, avg 55µs/call # 727 times (12.4ms+37.8ms) by JSON::Schema::Modern::Document::OpenAPI::_traverse_schema at line 218 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 69µs/call # 15 times (122µs+368µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 162 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 33µs/call
sub canonical_uri ($state, @extra_path) {
190168344157ms return $state->{initial_schema_uri} if not length($state->{schema_path}) and not @extra_path;
19112662546.9ms splice(@extra_path, -1, 1, $extra_path[-1]->@*) if @extra_path and is_plain_arrayref($extra_path[-1]);
192126625189ms1266254.75s my $uri = $state->{initial_schema_uri}->clone;
# spent 4.75s making 126625 calls to Mojo::URL::clone, avg 38µs/call
193126625310ms202632627ms my $fragment = ($uri->fragment//'').(@extra_path ? jsonp($state->{schema_path}, @extra_path) : $state->{schema_path});
# spent 500ms making 76007 calls to JSON::Schema::Modern::Utilities::jsonp, avg 7µs/call # spent 126ms making 126625 calls to Mojo::URL::fragment, avg 998ns/call
19412662530.5ms undef $fragment if not length($fragment);
19512662577.8ms126625121ms $uri->fragment($fragment);
# spent 121ms making 126625 calls to Mojo::URL::fragment, avg 953ns/call
196126625237ms $uri;
197}
198
199# shorthand for creating error objects
200# uses these keys from $state:
201# - initial_schema_uri
202# - keyword
203# - data_path
204# - traversed_schema_path
205# - schema_path
206# - _schema_path_suffix
207# - errors
208168684.85ms
# spent 1.17s (117ms+1.05) within JSON::Schema::Modern::Utilities::E which was called 4217 times, avg 277µs/call: # 1438 times (43.5ms+355ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 273 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 277µs/call # 1115 times (34.5ms+290ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 73 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 291µs/call # 799 times (20.2ms+199ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 97 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 275µs/call # 799 times (16.6ms+190ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 392 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 259µs/call # 66 times (2.00ms+17.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum at line 88 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 297µs/call
sub E ($state, $error_string, @args) {
20942171.51ms croak 'E called in void context' if not defined wantarray;
210
211 # sometimes the keyword shouldn't be at the very end of the schema path
212 my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix})
213421724.6ms8434395ms ->to_abs($state->{effective_base_uri});
# spent 233ms making 4217 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 55µs/call # spent 162ms making 4217 calls to Mojo::URL::to_abs, avg 38µs/call
214
215 my $keyword_location = $state->{traversed_schema_path}
21642178.10ms421718.7ms .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix});
# spent 18.7ms making 4217 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call
217
218421714.6ms8434404ms undef $uri if $uri eq '' and $keyword_location eq ''
# spent 401ms making 4217 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 95µs/call # spent 2.65ms making 4217 calls to Mojo::URL::fragment, avg 629ns/call
219 or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq '';
220
221 push $state->{errors}->@*, JSON::Schema::Modern::Error->new(
222 keyword => $state->{keyword},
223 instance_location => $state->{data_path},
224 keyword_location => $keyword_location,
225 defined $uri ? ( absolute_keyword_location => $uri ) : (),
226 error => @args ? sprintf($error_string, @args) : $error_string,
227421728.7ms4217235ms $state->{exception} ? ( exception => $state->{exception} ) : (),
# spent 235ms making 4217 calls to JSON::Schema::Modern::Error::new, avg 56µs/call
228 );
229
230421713.7ms return 0;
231}
232
233# shorthand for creating annotations
234# uses these keys from $state:
235# - initial_schema_uri
236# - keyword
237# - data_path
238# - traversed_schema_path
239# - schema_path
240# - _schema_path_suffix
241# - annotations
242# - collect_annotations
24321537643.9ms
# spent 19.7s (1.64+18.1) within JSON::Schema::Modern::Utilities::A which was called 71792 times, avg 275µs/call: # 32214 times (705ms+8.00s) by JSON::Schema::Modern::Utilities::annotate_self at line 345, avg 270µs/call # 28612 times (694ms+7.34s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 391 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 281µs/call # 3747 times (71.0ms+912ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 147 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 262µs/call # 3369 times (84.9ms+878ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 433 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 286µs/call # 2167 times (53.6ms+541ms) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_eval_keyword_format at line 40 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 275µs/call # 977 times (18.7ms+234ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 468 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 259µs/call # 643 times (14.8ms+161ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 325 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 274µs/call # 63 times (1.54ms+17.0ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 183 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 294µs/call
sub A ($state, $annotation) {
2447179252.7ms return 1 if not $state->{collect_annotations} or $state->{spec_version} eq 'draft7';
245
246 my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix})
24771790366ms1435806.98s ->to_abs($state->{effective_base_uri});
# spent 4.13s making 71790 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 58µs/call # spent 2.85s making 71790 calls to Mojo::URL::to_abs, avg 40µs/call
248
249 my $keyword_location = $state->{traversed_schema_path}
25071790146ms71790335ms .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix});
# spent 335ms making 71790 calls to JSON::Schema::Modern::Utilities::jsonp, avg 5µs/call
251
25271790222ms1435807.34s undef $uri if $uri eq '' and $keyword_location eq ''
# spent 7.29s making 71790 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 102µs/call # spent 45.9ms making 71790 calls to Mojo::URL::fragment, avg 639ns/call
253 or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq '';
254
255 push $state->{annotations}->@*, JSON::Schema::Modern::Annotation->new(
256 keyword => $state->{keyword},
257 instance_location => $state->{data_path},
258 keyword_location => $keyword_location,
259 defined $uri ? ( absolute_keyword_location => $uri ) : (),
260 annotation => $annotation,
26171790254ms717903.42s $state->{_unknown} ? ( unknown => 1 ) : (),
# spent 3.42s making 71790 calls to JSON::Schema::Modern::Annotation::new, avg 48µs/call
262 );
263
26471790224ms return 1;
265}
266
267# creates an error object, but also aborts evaluation immediately
268# only this error is returned, because other errors on the stack might not actually be "real"
269# errors (consider if we were in the middle of evaluating a "not" or "if").
270# Therefore this is only appropriate during the evaluation phase, not the traverse phase.
271sub abort ($state, $error_string, @args) {
272 ()= E({ %$state, exception => 1 }, $error_string, @args);
273 croak 'abort() called during traverse' if $state->{traverse};
274 die pop $state->{errors}->@*;
275}
276
27731µs
# spent 5µs within JSON::Schema::Modern::Utilities::assert_keyword_exists which was called: # once (5µ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) {
27810s croak 'assert_keyword_exists called in void context' if not defined wantarray;
27911µs return E($state, '%s keyword is required', $state->{keyword}) if not exists $schema->{$state->{keyword}};
28013µs return 1;
281}
282
283143602.16ms
# spent 51.3ms (19.3+32.1) within JSON::Schema::Modern::Utilities::assert_keyword_type which was called 3590 times, avg 14µs/call: # 1306 times (7.24ms+15.1ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 54 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 17µs/call # 732 times (3.86ms+7.69ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 203 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 16µs/call # 402 times (3.02ms+1.19ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 50 of JSON/Schema/Modern/Vocabulary.pm, avg 10µs/call # 275 times (1.19ms+515µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 261 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 6µs/call # 150 times (531µs+1.68ms) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_deprecated at line 55 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 15µs/call # 131 times (632µs+1.09ms) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_title at line 38 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 13µs/call # 118 times (618µs+1.16ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_comment at line 285 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 15µs/call # 87 times (329µs+917µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer at line 318 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call # 76 times (342µs+151µs) by JSON::Schema::Modern::Vocabulary::traverse_array_schemas at line 38 of JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call # 69 times (361µs+723µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 16µs/call # 60 times (221µs+97µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum at line 78 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call # 50 times (166µs+292µs) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_traverse_keyword_format at line 35 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 9µs/call # 31 times (146µs+341µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 265 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 16µs/call # 30 times (124µs+290µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_number at line 313 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call # 15 times (121µs+229µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 112 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 23µs/call # 15 times (95µs+207µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 153 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 20µs/call # 14 times (124µs+270µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 28µs/call # 11 times (79µs+59µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 256 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 13µs/call # 6 times (24µs+14µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 397 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 6µs/call # 6 times (23µs+12µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 61 of JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call # 3 times (13µs+36µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems at line 206 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 16µs/call # once (7µs+36µs) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm # once (4µs+2µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 277 of JSON/Schema/Modern/Vocabulary/Validation.pm # once (3µs+2µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding at line 39 of JSON/Schema/Modern/Vocabulary/Content.pm
sub assert_keyword_type ($state, $schema, $type) {
2843590860µs croak 'assert_keyword_type called in void context' if not defined wantarray;
28535902.83ms my $value = $schema->{$state->{keyword}};
2863590747µs my $thing = 'value';
287 ($value, $thing) = is_plain_hashref($value) ? ($value->{$state->{_schema_path_suffix}}, 'value at "'.$state->{_schema_path_suffix}.'"')
288 : is_plain_arrayref($value) ? ($value->[$state->{_schema_path_suffix}], 'item '.$state->{_schema_path_suffix})
289 : die 'unknown type'
2903590816µs if exists $state->{_schema_path_suffix};
291359011.7ms359032.1ms return 1 if is_type($type, $value);
# spent 32.1ms making 3590 calls to JSON::Schema::Modern::Utilities::is_type, avg 9µs/call
292 E($state, '%s %s is not a%s %s', $state->{keyword}, $thing, ($type =~ /^[aeiou]/ ? 'n' : ''), $type);
293}
294
29522551µs
# spent 3.64ms (1.30+2.34) within JSON::Schema::Modern::Utilities::assert_pattern which was called 75 times, avg 48µs/call: # 69 times (1.18ms+2.17ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 49µs/call # 6 times (114µs+171µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 401 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 47µs/call
sub assert_pattern ($state, $pattern) {
2967524µs croak 'assert_pattern called in void context' if not defined wantarray;
2977579µs try {
29875418µs local $SIG{__WARN__} = sub { die @_ };
299752.96ms1502.34ms qr/$pattern/;
# spent 2.16ms making 75 calls to JSON::Schema::Modern::Utilities::CORE:regcomp, avg 29µs/call # spent 183µs making 75 calls to JSON::Schema::Modern::Utilities::CORE:qr, avg 2µs/call
300 }
301 catch ($e) { return E($state, $e); };
30275141µs return 1;
303}
304
305# this is only suitable for checking URIs within schemas themselves
3062238394µs
# spent 195ms (12.9+182) within JSON::Schema::Modern::Utilities::assert_uri_reference which was called 746 times, avg 261µs/call: # 732 times (12.7ms+180ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 203 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 263µs/call # 14 times (206µs+2.31ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 180µs/call
sub assert_uri_reference ($state, $schema) {
307746274µs croak 'assert_uri_reference called in void context' if not defined wantarray;
308
309746489µs my $string = $schema->{$state->{keyword}};
310 return E($state, '%s value is not a valid URI reference', $state->{keyword})
311 # see also uri-reference format sub
31274615.4ms5108182ms if fc(Mojo::URL->new($string)->to_unsafe_string) ne fc($string)
# spent 105ms making 746 calls to Mojo::URL::new, avg 141µs/call # spent 70.8ms making 746 calls to Mojo::URL::to_unsafe_string, avg 95µs/call # spent 5.71ms making 3616 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 2µs/call
313 or $string =~ /[^[:ascii:]]/
314 or $string =~ /#/
315 and $string !~ m{#$} # empty fragment
316 and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment
317 and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment
318
3197461.87ms return 1;
320}
321
322# this is only suitable for checking URIs within schemas themselves
32318446µs
# spent 7.97ms (786µs+7.19) within JSON::Schema::Modern::Utilities::assert_uri which was called 46 times, avg 173µs/call: # 31 times (481µs+4.52ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 266 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 161µs/call # 15 times (305µs+2.67ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 112 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 198µs/call
sub assert_uri ($state, $schema, $override = undef) {
3244614µs croak 'assert_uri called in void context' if not defined wantarray;
325
3264623µs my $string = $override // $schema->{$state->{keyword}};
3274693µs462.24ms my $uri = Mojo::URL->new($string);
# spent 2.24ms making 46 calls to Mojo::URL::new, avg 49µs/call
328
32946341µs1844.94ms return E($state, '"%s" is not a valid URI', $string)
# spent 4.73ms making 46 calls to Mojo::URL::to_unsafe_string, avg 103µs/call # spent 170µs making 46 calls to Mojo::URL::is_abs, avg 4µs/call # spent 46µs making 92 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 500ns/call
330 # see also uri format sub
331 if fc($uri->to_unsafe_string) ne fc($string)
332 or $string =~ /[^[:ascii:]]/
333 or not $uri->is_abs
334 or $string =~ /#/
335 and $string !~ m{#$} # empty fragment
336 and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment
337 and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment
338
33946198µs return 1;
340}
341
342# produces an annotation whose value is the same as that of the current keyword
3439664216.4ms
# spent 8.95s (212ms+8.74) within JSON::Schema::Modern::Utilities::annotate_self which was called 32214 times, avg 278µs/call: # 32214 times (212ms+8.74s) by JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_title at line 43 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 278µs/call
sub annotate_self ($state, $schema) {
344 A($state, is_ref($schema->{$state->{keyword}}) ? dclone($schema->{$state->{keyword}})
34532214186ms333278.74s : $schema->{$state->{keyword}});
# spent 8.70s making 32214 calls to JSON::Schema::Modern::Utilities::A, avg 270µs/call # spent 40.9ms making 1113 calls to Storable::dclone, avg 37µs/call
346}
347
348sub sprintf_num ($value) {
349 # use original value as stored in the NV, without losing precision
350 ref($value) =~ /^Math::Big(?:Int|Float)$/ ? $value->bstr : sprintf('%s', $value);
351}
352
35317µs1;
354
355154µs1324µs__END__
 
# spent 5.82ms within JSON::Schema::Modern::Utilities::CORE:match which was called 3904 times, avg 1µs/call: # 3616 times (5.71ms+0s) by JSON::Schema::Modern::Utilities::assert_uri_reference at line 312, avg 2µs/call # 109 times (29µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 78, avg 266ns/call # 92 times (46µs+0s) by JSON::Schema::Modern::Utilities::assert_uri at line 329, avg 500ns/call # 87 times (41µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 83, avg 471ns/call
sub JSON::Schema::Modern::Utilities::CORE:match; # opcode
# spent 183µs within JSON::Schema::Modern::Utilities::CORE:qr which was called 75 times, avg 2µs/call: # 75 times (183µs+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 299, avg 2µs/call
sub JSON::Schema::Modern::Utilities::CORE:qr; # opcode
# spent 2.16ms within JSON::Schema::Modern::Utilities::CORE:regcomp which was called 75 times, avg 29µs/call: # 75 times (2.16ms+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 299, avg 29µs/call
sub JSON::Schema::Modern::Utilities::CORE:regcomp; # opcode
# spent 169ms within JSON::Schema::Modern::Utilities::CORE:subst which was called 469020 times, avg 360ns/call: # 469020 times (169ms+0s) by JSON::Schema::Modern::Utilities::jsonp at line 173, avg 360ns/call
sub JSON::Schema::Modern::Utilities::CORE:subst; # opcode
# spent 2µs within JSON::Schema::Modern::Utilities::__ANON__ which was called 2 times, avg 1µs/call: # once (1µs+0s) by JSON::Schema::Modern::Utilities::BEGIN@23 at line 23 # once (1µs+0s) by JSON::Schema::Modern::Utilities::BEGIN@24 at line 24
sub JSON::Schema::Modern::Utilities::__ANON__; # xsub