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

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Utilities.pm
StatementsExecuted 3784360 statements in 5.03s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
168344541.38s6.76sJSON::Schema::Modern::Utilities::::canonical_uriJSON::Schema::Modern::Utilities::canonical_uri
2212151241.19s1.35sJSON::Schema::Modern::Utilities::::jsonpJSON::Schema::Modern::Utilities::jsonp
7179285875ms5.16sJSON::Schema::Modern::Utilities::::AJSON::Schema::Modern::Utilities::A
16199954460ms648msJSON::Schema::Modern::Utilities::::get_typeJSON::Schema::Modern::Utilities::get_type
72310235288ms393msJSON::Schema::Modern::Utilities::::is_typeJSON::Schema::Modern::Utilities::is_type
46902011155ms155msJSON::Schema::Modern::Utilities::::CORE:substJSON::Schema::Modern::Utilities::CORE:subst (opcode)
3221411146ms2.39sJSON::Schema::Modern::Utilities::::annotate_selfJSON::Schema::Modern::Utilities::annotate_self
374711143ms143msJSON::Schema::Modern::Utilities::::local_annotationsJSON::Schema::Modern::Utilities::local_annotations
421752128ms1.24sJSON::Schema::Modern::Utilities::::EJSON::Schema::Modern::Utilities::E
1594632101ms352msJSON::Schema::Modern::Utilities::::is_equalJSON::Schema::Modern::Utilities::is_equal
6404118.7ms148msJSON::Schema::Modern::Utilities::::is_elements_uniqueJSON::Schema::Modern::Utilities::is_elements_unique
359024816.2ms44.2msJSON::Schema::Modern::Utilities::::assert_keyword_typeJSON::Schema::Modern::Utilities::assert_keyword_type
7462110.4ms162msJSON::Schema::Modern::Utilities::::assert_uri_referenceJSON::Schema::Modern::Utilities::assert_uri_reference
3904415.21ms5.21msJSON::Schema::Modern::Utilities::::CORE:matchJSON::Schema::Modern::Utilities::CORE:match (opcode)
75111.94ms1.94msJSON::Schema::Modern::Utilities::::CORE:regcompJSON::Schema::Modern::Utilities::CORE:regcomp (opcode)
75221.15ms3.24msJSON::Schema::Modern::Utilities::::assert_patternJSON::Schema::Modern::Utilities::assert_pattern
4621613µs6.63msJSON::Schema::Modern::Utilities::::assert_uriJSON::Schema::Modern::Utilities::assert_uri
7511152µs152µsJSON::Schema::Modern::Utilities::::CORE:qrJSON::Schema::Modern::Utilities::CORE:qr (opcode)
111102µs105µsJSON::Schema::Modern::::BEGIN@1.159 JSON::Schema::Modern::BEGIN@1.159
11143µs49µsJSON::Schema::Modern::Utilities::::BEGIN@14JSON::Schema::Modern::Utilities::BEGIN@14
11138µs64µsJSON::Schema::Modern::Utilities::::BEGIN@18JSON::Schema::Modern::Utilities::BEGIN@18
11128µs30µsJSON::Schema::Modern::Utilities::::BEGIN@16JSON::Schema::Modern::Utilities::BEGIN@16
11113µs688µsJSON::Schema::Modern::Utilities::::BEGIN@10JSON::Schema::Modern::Utilities::BEGIN@10
11113µs14µsJSON::Schema::Modern::Utilities::::BEGIN@23JSON::Schema::Modern::Utilities::BEGIN@23
11112µs37µsJSON::Schema::Modern::Utilities::::BEGIN@12JSON::Schema::Modern::Utilities::BEGIN@12
11111µs68µsJSON::Schema::Modern::Utilities::::BEGIN@53JSON::Schema::Modern::Utilities::BEGIN@53
11111µs11µsJSON::Schema::Modern::Utilities::::BEGIN@9JSON::Schema::Modern::Utilities::BEGIN@9
1119µs18µsJSON::Schema::Modern::Utilities::::BEGIN@15JSON::Schema::Modern::Utilities::BEGIN@15
1118µs20µsJSON::Schema::Modern::Utilities::::BEGIN@13JSON::Schema::Modern::Utilities::BEGIN@13
1117µs8µsJSON::Schema::Modern::Utilities::::BEGIN@24JSON::Schema::Modern::Utilities::BEGIN@24
1116µs53µsJSON::Schema::Modern::::BEGIN@2.160 JSON::Schema::Modern::BEGIN@2.160
1116µs87µsJSON::Schema::Modern::Utilities::::BEGIN@11JSON::Schema::Modern::Utilities::BEGIN@11
1116µs179µsJSON::Schema::Modern::Utilities::::BEGIN@25JSON::Schema::Modern::Utilities::BEGIN@25
1116µs11µsJSON::Schema::Modern::Utilities::::BEGIN@27JSON::Schema::Modern::Utilities::BEGIN@27
1115µs24µsJSON::Schema::Modern::Utilities::::BEGIN@19JSON::Schema::Modern::Utilities::BEGIN@19
1115µs11µsJSON::Schema::Modern::Utilities::::BEGIN@20JSON::Schema::Modern::Utilities::BEGIN@20
1115µs15µsJSON::Schema::Modern::Utilities::::BEGIN@21JSON::Schema::Modern::Utilities::BEGIN@21
1115µs21µsJSON::Schema::Modern::Utilities::::BEGIN@22JSON::Schema::Modern::Utilities::BEGIN@22
1115µs5µsJSON::Schema::Modern::Utilities::::BEGIN@52JSON::Schema::Modern::Utilities::BEGIN@52
1114µs29µsJSON::Schema::Modern::Utilities::::BEGIN@17JSON::Schema::Modern::Utilities::BEGIN@17
1114µs4µ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__[:299]JSON::Schema::Modern::Utilities::__ANON__[:299]
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
1240µs2108µs
# spent 105µs (102+3) within JSON::Schema::Modern::BEGIN@1.159 which was called: # once (102µs+3µs) by JSON::Schema::Modern::BEGIN@36 at line 1
use strict;
# spent 105µs making 1 call to JSON::Schema::Modern::BEGIN@1.159 # spent 3µs making 1 call to strict::import
2234µs2100µs
# spent 53µs (6+47) within JSON::Schema::Modern::BEGIN@2.160 which was called: # once (6µs+47µs) by JSON::Schema::Modern::BEGIN@36 at line 2
use warnings;
# spent 53µs making 1 call to JSON::Schema::Modern::BEGIN@2.160 # spent 47µ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.558';
8
9234µ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
10327µs31.36ms
# spent 688µs (13+675) within JSON::Schema::Modern::Utilities::BEGIN@10 which was called: # once (13µs+675µs) by JSON::Schema::Modern::BEGIN@36 at line 10
use strictures 2;
# spent 688µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@10 # spent 660µs making 1 call to strictures::import # spent 15µs making 1 call to strictures::VERSION
11231µs2168µs
# spent 87µs (6+81) within JSON::Schema::Modern::Utilities::BEGIN@11 which was called: # once (6µs+81µs) by JSON::Schema::Modern::BEGIN@36 at line 11
use experimental qw(signatures postderef);
# spent 87µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@11 # spent 81µs making 1 call to experimental::import
12222µs240µs
# spent 37µs (12+25) within JSON::Schema::Modern::Utilities::BEGIN@12 which was called: # once (12µs+25µs) by JSON::Schema::Modern::BEGIN@36 at line 12
use if "$]" >= 5.022, experimental => 're_strict';
# spent 37µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@12 # spent 3µs making 1 call to if::import
13242µs222µs
# spent 20µs (8+12) within JSON::Schema::Modern::Utilities::BEGIN@13 which was called: # once (8µs+12µs) by JSON::Schema::Modern::BEGIN@36 at line 13
no if "$]" >= 5.031009, feature => 'indirect';
# spent 20µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@13 # spent 2µs making 1 call to if::unimport
14215µs249µs
# spent 49µs (43+6) within JSON::Schema::Modern::Utilities::BEGIN@14 which was called: # once (43µs+6µs) by JSON::Schema::Modern::BEGIN@36 at line 14
no if "$]" >= 5.033001, feature => 'multidimensional';
# spent 49µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@14 # spent 0s making 1 call to if::unimport
15236µs219µs
# spent 18µs (9+9) within JSON::Schema::Modern::Utilities::BEGIN@15 which was called: # once (9µs+9µs) by JSON::Schema::Modern::BEGIN@36 at line 15
no if "$]" >= 5.033006, feature => 'bareword_filehandles';
# spent 18µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@15 # spent 1µs making 1 call to if::unimport
16214µs232µs
# spent 30µs (28+2) within JSON::Schema::Modern::Utilities::BEGIN@16 which was called: # once (28µs+2µs) by JSON::Schema::Modern::BEGIN@36 at line 16
use B;
# spent 30µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@16 # spent 2µs making 1 call to B::import
17217µs254µs
# spent 29µs (4+25) within JSON::Schema::Modern::Utilities::BEGIN@17 which was called: # once (4µs+25µs) by JSON::Schema::Modern::BEGIN@36 at line 17
use Carp 'croak';
# spent 29µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@17 # spent 25µs making 1 call to Exporter::import
18327µs390µs
# spent 64µs (38+26) within JSON::Schema::Modern::Utilities::BEGIN@18 which was called: # once (38µs+26µs) by JSON::Schema::Modern::BEGIN@36 at line 18
use JSON::MaybeXS 1.004004 'is_bool';
# spent 64µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@18 # spent 21µs making 1 call to Exporter::import # spent 5µs making 1 call to UNIVERSAL::VERSION
19323µs343µs
# spent 24µs (5+19) within JSON::Schema::Modern::Utilities::BEGIN@19 which was called: # once (5µs+19µ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 24µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@19 # spent 14µs making 1 call to Exporter::import # spent 5µs making 1 call to UNIVERSAL::VERSION
20215µs217µs
# spent 11µs (5+6) within JSON::Schema::Modern::Utilities::BEGIN@20 which was called: # once (5µs+6µs) by JSON::Schema::Modern::BEGIN@36 at line 20
use Scalar::Util 'blessed';
# spent 11µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@20 # spent 6µs making 1 call to Exporter::import
21213µs225µs
# spent 15µs (5+10) within JSON::Schema::Modern::Utilities::BEGIN@21 which was called: # once (5µs+10µs) by JSON::Schema::Modern::BEGIN@36 at line 21
use Storable 'dclone';
# spent 15µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@21 # spent 10µs making 1 call to Exporter::import
22213µs237µs
# spent 21µs (5+16) within JSON::Schema::Modern::Utilities::BEGIN@22 which was called: # once (5µs+16µs) by JSON::Schema::Modern::BEGIN@36 at line 22
use Feature::Compat::Try;
# spent 21µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@22 # spent 16µs making 1 call to Feature::Compat::Try::import
23225µs215µs
# spent 14µs (13+1) within JSON::Schema::Modern::Utilities::BEGIN@23 which was called: # once (13µs+1µs) by JSON::Schema::Modern::BEGIN@36 at line 23
use JSON::Schema::Modern::Error;
# spent 14µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@23 # spent 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__
24216µs29µs
# spent 8µs (7+1000ns) within JSON::Schema::Modern::Utilities::BEGIN@24 which was called: # once (7µs+1000ns) by JSON::Schema::Modern::BEGIN@36 at line 24
use JSON::Schema::Modern::Annotation;
# spent 8µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@24 # spent 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__
25223µs2352µs
# spent 179µs (6+173) within JSON::Schema::Modern::Utilities::BEGIN@25 which was called: # once (6µs+173µs) by JSON::Schema::Modern::BEGIN@36 at line 25
use namespace::clean;
# spent 179µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@25 # spent 173µs making 1 call to namespace::clean::import
26
272185µs216µs
# spent 11µs (6+5) within JSON::Schema::Modern::Utilities::BEGIN@27 which was called: # once (6µs+5µs) by JSON::Schema::Modern::BEGIN@36 at line 27
use Exporter 'import';
# spent 11µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@27 # spent 5µ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
52238µs15µs
# spent 5µs within JSON::Schema::Modern::Utilities::BEGIN@52 which was called: # once (5µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 52
use JSON::PP ();
# spent 5µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@52
5322.56ms4125µs
# spent 68µs (11+57) within JSON::Schema::Modern::Utilities::BEGIN@53 which was called: # once (11µs+57µs) by JSON::Schema::Modern::BEGIN@36 at line 53
use constant { true => JSON::PP::true, false => JSON::PP::false };
# spent 68µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@53 # spent 53µs making 1 call to constant::import # spent 2µs making 1 call to JSON::PP::false # spent 2µs making 1 call to JSON::PP::true
54
5521693053.9ms
# spent 393ms (288+105) within JSON::Schema::Modern::Utilities::is_type which was called 72310 times, avg 5µs/call: # 32492 times (132ms+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 (43.9ms+65.8ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 374 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 10µs/call # 4795 times (16.6ms+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.57ms+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 (21.2ms+6.84ms) by JSON::Schema::Modern::Utilities::assert_keyword_type at line 292, avg 8µs/call # 3369 times (15.4ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 408 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 5µs/call # 1835 times (7.14ms+11.1ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 451 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 10µs/call # 1799 times (6.33ms+12.4ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 415 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 10µs/call # 1758 times (8.20ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 299 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 5µs/call # 1632 times (6.44ms+7.55ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 305 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call # 1403 times (2.05ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 211 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 1µs/call # 1244 times (4.39ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems at line 200 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 4µs/call # 977 times (3.58ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 441 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call # 774 times (3.58ms+592µs) by List::Util::any at line 263 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call # 627 times (1.65ms+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.16ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties at line 254 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call # 305 times (523µ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.64ms+768µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 183 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 13µs/call # 79 times (1.02ms+91µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum at line 146 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call # 63 times (650µs+170µs) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 182 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 13µs/call # 15 times (41µ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 (1µs+2µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 286 of JSON/Schema/Modern/Vocabulary/Validation.pm # once (0s+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) {
567231029.9ms if ($type eq 'null') {
57 return !(defined $value);
58 }
597231098.1ms1650798.2ms if ($type eq 'boolean') {
# spent 98.2ms making 16507 calls to JSON::MaybeXS::is_bool, avg 6µs/call
60 return is_bool($value);
61 }
6255803152ms if ($type eq 'object') {
63 return is_plain_hashref($value);
64 }
65856514.8ms if ($type eq 'array') {
66 return is_plain_arrayref($value);
67 }
68
6937481.27ms if ($type eq 'string' or $type eq 'number' or $type eq 'integer') {
703748741µs return 0 if not defined $value;
71374818.9ms74966.99ms my $flags = B::svref_2object(\$value)->FLAGS;
# spent 5.34ms making 3748 calls to B::svref_2object, avg 1µs/call # spent 1.64ms making 3748 calls to B::SV::FLAGS, avg 439ns/call
72
7337488.74ms if ($type eq 'string') {
74 return !is_ref($value) && $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK));
75 }
76
7719698µs if ($type eq 'number') {
78109610µs10935µs return ref($value) =~ /^Math::Big(?:Int|Float)$/
# spent 35µs making 109 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 321ns/call
79 || !($flags & B::SVf_POK) && ($flags & (B::SVf_IOK | B::SVf_NOK));
80 }
81
828727µs if ($type eq 'integer') {
8387442µs8721µs return ref($value) =~ /^Math::Big(?:Int|Float)$/ && $value->is_int
# spent 21µs making 87 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 241ns/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
9532399850.7ms
# spent 648ms (460+188) within JSON::Schema::Modern::Utilities::get_type which was called 161999 times, avg 4µs/call: # 91595 times (186ms+0s) by JSON::Schema::Modern::_eval_subschema at line 534 of JSON/Schema/Modern.pm, avg 2µs/call # 35648 times (114ms+88.1ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 62 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 6µs/call # 31892 times (154ms+96.6ms) by JSON::Schema::Modern::Utilities::is_equal at line 120, avg 8µs/call # 2863 times (5.57ms+3.22ms) by JSON::Schema::Modern::_traverse_subschema at line 458 of JSON/Schema/Modern.pm, avg 3µs/call # once (3µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 89 of JSON/Schema/Modern/Document/OpenAPI.pm
sub get_type ($value) {
96161999320ms return 'object' if is_plain_hashref($value);
974163248.1ms41632140ms return 'boolean' if is_bool($value);
# spent 140ms making 41632 calls to JSON::MaybeXS::is_bool, avg 3µs/call
98368466.60ms return 'null' if not defined $value;
99368467.54ms return 'array' if is_plain_arrayref($value);
100
101357414.70ms 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
10535741142ms7148247.9ms my $flags = B::svref_2object(\$value)->FLAGS;
# spent 34.2ms making 35741 calls to B::svref_2object, avg 956ns/call # spent 13.7ms making 35741 calls to B::SV::FLAGS, avg 384ns/call
1063574159.1ms return 'string' if $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK));
107107332µ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.3ms
# spent 352ms (101+251) within JSON::Schema::Modern::Utilities::is_equal which was called 15946 times, avg 22µs/call: # 7494 times (48.8ms+125ms) by List::Util::any at line 85 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 23µs/call # 7244 times (36.3ms+92.7ms) by JSON::Schema::Modern::Utilities::is_elements_unique at line 160, avg 18µs/call # 1208 times (15.4ms+33.7ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 95 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 41µs/call
sub is_equal ($x, $y, $state = undef) {
118159466.99ms $state->{path} //= '';
119
1201594625.9ms31892251ms my @types = map get_type($_), $x, $y;
# spent 251ms making 31892 calls to JSON::Schema::Modern::Utilities::get_type, avg 8µs/call
121
122159464.59ms if ($state->{scalarref_booleans}) {
1237244954µs ($x, $types[0]) = (0+!!$$x, 'boolean') if $types[0] eq 'reference to SCALAR';
1247244908µs ($y, $types[1]) = (0+!!$$y, 'boolean') if $types[1] eq 'reference to SCALAR';
125 }
126
127159463.74ms return 0 if $types[0] ne $types[1];
128154842.53ms return 1 if $types[0] eq 'null';
1291548425.8ms return $x eq $y if $types[0] eq 'string';
1301731.33ms346555µs return $x == $y if grep $types[0] eq $_, qw(boolean number integer);
# spent 555µs making 346 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:7], avg 2µ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
1571920394µs
# spent 148ms (18.7+129) within JSON::Schema::Modern::Utilities::is_elements_unique which was called 640 times, avg 231µs/call: # 288 times (9.20ms+64.3ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 213 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 255µs/call # 275 times (8.67ms+61.9ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 264 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 257µs/call # 76 times (780µs+2.79ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 51 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 47µs/call # once (4µ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.12ms foreach my $idx0 (0 .. $array->$#*-1) {
15911411.46ms foreach my $idx1 ($idx0+1 .. $array->$#*) {
160724410.5ms7244129ms if (is_equal($array->[$idx0], $array->[$idx1], { scalarref_booleans => 1 })) {
# spent 129ms making 7244 calls to JSON::Schema::Modern::Utilities::is_equal, avg 18µs/call
161 push @$equal_indices, $idx0, $idx1 if defined $equal_indices;
162 return 0;
163 }
164 }
165 }
1666401.37ms 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.35s (1.19+155ms) within JSON::Schema::Modern::Utilities::jsonp which was called 221215 times, avg 6µs/call: # 76007 times (404ms+64.0ms) by JSON::Schema::Modern::Utilities::canonical_uri at line 193, avg 6µs/call # 71790 times (270ms+24.0ms) by JSON::Schema::Modern::Utilities::A at line 253, avg 4µs/call # 41707 times (324ms+39.5ms) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 89 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call # 21824 times (142ms+14.9ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 380 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call # 4217 times (17.1ms+1.88ms) by JSON::Schema::Modern::Utilities::E at line 216, avg 4µs/call # 1835 times (11.6ms+3.73ms) 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 (8.40ms+2.30ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 421 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call # 1349 times (9.56ms+1.68ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 55 of JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call # 713 times (4.06ms+2.52ms) 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.01ms+272µs) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 167 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 6 times (35µs+6µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 64 of JSON/Schema/Modern/Vocabulary.pm, avg 7µs/call # once (4µs+2µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 132 of JSON/Schema/Modern/Vocabulary/Core.pm
sub jsonp {
1732212151.53s469020155ms return join('/', shift, map s/~/~0/gr =~ s!/!~1!gr, map +(is_plain_arrayref($_) ? @$_ : $_), grep defined, @_);
# spent 155ms making 469020 calls to JSON::Schema::Modern::Utilities::CORE:subst, avg 330ns/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) - remember these are hashrefs, not Annotation objects
18374941.33ms
# spent 143ms within JSON::Schema::Modern::Utilities::local_annotations which was called 3747 times, avg 38µs/call: # 3747 times (143ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 119 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 38µs/call
sub local_annotations ($state) {
1843747145ms grep $_->{instance_location} eq $state->{data_path}, $state->{annotations}->@*;
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}
189505032119ms
# spent 6.76s (1.38+5.38) within JSON::Schema::Modern::Utilities::canonical_uri which was called 168344 times, avg 40µs/call: # 91595 times (522ms+1.97s) by JSON::Schema::Modern::_eval_subschema at line 544 of JSON/Schema/Modern.pm, avg 27µs/call # 71790 times (799ms+3.19s) by JSON::Schema::Modern::Utilities::A at line 250, avg 56µs/call # 4217 times (45.2ms+185ms) by JSON::Schema::Modern::Utilities::E at line 213, avg 55µs/call # 727 times (11.4ms+33.8ms) by JSON::Schema::Modern::Document::OpenAPI::_traverse_schema at line 218 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 62µs/call # 15 times (80µs+187µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 162 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 18µs/call
sub canonical_uri ($state, @extra_path) {
190168344139ms return $state->{initial_schema_uri} if not @extra_path and not length($state->{schema_path});
19112662540.8ms splice(@extra_path, -1, 1, $extra_path[-1]->@*) if @extra_path and is_plain_arrayref($extra_path[-1]);
192126625159ms1266254.67s my $uri = $state->{initial_schema_uri}->clone;
# spent 4.67s making 126625 calls to Mojo::URL::clone, avg 37µs/call
193126625297ms202632591ms my $fragment = ($uri->fragment//'').(@extra_path ? jsonp($state->{schema_path}, @extra_path) : $state->{schema_path});
# spent 468ms making 76007 calls to JSON::Schema::Modern::Utilities::jsonp, avg 6µs/call # spent 123ms making 126625 calls to Mojo::URL::fragment, avg 970ns/call
19412662527.9ms undef $fragment if not length($fragment);
19512662583.8ms126625118ms $uri->fragment($fragment);
# spent 118ms making 126625 calls to Mojo::URL::fragment, avg 929ns/call
196126625234ms $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.88ms
# spent 1.24s (128ms+1.11) within JSON::Schema::Modern::Utilities::E which was called 4217 times, avg 293µs/call: # 1438 times (47.6ms+380ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 273 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 297µs/call # 1115 times (38.4ms+315ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 73 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 317µs/call # 799 times (23.1ms+210ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 97 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 292µs/call # 799 times (17.2ms+183ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 392 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 251µs/call # 66 times (2.01ms+18.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum at line 88 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 312µs/call
sub E ($state, $error_string, @args) {
20942171.36ms 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})
213421727.5ms8434392ms ->to_abs($state->{effective_base_uri});
# spent 231ms making 4217 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 55µs/call # spent 161ms making 4217 calls to Mojo::URL::to_abs, avg 38µs/call
214
215 my $keyword_location = $state->{traversed_schema_path}
21642178.99ms421719.0ms .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix});
# spent 19.0ms making 4217 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call
217
218421717.0ms8434440ms undef $uri if $uri eq '' and $keyword_location eq ''
# spent 437ms making 4217 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 104µs/call # spent 2.84ms making 4217 calls to Mojo::URL::fragment, avg 675ns/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,
227421732.4ms4217256ms $state->{exception} ? ( exception => $state->{exception} ) : (),
# spent 256ms making 4217 calls to JSON::Schema::Modern::Error::new, avg 61µs/call
228 );
229
230421712.8ms 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
24321537644.7ms
# spent 5.16s (875ms+4.28) within JSON::Schema::Modern::Utilities::A which was called 71792 times, avg 72µs/call: # 32214 times (344ms+1.84s) by JSON::Schema::Modern::Utilities::annotate_self at line 346, avg 68µs/call # 28612 times (392ms+1.78s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 391 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 76µs/call # 3747 times (34.1ms+203ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 147 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 63µs/call # 3369 times (52.6ms+223ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 433 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 82µs/call # 2167 times (32.9ms+137ms) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_eval_keyword_format at line 40 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 79µs/call # 977 times (9.83ms+53.8ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 468 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 65µs/call # 643 times (9.23ms+42.1ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 325 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 80µs/call # 63 times (1.01ms+4.18ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 180 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 82µs/call
sub A ($state, $annotation) {
2447179252.4ms return 1 if not $state->{collect_annotations} or $state->{spec_version} eq 'draft7';
245
246 # we store the absolute uri in unresolved form until needed,
247 # and perform the rest of the calculations later.
248
249 my $uri = [ canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix}),
25071790196ms717903.99s $state->{effective_base_uri} ];
# spent 3.99s making 71790 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 56µs/call
251
252 my $keyword_location = $state->{traversed_schema_path}
25371790136ms71790294ms .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix});
# spent 294ms making 71790 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call
254
255 push $state->{annotations}->@*, {
256 keyword => $state->{keyword},
257 instance_location => $state->{data_path},
258 keyword_location => $keyword_location,
259 # we calculate absolute_keyword_location when instantiating the Annotation object for Result
260 _uri => $uri,
261 annotation => $annotation,
26271790228ms $state->{_unknown} ? ( unknown => 1 ) : (),
263 };
264
26571790150ms return 1;
266}
267
268# creates an error object, but also aborts evaluation immediately
269# only this error is returned, because other errors on the stack might not actually be "real"
270# errors (consider if we were in the middle of evaluating a "not" or "if").
271# Therefore this is only appropriate during the evaluation phase, not the traverse phase.
272sub abort ($state, $error_string, @args) {
273 ()= E({ %$state, exception => 1 }, $error_string, @args);
274 croak 'abort() called during traverse' if $state->{traverse};
275 die pop $state->{errors}->@*;
276}
277
27831µs
# spent 4µs within JSON::Schema::Modern::Utilities::assert_keyword_exists which was called: # once (4µ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) {
27910s croak 'assert_keyword_exists called in void context' if not defined wantarray;
28011µs return E($state, '%s keyword is required', $state->{keyword}) if not exists $schema->{$state->{keyword}};
28113µs return 1;
282}
283
284143602.19ms
# spent 44.2ms (16.2+28.0) within JSON::Schema::Modern::Utilities::assert_keyword_type which was called 3590 times, avg 12µs/call: # 1306 times (6.17ms+12.7ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 54 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call # 732 times (3.39ms+6.70ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 203 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 14µs/call # 402 times (2.19ms+1.29ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 50 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call # 275 times (1.03ms+499µ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 (487µs+1.55ms) 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+825µs) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_title at line 38 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 10µs/call # 118 times (545µs+982µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_comment at line 285 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 13µs/call # 87 times (276µs+1.02ms) by JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer at line 318 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 15µs/call # 76 times (291µs+169µs) by JSON::Schema::Modern::Vocabulary::traverse_array_schemas at line 38 of JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call # 69 times (282µs+567µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call # 60 times (225µs+110µ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 (181µs+246µ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 (150µs+340µ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 (72µs+239µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_number at line 313 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 10µs/call # 15 times (79µs+234µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 112 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 21µs/call # 15 times (58µs+185µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 153 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 16µs/call # 14 times (111µs+266µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 27µs/call # 11 times (48µs+28µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 256 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 7µs/call # 6 times (28µs+6µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 61 of JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call # 6 times (11µs+8µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 397 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 3 times (10µs+41µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems at line 206 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 17µs/call # once (9µs+26µs) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm # once (3µs+4µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding at line 39 of JSON/Schema/Modern/Vocabulary/Content.pm # once (1µs+2µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 277 of JSON/Schema/Modern/Vocabulary/Validation.pm
sub assert_keyword_type ($state, $schema, $type) {
2853590776µs croak 'assert_keyword_type called in void context' if not defined wantarray;
28635902.78ms my $value = $schema->{$state->{keyword}};
2873590652µs my $thing = 'value';
288 ($value, $thing) = is_plain_hashref($value) ? ($value->{$state->{_schema_path_suffix}}, 'value at "'.$state->{_schema_path_suffix}.'"')
289 : is_plain_arrayref($value) ? ($value->[$state->{_schema_path_suffix}], 'item '.$state->{_schema_path_suffix})
290 : die 'unknown type'
2913590775µs if exists $state->{_schema_path_suffix};
29235909.95ms359028.0ms return 1 if is_type($type, $value);
# spent 28.0ms making 3590 calls to JSON::Schema::Modern::Utilities::is_type, avg 8µs/call
293 E($state, '%s %s is not a%s %s', $state->{keyword}, $thing, ($type =~ /^[aeiou]/ ? 'n' : ''), $type);
294}
295
29622541µs
# spent 3.24ms (1.15+2.10) within JSON::Schema::Modern::Utilities::assert_pattern which was called 75 times, avg 43µs/call: # 69 times (1.06ms+1.95ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 44µs/call # 6 times (88µs+145µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 401 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 39µs/call
sub assert_pattern ($state, $pattern) {
2977552µs croak 'assert_pattern called in void context' if not defined wantarray;
2987532µs try {
29975330µs local $SIG{__WARN__} = sub { die @_ };
300752.73ms1502.10ms qr/$pattern/;
# spent 1.94ms making 75 calls to JSON::Schema::Modern::Utilities::CORE:regcomp, avg 26µs/call # spent 152µs making 75 calls to JSON::Schema::Modern::Utilities::CORE:qr, avg 2µs/call
301 }
302 catch ($e) { return E($state, $e); };
30375162µs return 1;
304}
305
306# this is only suitable for checking URIs within schemas themselves
3072238310µs
# spent 162ms (10.4+152) within JSON::Schema::Modern::Utilities::assert_uri_reference which was called 746 times, avg 218µs/call: # 732 times (10.2ms+150ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 203 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 218µs/call # 14 times (201µs+2.38ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 184µs/call
sub assert_uri_reference ($state, $schema) {
308746227µs croak 'assert_uri_reference called in void context' if not defined wantarray;
309
310746454µs my $string = $schema->{$state->{keyword}};
311 return E($state, '%s value is not a valid URI reference', $state->{keyword})
312 # see also uri-reference format sub
31374612.7ms5108152ms if fc(Mojo::URL->new($string)->to_unsafe_string) ne fc($string)
# spent 85.8ms making 746 calls to Mojo::URL::new, avg 115µs/call # spent 61.0ms making 746 calls to Mojo::URL::to_unsafe_string, avg 82µs/call # spent 5.14ms making 3616 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 1µs/call
314 or $string =~ /[^[:ascii:]]/
315 or $string =~ /#/
316 and $string !~ m{#$} # empty fragment
317 and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment
318 and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment
319
3207461.46ms return 1;
321}
322
323# this is only suitable for checking URIs within schemas themselves
32418428µs
# spent 6.63ms (613µs+6.02) within JSON::Schema::Modern::Utilities::assert_uri which was called 46 times, avg 144µs/call: # 31 times (375µs+3.79ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 266 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 134µs/call # 15 times (238µs+2.23ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 112 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 164µs/call
sub assert_uri ($state, $schema, $override = undef) {
3254618µs croak 'assert_uri called in void context' if not defined wantarray;
326
3274624µs my $string = $override // $schema->{$state->{keyword}};
3284642µs461.97ms my $uri = Mojo::URL->new($string);
# spent 1.97ms making 46 calls to Mojo::URL::new, avg 43µs/call
329
33046295µs1844.05ms return E($state, '"%s" is not a valid URI', $string)
# spent 3.88ms making 46 calls to Mojo::URL::to_unsafe_string, avg 84µs/call # spent 148µs making 46 calls to Mojo::URL::is_abs, avg 3µs/call # spent 22µs making 92 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 239ns/call
331 # see also uri format sub
332 if fc($uri->to_unsafe_string) ne fc($string)
333 or $string =~ /[^[:ascii:]]/
334 or not $uri->is_abs
335 or $string =~ /#/
336 and $string !~ m{#$} # empty fragment
337 and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment
338 and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment
339
34046142µs return 1;
341}
342
343# produces an annotation whose value is the same as that of the current keyword
3449664215.3ms
# spent 2.39s (146ms+2.24) within JSON::Schema::Modern::Utilities::annotate_self which was called 32214 times, avg 74µs/call: # 32214 times (146ms+2.24s) by JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_title at line 43 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 74µs/call
sub annotate_self ($state, $schema) {
345 A($state, is_ref($schema->{$state->{keyword}}) ? dclone($schema->{$state->{keyword}})
34632214170ms333272.24s : $schema->{$state->{keyword}});
# spent 2.19s making 32214 calls to JSON::Schema::Modern::Utilities::A, avg 68µs/call # spent 55.3ms making 1113 calls to Storable::dclone, avg 50µs/call
347}
348
349sub sprintf_num ($value) {
350 # use original value as stored in the NV, without losing precision
351 ref($value) =~ /^Math::Big(?:Int|Float)$/ ? $value->bstr : sprintf('%s', $value);
352}
353
35416µs1;
355
356130µs1207µs__END__
 
# spent 5.21ms within JSON::Schema::Modern::Utilities::CORE:match which was called 3904 times, avg 1µs/call: # 3616 times (5.14ms+0s) by JSON::Schema::Modern::Utilities::assert_uri_reference at line 313, avg 1µs/call # 109 times (35µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 78, avg 321ns/call # 92 times (22µs+0s) by JSON::Schema::Modern::Utilities::assert_uri at line 330, avg 239ns/call # 87 times (21µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 83, avg 241ns/call
sub JSON::Schema::Modern::Utilities::CORE:match; # opcode
# spent 152µs within JSON::Schema::Modern::Utilities::CORE:qr which was called 75 times, avg 2µs/call: # 75 times (152µs+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 300, avg 2µs/call
sub JSON::Schema::Modern::Utilities::CORE:qr; # opcode
# spent 1.94ms within JSON::Schema::Modern::Utilities::CORE:regcomp which was called 75 times, avg 26µs/call: # 75 times (1.94ms+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 300, avg 26µs/call
sub JSON::Schema::Modern::Utilities::CORE:regcomp; # opcode
# spent 155ms within JSON::Schema::Modern::Utilities::CORE:subst which was called 469020 times, avg 330ns/call: # 469020 times (155ms+0s) by JSON::Schema::Modern::Utilities::jsonp at line 173, avg 330ns/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