← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Thu Dec 15 15:23:56 2022
Reported on Thu Dec 15 15:27:03 2022

Filename/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Utilities.pm
StatementsExecuted 2842898 statements in 2.60s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10944054647ms2.95sJSON::Schema::Modern::Utilities::::canonical_uriJSON::Schema::Modern::Utilities::canonical_uri
104485124499ms561msJSON::Schema::Modern::Utilities::::jsonpJSON::Schema::Modern::Utilities::jsonp
16016454348ms496msJSON::Schema::Modern::Utilities::::get_typeJSON::Schema::Modern::Utilities::get_type
7108074223ms940msJSON::Schema::Modern::Utilities::::AJSON::Schema::Modern::Utilities::A
73239235201ms281msJSON::Schema::Modern::Utilities::::is_typeJSON::Schema::Modern::Utilities::is_type
3182811118ms187msJSON::Schema::Modern::Utilities::::annotate_selfJSON::Schema::Modern::Utilities::annotate_self
419652110ms978msJSON::Schema::Modern::Utilities::::EJSON::Schema::Modern::Utilities::E
156373280.1ms289msJSON::Schema::Modern::Utilities::::is_equalJSON::Schema::Modern::Utilities::is_equal
2353721161.9ms61.9msJSON::Schema::Modern::Utilities::::CORE:substJSON::Schema::Modern::Utilities::CORE:subst (opcode)
353924832.6ms55.5msJSON::Schema::Modern::Utilities::::assert_keyword_typeJSON::Schema::Modern::Utilities::assert_keyword_type
37421128.2ms28.2msJSON::Schema::Modern::Utilities::::local_annotationsJSON::Schema::Modern::Utilities::local_annotations
6304115.9ms124msJSON::Schema::Modern::Utilities::::is_elements_uniqueJSON::Schema::Modern::Utilities::is_elements_unique
740219.80ms181msJSON::Schema::Modern::Utilities::::assert_uri_referenceJSON::Schema::Modern::Utilities::assert_uri_reference
3874414.86ms4.86msJSON::Schema::Modern::Utilities::::CORE:matchJSON::Schema::Modern::Utilities::CORE:match (opcode)
75111.81ms1.81msJSON::Schema::Modern::Utilities::::CORE:regcompJSON::Schema::Modern::Utilities::CORE:regcomp (opcode)
7522945µs2.86msJSON::Schema::Modern::Utilities::::assert_patternJSON::Schema::Modern::Utilities::assert_pattern
4621483µs5.35msJSON::Schema::Modern::Utilities::::assert_uriJSON::Schema::Modern::Utilities::assert_uri
751198µs98µsJSON::Schema::Modern::Utilities::::CORE:qrJSON::Schema::Modern::Utilities::CORE:qr (opcode)
11129µs32µsJSON::Schema::Modern::::BEGIN@1.159 JSON::Schema::Modern::BEGIN@1.159
11119µs1.13msJSON::Schema::Modern::Utilities::::BEGIN@10JSON::Schema::Modern::Utilities::BEGIN@10
11117µs59µsJSON::Schema::Modern::Utilities::::BEGIN@18JSON::Schema::Modern::Utilities::BEGIN@18
11116µs16µsJSON::Schema::Modern::Utilities::::BEGIN@23JSON::Schema::Modern::Utilities::BEGIN@23
11113µs42µsJSON::Schema::Modern::Utilities::::BEGIN@12JSON::Schema::Modern::Utilities::BEGIN@12
11113µs46µsJSON::Schema::Modern::Utilities::::BEGIN@19JSON::Schema::Modern::Utilities::BEGIN@19
11113µs19µsJSON::Schema::Modern::Utilities::::BEGIN@27JSON::Schema::Modern::Utilities::BEGIN@27
11111µs11µsJSON::Schema::Modern::Utilities::::BEGIN@24JSON::Schema::Modern::Utilities::BEGIN@24
11110µs27µsJSON::Schema::Modern::Utilities::::BEGIN@13JSON::Schema::Modern::Utilities::BEGIN@13
11110µs55µsJSON::Schema::Modern::Utilities::::BEGIN@17JSON::Schema::Modern::Utilities::BEGIN@17
11110µs56µsJSON::Schema::Modern::Utilities::::BEGIN@53JSON::Schema::Modern::Utilities::BEGIN@53
1119µs9µsJSON::Schema::Modern::Utilities::::BEGIN@9JSON::Schema::Modern::Utilities::BEGIN@9
1117µs113µsJSON::Schema::Modern::Utilities::::BEGIN@11JSON::Schema::Modern::Utilities::BEGIN@11
1117µs15µsJSON::Schema::Modern::Utilities::::BEGIN@14JSON::Schema::Modern::Utilities::BEGIN@14
1117µs18µsJSON::Schema::Modern::Utilities::::BEGIN@15JSON::Schema::Modern::Utilities::BEGIN@15
1116µs32µsJSON::Schema::Modern::::BEGIN@2.160 JSON::Schema::Modern::BEGIN@2.160
1116µs8µsJSON::Schema::Modern::Utilities::::BEGIN@16JSON::Schema::Modern::Utilities::BEGIN@16
1116µs25µsJSON::Schema::Modern::Utilities::::BEGIN@22JSON::Schema::Modern::Utilities::BEGIN@22
1116µs140µsJSON::Schema::Modern::Utilities::::BEGIN@25JSON::Schema::Modern::Utilities::BEGIN@25
1115µs15µsJSON::Schema::Modern::Utilities::::BEGIN@20JSON::Schema::Modern::Utilities::BEGIN@20
1115µs14µsJSON::Schema::Modern::Utilities::::BEGIN@21JSON::Schema::Modern::Utilities::BEGIN@21
1115µs5µsJSON::Schema::Modern::Utilities::::BEGIN@52JSON::Schema::Modern::Utilities::BEGIN@52
1114µs4µsJSON::Schema::Modern::Utilities::::assert_keyword_existsJSON::Schema::Modern::Utilities::assert_keyword_exists
2210s0sJSON::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
1230µs235µs
# spent 32µs (29+3) within JSON::Schema::Modern::BEGIN@1.159 which was called: # once (29µs+3µs) by JSON::Schema::Modern::BEGIN@36 at line 1
use strict;
# spent 32µs making 1 call to JSON::Schema::Modern::BEGIN@1.159 # spent 3µs making 1 call to strict::import
2232µs258µs
# spent 32µs (6+26) within JSON::Schema::Modern::BEGIN@2.160 which was called: # once (6µs+26µs) by JSON::Schema::Modern::BEGIN@36 at line 2
use warnings;
# spent 32µs making 1 call to JSON::Schema::Modern::BEGIN@2.160 # spent 26µ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.559';
8
9227µs19µs
# spent 9µs within JSON::Schema::Modern::Utilities::BEGIN@9 which was called: # once (9µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 9
use 5.020;
# spent 9µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@9
10358µs32.23ms
# spent 1.13ms (19µs+1.11) within JSON::Schema::Modern::Utilities::BEGIN@10 which was called: # once (19µs+1.11ms) by JSON::Schema::Modern::BEGIN@36 at line 10
use strictures 2;
# spent 1.13ms making 1 call to JSON::Schema::Modern::Utilities::BEGIN@10 # spent 1.09ms making 1 call to strictures::import # spent 17µs making 1 call to strictures::VERSION
11240µs2219µs
# spent 113µs (7+106) within JSON::Schema::Modern::Utilities::BEGIN@11 which was called: # once (7µs+106µs) by JSON::Schema::Modern::BEGIN@36 at line 11
use experimental qw(signatures postderef);
# spent 113µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@11 # spent 106µs making 1 call to experimental::import
12227µs246µs
# spent 42µs (13+29) within JSON::Schema::Modern::Utilities::BEGIN@12 which was called: # once (13µs+29µs) by JSON::Schema::Modern::BEGIN@36 at line 12
use if "$]" >= 5.022, experimental => 're_strict';
# spent 42µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@12 # spent 4µs making 1 call to if::import
13219µs229µs
# spent 27µs (10+17) within JSON::Schema::Modern::Utilities::BEGIN@13 which was called: # once (10µs+17µs) by JSON::Schema::Modern::BEGIN@36 at line 13
no if "$]" >= 5.031009, feature => 'indirect';
# spent 27µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@13 # spent 2µs making 1 call to if::unimport
14222µs216µs
# spent 15µs (7+8) within JSON::Schema::Modern::Utilities::BEGIN@14 which was called: # once (7µs+8µs) by JSON::Schema::Modern::BEGIN@36 at line 14
no if "$]" >= 5.033001, feature => 'multidimensional';
# spent 15µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@14 # spent 1µs making 1 call to if::unimport
15218µs220µs
# spent 18µs (7+11) within JSON::Schema::Modern::Utilities::BEGIN@15 which was called: # once (7µs+11µ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 2µs making 1 call to if::unimport
16219µs210µs
# spent 8µs (6+2) within JSON::Schema::Modern::Utilities::BEGIN@16 which was called: # once (6µs+2µs) by JSON::Schema::Modern::BEGIN@36 at line 16
use B;
# spent 8µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@16 # spent 2µs making 1 call to B::import
17251µs2100µs
# spent 55µs (10+45) within JSON::Schema::Modern::Utilities::BEGIN@17 which was called: # once (10µs+45µs) by JSON::Schema::Modern::BEGIN@36 at line 17
use Carp 'croak';
# spent 55µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@17 # spent 45µs making 1 call to Exporter::import
18348µs3101µs
# spent 59µs (17+42) within JSON::Schema::Modern::Utilities::BEGIN@18 which was called: # once (17µs+42µs) by JSON::Schema::Modern::BEGIN@36 at line 18
use JSON::MaybeXS 1.004004 'is_bool';
# spent 59µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@18 # spent 32µs making 1 call to Exporter::import # spent 10µs making 1 call to UNIVERSAL::VERSION
19331µs379µs
# spent 46µs (13+33) within JSON::Schema::Modern::Utilities::BEGIN@19 which was called: # once (13µs+33µ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 46µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@19 # spent 29µs making 1 call to Exporter::import # spent 4µs making 1 call to UNIVERSAL::VERSION
20214µs225µs
# spent 15µs (5+10) within JSON::Schema::Modern::Utilities::BEGIN@20 which was called: # once (5µs+10µs) by JSON::Schema::Modern::BEGIN@36 at line 20
use Scalar::Util 'blessed';
# spent 15µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@20 # spent 10µs making 1 call to Exporter::import
21214µs223µs
# spent 14µs (5+9) within JSON::Schema::Modern::Utilities::BEGIN@21 which was called: # once (5µs+9µs) by JSON::Schema::Modern::BEGIN@36 at line 21
use Storable 'dclone';
# spent 14µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@21 # spent 9µs making 1 call to Exporter::import
22216µs244µs
# spent 25µs (6+19) within JSON::Schema::Modern::Utilities::BEGIN@22 which was called: # once (6µs+19µs) by JSON::Schema::Modern::BEGIN@36 at line 22
use Feature::Compat::Try;
# spent 25µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@22 # spent 19µs making 1 call to Feature::Compat::Try::import
23227µs216µs
# spent 16µs within JSON::Schema::Modern::Utilities::BEGIN@23 which was called: # once (16µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 23
use JSON::Schema::Modern::Error;
# spent 16µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@23 # spent 0s making 1 call to JSON::Schema::Modern::Utilities::__ANON__
24219µs211µs
# spent 11µs within JSON::Schema::Modern::Utilities::BEGIN@24 which was called: # once (11µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 24
use JSON::Schema::Modern::Annotation;
# spent 11µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@24 # spent 0s making 1 call to JSON::Schema::Modern::Utilities::__ANON__
25235µs2274µs
# spent 140µs (6+134) within JSON::Schema::Modern::Utilities::BEGIN@25 which was called: # once (6µs+134µs) by JSON::Schema::Modern::BEGIN@36 at line 25
use namespace::clean;
# spent 140µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@25 # spent 134µs making 1 call to namespace::clean::import
26
27281µs225µs
# spent 19µs (13+6) within JSON::Schema::Modern::Utilities::BEGIN@27 which was called: # once (13µs+6µs) by JSON::Schema::Modern::BEGIN@36 at line 27
use Exporter 'import';
# spent 19µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@27 # spent 6µs making 1 call to Exporter::import
28
2914µ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
52233µ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.26ms4102µs
# spent 56µs (10+46) within JSON::Schema::Modern::Utilities::BEGIN@53 which was called: # once (10µs+46µs) by JSON::Schema::Modern::BEGIN@36 at line 53
use constant { true => JSON::PP::true, false => JSON::PP::false };
# spent 56µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@53 # spent 43µs making 1 call to constant::import # spent 2µs making 1 call to JSON::PP::true # spent 1µs making 1 call to JSON::PP::false
54
5521971739.6ms
# spent 281ms (201+79.7) within JSON::Schema::Modern::Utilities::is_type which was called 73239 times, avg 4µs/call: # 32177 times (81.7ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 371 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 10976 times (31.4ms+47.7ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 379 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call # 4781 times (10.7ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 269 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call # 3742 times (6.18ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 107 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 2µs/call # 3539 times (16.8ms+6.04ms) by JSON::Schema::Modern::Utilities::assert_keyword_type at line 292, avg 6µs/call # 3368 times (9.53ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 414 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 1816 times (5.21ms+7.65ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 458 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call # 1799 times (4.74ms+9.94ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 421 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call # 1739 times (5.39ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 301 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call # 1597 times (4.39ms+5.59ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 307 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 6µs/call # 1594 times (10.7ms+1.72ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 182 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 8µs/call # 1388 times (1.90ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 211 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 1µs/call # 1232 times (2.94ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems at line 200 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call # 971 times (2.28ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 448 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call # 747 times (2.72ms+512µs) by List::Util::any at line 263 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 4µs/call # 627 times (1.02ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 484 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call # 485 times (829µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties at line 254 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call # 304 times (429µs+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 161 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 1µs/call # 261 times (1.55ms+462µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 183 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 8µs/call # 79 times (793µs+85µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum at line 146 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 11µs/call # 15 times (30µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_maxProperties at line 245 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call # once (5µs+1000ns) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 286 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm # once (3µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 282 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm
sub is_type ($type, $value) {
567323918.2ms if ($type eq 'null') {
57 return !(defined $value);
58 }
597323964.5ms1635872.1ms if ($type eq 'boolean') {
# spent 72.1ms making 16358 calls to JSON::MaybeXS::is_bool, avg 4µs/call
60 return is_bool($value);
61 }
6256881111ms if ($type eq 'object') {
63 return is_plain_hashref($value);
64 }
65999011.8ms if ($type eq 'array') {
66 return is_plain_arrayref($value);
67 }
68
6952271.36ms if ($type eq 'string' or $type eq 'number' or $type eq 'integer') {
705227645µs return 0 if not defined $value;
71522721.5ms104547.56ms my $flags = B::svref_2object(\$value)->FLAGS;
# spent 5.59ms making 5227 calls to B::svref_2object, avg 1µs/call # spent 1.97ms making 5227 calls to B::SV::FLAGS, avg 377ns/call
72
7352279.93ms if ($type eq 'string') {
74 return !is_ref($value) && $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK));
75 }
76
77196106µs if ($type eq 'number') {
78109495µ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
828727µs if ($type eq 'integer') {
8387340µs8722µs return ref($value) =~ /^Math::Big(?:Int|Float)$/ && $value->is_int
# spent 22µs making 87 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 253ns/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
9532032844.8ms
# spent 496ms (348+149) within JSON::Schema::Modern::Utilities::get_type which was called 160164 times, avg 3µs/call: # 90777 times (130ms+0s) by JSON::Schema::Modern::_eval_subschema at line 539 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 1µs/call # 35279 times (82.7ms+67.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 62 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 4µs/call # 31274 times (131ms+78.2ms) by JSON::Schema::Modern::Utilities::is_equal at line 120, avg 7µs/call # 2833 times (4.41ms+2.78ms) by JSON::Schema::Modern::_traverse_subschema at line 463 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 3µs/call # once (1µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 89 of JSON/Schema/Modern/Document/OpenAPI.pm
sub get_type ($value) {
96160164214ms return 'object' if is_plain_hashref($value);
974091143.8ms40911111ms return 'boolean' if is_bool($value);
# spent 111ms making 40911 calls to JSON::MaybeXS::is_bool, avg 3µs/call
98361614.85ms return 'null' if not defined $value;
99361616.55ms return 'array' if is_plain_arrayref($value);
100
101350653.90ms 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
10535065116ms7013038.1ms my $flags = B::svref_2object(\$value)->FLAGS;
# spent 27.0ms making 35065 calls to B::svref_2object, avg 770ns/call # spent 11.1ms making 35065 calls to B::SV::FLAGS, avg 317ns/call
1063506548.9ms return 'string' if $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK));
107107299µ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
117625489.87ms
# spent 289ms (80.1+209) within JSON::Schema::Modern::Utilities::is_equal which was called 15637 times, avg 19µs/call: # 7456 times (39.0ms+105ms) by List::Util::any at line 85 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 19µs/call # 6978 times (29.7ms+78.4ms) by JSON::Schema::Modern::Utilities::is_elements_unique at line 160, avg 15µs/call # 1203 times (11.3ms+26.1ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 95 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 31µs/call
sub is_equal ($x, $y, $state = undef) {
118156375.02ms $state->{path} //= '';
119
1201563720.8ms31274209ms my @types = map get_type($_), $x, $y;
# spent 209ms making 31274 calls to JSON::Schema::Modern::Utilities::get_type, avg 7µs/call
121
122156373.31ms if ($state->{scalarref_booleans}) {
1236978690µs ($x, $types[0]) = (0+!!$$x, 'boolean') if $types[0] eq 'reference to SCALAR';
1246978698µs ($y, $types[1]) = (0+!!$$y, 'boolean') if $types[1] eq 'reference to SCALAR';
125 }
126
127156373.45ms return 0 if $types[0] ne $types[1];
128151752.07ms return 1 if $types[0] eq 'null';
1291517523.2ms return $x eq $y if $types[0] eq 'string';
1301731.12ms346450µs return $x == $y if grep $types[0] eq $_, qw(boolean number integer);
# spent 450µs making 346 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:8], 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
1571890357µs
# spent 124ms (15.9+108) within JSON::Schema::Modern::Utilities::is_elements_unique which was called 630 times, avg 197µs/call: # 283 times (8.17ms+55.0ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 213 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 223µs/call # 270 times (7.17ms+51.1ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 264 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 216µs/call # 76 times (583µs+2.07ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 51 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 35µs/call # once (3µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 290 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm
sub is_elements_unique ($array, $equal_indices = undef) {
158630952µs foreach my $idx0 (0 .. $array->$#*-1) {
15910971.08ms foreach my $idx1 ($idx0+1 .. $array->$#*) {
16069788.30ms6978108ms if (is_equal($array->[$idx0], $array->[$idx1], { scalarref_booleans => 1 })) {
# spent 108ms making 6978 calls to JSON::Schema::Modern::Utilities::is_equal, avg 15µs/call
161 push @$equal_indices, $idx0, $idx1 if defined $equal_indices;
162 return 0;
163 }
164 }
165 }
1666301.27ms 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 561ms (499+61.9) within JSON::Schema::Modern::Utilities::jsonp which was called 104485 times, avg 5µs/call: # 41337 times (221ms+24.2ms) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 95 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call # 21668 times (114ms+11.9ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 385 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 6µs/call # 17923 times (75.8ms+11.3ms) by JSON::Schema::Modern::Utilities::canonical_uri at line 193, avg 5µs/call # 13727 times (40.9ms+4.17ms) by JSON::Schema::Modern::Utilities::A at line 253, avg 3µs/call # 4196 times (13.8ms+1.54ms) by JSON::Schema::Modern::Utilities::E at line 216, avg 4µs/call # 1816 times (10.4ms+3.15ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 464 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call # 1476 times (7.44ms+2.00ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 427 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 6µs/call # 1334 times (9.12ms+1.34ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 55 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call # 712 times (4.72ms+1.95ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 488 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call # 289 times (1.72ms+247µs) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 167 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call # 6 times (41µs+6µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 64 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call # once (7µs+1000ns) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 138 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm
sub jsonp {
173104485643ms23537261.9ms return join('/', shift, map s/~/~0/gr =~ s!/!~1!gr, map +(is_plain_arrayref($_) ? @$_ : $_), grep defined, @_);
# spent 61.9ms making 235372 calls to JSON::Schema::Modern::Utilities::CORE:subst, avg 263ns/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
18374841.21ms
# spent 28.2ms within JSON::Schema::Modern::Utilities::local_annotations which was called 3742 times, avg 8µs/call: # 3742 times (28.2ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 110 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 8µs/call
sub local_annotations ($state) {
184374231.8ms 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}
18932832051.3ms
# spent 2.95s (647ms+2.31) within JSON::Schema::Modern::Utilities::canonical_uri which was called 109440 times, avg 27µs/call: # 90777 times (453ms+1.61s) by JSON::Schema::Modern::_eval_subschema at line 549 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm, avg 23µs/call # 13727 times (148ms+524ms) by JSON::Schema::Modern::Utilities::A at line 250, avg 49µs/call # 4196 times (35.6ms+144ms) by JSON::Schema::Modern::Utilities::E at line 213, avg 43µs/call # 725 times (9.82ms+29.4ms) by JSON::Schema::Modern::Document::OpenAPI::_traverse_schema at line 218 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 54µs/call # 15 times (132µs+192µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 168 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 22µs/call
sub canonical_uri ($state, @extra_path) {
19010944096.5ms return $state->{initial_schema_uri} if not @extra_path and not length($state->{schema_path});
1916809118.5ms splice(@extra_path, -1, 1, $extra_path[-1]->@*) if @extra_path and is_plain_arrayref($extra_path[-1]);
1926809176.7ms680912.10s my $uri = $state->{initial_schema_uri}->clone;
# spent 2.10s making 68091 calls to Mojo::URL::clone, avg 31µs/call
19368091119ms86014147ms my $fragment = ($uri->fragment//'').(@extra_path ? jsonp($state->{schema_path}, @extra_path) : $state->{schema_path});
# spent 87.1ms making 17923 calls to JSON::Schema::Modern::Utilities::jsonp, avg 5µs/call # spent 59.7ms making 68091 calls to Mojo::URL::fragment, avg 877ns/call
1946809117.2ms undef $fragment if not length($fragment);
1956809161.3ms6809163.8ms $uri->fragment($fragment);
# spent 63.8ms making 68091 calls to Mojo::URL::fragment, avg 937ns/call
19668091112ms $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
208167844.30ms
# spent 978ms (110+868) within JSON::Schema::Modern::Utilities::E which was called 4196 times, avg 233µs/call: # 1435 times (37.4ms+305ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 273 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 239µs/call # 1105 times (31.4ms+241ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 73 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 247µs/call # 795 times (27.0ms+164ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 97 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 240µs/call # 795 times (12.7ms+143ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 398 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 196µs/call # 66 times (1.74ms+14.8ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum at line 88 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 250µs/call
sub E ($state, $error_string, @args) {
20941961.03ms 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})
213419620.8ms8392310ms ->to_abs($state->{effective_base_uri});
# spent 180ms making 4196 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 43µs/call # spent 130ms making 4196 calls to Mojo::URL::to_abs, avg 31µs/call
214
215 my $keyword_location = $state->{traversed_schema_path}
21641967.06ms419615.4ms .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix});
# spent 15.4ms making 4196 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call
217
218419613.2ms8392329ms undef $uri if $uri eq '' and $keyword_location eq ''
# spent 327ms making 4196 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 78µs/call # spent 2.19ms making 4196 calls to Mojo::URL::fragment, avg 521ns/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,
227419625.9ms4196213ms $state->{exception} ? ( exception => $state->{exception} ) : (),
# spent 213ms making 4196 calls to JSON::Schema::Modern::Error::new, avg 51µs/call
228 );
229
230419612.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
24321324035.0ms
# spent 940ms (223+717) within JSON::Schema::Modern::Utilities::A which was called 71080 times, avg 13µs/call: # 31828 times (41.3ms+132µs) by JSON::Schema::Modern::Utilities::annotate_self at line 346, avg 1µs/call # 28317 times (108ms+374ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 397 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 17µs/call # 3742 times (27.5ms+170ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 139 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 53µs/call # 3368 times (38.3ms+173ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 440 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 63µs/call # 2220 times (5.28ms+0s) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 180 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 2µs/call # 971 times (1.43ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 476 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 1µs/call # 634 times (1.31ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 328 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call
sub A ($state, $annotation) {
24471080116ms 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}),
2501372730.9ms13727672ms $state->{effective_base_uri} ];
# spent 672ms making 13727 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 49µs/call
251
252 my $keyword_location = $state->{traversed_schema_path}
2531372719.8ms1372745.1ms .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix});
# spent 45.1ms making 13727 calls to JSON::Schema::Modern::Utilities::jsonp, avg 3µ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,
2621372738.5ms $state->{_unknown} ? ( unknown => 1 ) : (),
263 };
264
2651372721.5ms 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) {
27911µs 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}};
28112µs return 1;
282}
283
284141561.99ms
# spent 55.5ms (32.6+22.9) within JSON::Schema::Modern::Utilities::assert_keyword_type which was called 3539 times, avg 16µs/call: # 1296 times (23.1ms+10.3ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 54 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 26µs/call # 726 times (3.03ms+5.57ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 209 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 12µs/call # 397 times (2.13ms+856µs) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 50 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call # 270 times (1.02ms+381µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 261 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call # 136 times (450µs+1.36ms) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_deprecated at line 55 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 13µs/call # 129 times (435µs+754µs) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_title at line 38 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 9µs/call # 112 times (480µs+840µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_comment at line 291 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 12µs/call # 87 times (258µs+732µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer at line 318 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 11µs/call # 74 times (339µs+140µs) by JSON::Schema::Modern::Vocabulary::traverse_array_schemas at line 38 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call # 69 times (280µs+519µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call # 59 times (217µs+108µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum at line 78 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 6µs/call # 50 times (180µs+231µs) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_traverse_keyword_format at line 35 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 8µs/call # 31 times (118µs+266µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 271 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 12µs/call # 30 times (85µs+222µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_number at line 313 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 10µs/call # 15 times (70µs+119µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 118 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 13µs/call # 15 times (53µs+114µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 159 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 11µs/call # 14 times (112µs+223µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 24µs/call # 11 times (89µs+16µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 262 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 10µs/call # 6 times (22µs+10µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 403 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 5µs/call # 6 times (23µs+4µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 61 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary.pm, avg 4µs/call # 3 times (13µs+47µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems at line 206 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 20µs/call # once (37µs+6µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding at line 39 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Content.pm # once (4µs+20µs) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm # once (1µs+3µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 277 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm
sub assert_keyword_type ($state, $schema, $type) {
2853539566µs croak 'assert_keyword_type called in void context' if not defined wantarray;
28635392.61ms my $value = $schema->{$state->{keyword}};
2873539673µ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'
2913539640µs if exists $state->{_schema_path_suffix};
292353926.1ms353922.9ms return 1 if is_type($type, $value);
# spent 22.9ms making 3539 calls to JSON::Schema::Modern::Utilities::is_type, avg 6µs/call
293 E($state, '%s %s is not a%s %s', $state->{keyword}, $thing, ($type =~ /^[aeiou]/ ? 'n' : ''), $type);
294}
295
29622540µs
# spent 2.86ms (945µs+1.91) within JSON::Schema::Modern::Utilities::assert_pattern which was called 75 times, avg 38µs/call: # 69 times (849µs+1.72ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Validation.pm, avg 37µs/call # 6 times (96µs+191µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 407 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 48µs/call
sub assert_pattern ($state, $pattern) {
2977518µs croak 'assert_pattern called in void context' if not defined wantarray;
2987527µs try {
29975285µs local $SIG{__WARN__} = sub { die @_ };
300752.42ms1501.91ms qr/$pattern/;
# spent 1.81ms making 75 calls to JSON::Schema::Modern::Utilities::CORE:regcomp, avg 24µs/call # spent 98µs making 75 calls to JSON::Schema::Modern::Utilities::CORE:qr, avg 1µs/call
301 }
302 catch ($e) { return E($state, $e); };
30375126µs return 1;
304}
305
306# this is only suitable for checking URIs within schemas themselves
3072220298µs
# spent 181ms (9.80+171) within JSON::Schema::Modern::Utilities::assert_uri_reference which was called 740 times, avg 244µs/call: # 726 times (9.57ms+150ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 209 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 219µs/call # 14 times (231µs+21.3ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 1.54ms/call
sub assert_uri_reference ($state, $schema) {
308740197µs croak 'assert_uri_reference called in void context' if not defined wantarray;
309
310740413µ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
31374011.9ms5066171ms if fc(Mojo::URL->new($string)->to_unsafe_string) ne fc($string)
# spent 94.7ms making 740 calls to Mojo::URL::new, avg 128µs/call # spent 71.3ms making 740 calls to Mojo::URL::to_unsafe_string, avg 96µs/call # spent 4.75ms making 3586 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
3207401.40ms return 1;
321}
322
323# this is only suitable for checking URIs within schemas themselves
32418427µs
# spent 5.35ms (483µs+4.86) within JSON::Schema::Modern::Utilities::assert_uri which was called 46 times, avg 116µs/call: # 31 times (281µs+3.16ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 272 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 111µs/call # 15 times (202µs+1.70ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 118 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/Core.pm, avg 127µs/call
sub assert_uri ($state, $schema, $override = undef) {
325466µs croak 'assert_uri called in void context' if not defined wantarray;
326
3274623µs my $string = $override // $schema->{$state->{keyword}};
3284644µs461.55ms my $uri = Mojo::URL->new($string);
# spent 1.55ms making 46 calls to Mojo::URL::new, avg 34µs/call
329
33046216µs1843.31ms return E($state, '"%s" is not a valid URI', $string)
# spent 3.16ms making 46 calls to Mojo::URL::to_unsafe_string, avg 69µs/call # spent 100µs making 46 calls to Mojo::URL::is_abs, avg 2µs/call # spent 56µs making 92 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 609ns/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
34046166µs return 1;
341}
342
343# produces an annotation whose value is the same as that of the current keyword
3449548412.1ms
# spent 187ms (118+69.4) within JSON::Schema::Modern::Utilities::annotate_self which was called 31828 times, avg 6µs/call: # 31828 times (118ms+69.4ms) by JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_title at line 43 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 6µs/call
sub annotate_self ($state, $schema) {
345 A($state, is_ref($schema->{$state->{keyword}}) ? dclone($schema->{$state->{keyword}})
34631828116ms3291569.4ms : $schema->{$state->{keyword}});
# spent 41.5ms making 31828 calls to JSON::Schema::Modern::Utilities::A, avg 1µs/call # spent 28.0ms making 1087 calls to Storable::dclone, avg 26µ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
35418µs1;
355185µs1343µs__END__
 
# spent 4.86ms within JSON::Schema::Modern::Utilities::CORE:match which was called 3874 times, avg 1µs/call: # 3586 times (4.75ms+0s) by JSON::Schema::Modern::Utilities::assert_uri_reference at line 313, avg 1µs/call # 109 times (29µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 78, avg 266ns/call # 92 times (56µs+0s) by JSON::Schema::Modern::Utilities::assert_uri at line 330, avg 609ns/call # 87 times (22µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 83, avg 253ns/call
sub JSON::Schema::Modern::Utilities::CORE:match; # opcode
# spent 98µs within JSON::Schema::Modern::Utilities::CORE:qr which was called 75 times, avg 1µs/call: # 75 times (98µs+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 300, avg 1µs/call
sub JSON::Schema::Modern::Utilities::CORE:qr; # opcode
# spent 1.81ms within JSON::Schema::Modern::Utilities::CORE:regcomp which was called 75 times, avg 24µs/call: # 75 times (1.81ms+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 300, avg 24µs/call
sub JSON::Schema::Modern::Utilities::CORE:regcomp; # opcode
# spent 61.9ms within JSON::Schema::Modern::Utilities::CORE:subst which was called 235372 times, avg 263ns/call: # 235372 times (61.9ms+0s) by JSON::Schema::Modern::Utilities::jsonp at line 173, avg 263ns/call
sub JSON::Schema::Modern::Utilities::CORE:subst; # opcode
# spent 0s within JSON::Schema::Modern::Utilities::__ANON__ which was called 2 times, avg 0s/call: # once (0s+0s) by JSON::Schema::Modern::Utilities::BEGIN@24 at line 24 # once (0s+0s) by JSON::Schema::Modern::Utilities::BEGIN@23 at line 23
sub JSON::Schema::Modern::Utilities::__ANON__; # xsub