Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Utilities.pm |
Statements | Executed 3856150 statements in 5.77s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
71792 | 8 | 5 | 1.64s | 19.7s | A | JSON::Schema::Modern::Utilities::
168344 | 5 | 4 | 1.46s | 6.96s | canonical_uri | JSON::Schema::Modern::Utilities::
221215 | 12 | 4 | 1.24s | 1.41s | jsonp | JSON::Schema::Modern::Utilities::
3747 | 1 | 1 | 575ms | 886ms | local_annotations | JSON::Schema::Modern::Utilities::
161999 | 5 | 4 | 453ms | 634ms | get_type | JSON::Schema::Modern::Utilities::
72310 | 23 | 5 | 274ms | 365ms | is_type | JSON::Schema::Modern::Utilities::
32214 | 1 | 1 | 212ms | 8.95s | annotate_self | JSON::Schema::Modern::Utilities::
469020 | 1 | 1 | 169ms | 169ms | CORE:subst (opcode) | JSON::Schema::Modern::Utilities::
4217 | 5 | 2 | 117ms | 1.17s | E | JSON::Schema::Modern::Utilities::
15946 | 3 | 2 | 97.0ms | 373ms | is_equal | JSON::Schema::Modern::Utilities::
640 | 4 | 1 | 20.9ms | 163ms | is_elements_unique | JSON::Schema::Modern::Utilities::
3590 | 24 | 8 | 19.3ms | 51.3ms | assert_keyword_type | JSON::Schema::Modern::Utilities::
746 | 2 | 1 | 12.9ms | 195ms | assert_uri_reference | JSON::Schema::Modern::Utilities::
3904 | 4 | 1 | 5.82ms | 5.82ms | CORE:match (opcode) | JSON::Schema::Modern::Utilities::
75 | 1 | 1 | 2.16ms | 2.16ms | CORE:regcomp (opcode) | JSON::Schema::Modern::Utilities::
75 | 2 | 2 | 1.30ms | 3.64ms | assert_pattern | JSON::Schema::Modern::Utilities::
46 | 2 | 1 | 786µs | 7.97ms | assert_uri | JSON::Schema::Modern::Utilities::
75 | 1 | 1 | 183µs | 183µs | CORE:qr (opcode) | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 103µs | 1.27ms | BEGIN@10 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 54µs | 59µs | BEGIN@1.158 | JSON::Schema::Modern::
1 | 1 | 1 | 28µs | 29µs | BEGIN@23 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 21µs | 91µs | BEGIN@53 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 18µs | 80µs | BEGIN@2.159 | JSON::Schema::Modern::
1 | 1 | 1 | 17µs | 67µs | BEGIN@18 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 16µs | 48µs | BEGIN@12 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 16µs | 33µs | BEGIN@14 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 15µs | 16µs | BEGIN@24 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 15µs | 24µs | BEGIN@27 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 14µs | 30µs | BEGIN@13 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 12µs | 150µs | BEGIN@11 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 12µs | 29µs | BEGIN@15 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 12µs | 42µs | BEGIN@19 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 12µs | 12µs | BEGIN@9 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 10µs | 24µs | BEGIN@20 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 10µs | 10µs | BEGIN@52 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 8µs | 10µs | BEGIN@16 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 8µs | 36µs | BEGIN@22 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 8µs | 444µs | BEGIN@25 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 7µs | 43µs | BEGIN@17 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 7µs | 23µs | BEGIN@21 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 5µs | 5µs | assert_keyword_exists | JSON::Schema::Modern::Utilities::
2 | 2 | 1 | 2µs | 2µs | __ANON__ (xsub) | JSON::Schema::Modern::Utilities::
0 | 0 | 0 | 0s | 0s | __ANON__[:298] | JSON::Schema::Modern::Utilities::
0 | 0 | 0 | 0s | 0s | abort | JSON::Schema::Modern::Utilities::
0 | 0 | 0 | 0s | 0s | sprintf_num | JSON::Schema::Modern::Utilities::
0 | 0 | 0 | 0s | 0s | unjsonp | JSON::Schema::Modern::Utilities::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 66µs | 2 | 64µs | # spent 59µs (54+5) within JSON::Schema::Modern::BEGIN@1.158 which was called:
# once (54µs+5µs) by JSON::Schema::Modern::BEGIN@36 at line 1 # spent 59µs making 1 call to JSON::Schema::Modern::BEGIN@1.158
# spent 5µs making 1 call to strict::import |
2 | 2 | 72µs | 2 | 142µs | # spent 80µs (18+62) within JSON::Schema::Modern::BEGIN@2.159 which was called:
# once (18µs+62µs) by JSON::Schema::Modern::BEGIN@36 at line 2 # spent 80µs making 1 call to JSON::Schema::Modern::BEGIN@2.159
# spent 62µs making 1 call to warnings::import |
3 | package 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 | |||||
7 | 1 | 1µs | our $VERSION = '0.556'; | ||
8 | |||||
9 | 2 | 98µs | 1 | 12µs | # spent 12µs within JSON::Schema::Modern::Utilities::BEGIN@9 which was called:
# once (12µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 9 # spent 12µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@9 |
10 | 3 | 134µs | 3 | 2.44ms | # spent 1.27ms (103µs+1.17) within JSON::Schema::Modern::Utilities::BEGIN@10 which was called:
# once (103µs+1.17ms) by JSON::Schema::Modern::BEGIN@36 at line 10 # spent 1.27ms making 1 call to JSON::Schema::Modern::Utilities::BEGIN@10
# spent 1.14ms making 1 call to strictures::import
# spent 32µs making 1 call to strictures::VERSION |
11 | 2 | 51µs | 2 | 288µs | # spent 150µs (12+138) within JSON::Schema::Modern::Utilities::BEGIN@11 which was called:
# once (12µs+138µs) by JSON::Schema::Modern::BEGIN@36 at line 11 # spent 150µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@11
# spent 138µs making 1 call to experimental::import |
12 | 2 | 37µs | 2 | 52µs | # spent 48µs (16+32) within JSON::Schema::Modern::Utilities::BEGIN@12 which was called:
# once (16µs+32µs) by JSON::Schema::Modern::BEGIN@36 at line 12 # spent 48µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@12
# spent 4µs making 1 call to if::import |
13 | 2 | 41µs | 2 | 32µs | # spent 30µs (14+16) within JSON::Schema::Modern::Utilities::BEGIN@13 which was called:
# once (14µs+16µs) by JSON::Schema::Modern::BEGIN@36 at line 13 # spent 30µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@13
# spent 2µs making 1 call to if::unimport |
14 | 2 | 28µs | 2 | 36µs | # spent 33µs (16+17) within JSON::Schema::Modern::Utilities::BEGIN@14 which was called:
# once (16µs+17µs) by JSON::Schema::Modern::BEGIN@36 at line 14 # spent 33µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@14
# spent 3µs making 1 call to if::unimport |
15 | 2 | 22µs | 2 | 31µs | # spent 29µs (12+17) within JSON::Schema::Modern::Utilities::BEGIN@15 which was called:
# once (12µs+17µs) by JSON::Schema::Modern::BEGIN@36 at line 15 # spent 29µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@15
# spent 2µs making 1 call to if::unimport |
16 | 2 | 21µs | 2 | 12µs | # spent 10µs (8+2) within JSON::Schema::Modern::Utilities::BEGIN@16 which was called:
# once (8µs+2µs) by JSON::Schema::Modern::BEGIN@36 at line 16 # spent 10µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@16
# spent 2µs making 1 call to B::import |
17 | 2 | 32µs | 2 | 79µs | # spent 43µs (7+36) within JSON::Schema::Modern::Utilities::BEGIN@17 which was called:
# once (7µs+36µs) by JSON::Schema::Modern::BEGIN@36 at line 17 # spent 43µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@17
# spent 36µs making 1 call to Exporter::import |
18 | 3 | 50µs | 3 | 117µs | # spent 67µs (17+50) within JSON::Schema::Modern::Utilities::BEGIN@18 which was called:
# once (17µs+50µs) by JSON::Schema::Modern::BEGIN@36 at line 18 # spent 67µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@18
# spent 38µs making 1 call to Exporter::import
# spent 12µs making 1 call to UNIVERSAL::VERSION |
19 | 3 | 34µs | 3 | 72µs | # spent 42µs (12+30) within JSON::Schema::Modern::Utilities::BEGIN@19 which was called:
# once (12µs+30µs) by JSON::Schema::Modern::BEGIN@36 at line 19 # spent 42µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@19
# spent 25µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
20 | 2 | 24µs | 2 | 38µs | # spent 24µs (10+14) within JSON::Schema::Modern::Utilities::BEGIN@20 which was called:
# once (10µs+14µs) by JSON::Schema::Modern::BEGIN@36 at line 20 # spent 24µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@20
# spent 14µs making 1 call to Exporter::import |
21 | 2 | 21µs | 2 | 39µs | # spent 23µs (7+16) within JSON::Schema::Modern::Utilities::BEGIN@21 which was called:
# once (7µs+16µs) by JSON::Schema::Modern::BEGIN@36 at line 21 # spent 23µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@21
# spent 16µs making 1 call to Exporter::import |
22 | 2 | 21µs | 2 | 64µs | # spent 36µs (8+28) within JSON::Schema::Modern::Utilities::BEGIN@22 which was called:
# once (8µs+28µs) by JSON::Schema::Modern::BEGIN@36 at line 22 # spent 36µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@22
# spent 28µs making 1 call to Feature::Compat::Try::import |
23 | 2 | 48µs | 2 | 30µs | # spent 29µs (28+1) within JSON::Schema::Modern::Utilities::BEGIN@23 which was called:
# once (28µs+1µs) by JSON::Schema::Modern::BEGIN@36 at line 23 # spent 29µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@23
# spent 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__ |
24 | 2 | 30µs | 2 | 17µs | # spent 16µs (15+1000ns) within JSON::Schema::Modern::Utilities::BEGIN@24 which was called:
# once (15µs+1000ns) by JSON::Schema::Modern::BEGIN@36 at line 24 # spent 16µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@24
# spent 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__ |
25 | 2 | 60µs | 2 | 880µs | # spent 444µs (8+436) within JSON::Schema::Modern::Utilities::BEGIN@25 which was called:
# once (8µs+436µs) by JSON::Schema::Modern::BEGIN@36 at line 25 # spent 444µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@25
# spent 436µs making 1 call to namespace::clean::import |
26 | |||||
27 | 2 | 72µs | 2 | 33µs | # spent 24µs (15+9) within JSON::Schema::Modern::Utilities::BEGIN@27 which was called:
# once (15µs+9µs) by JSON::Schema::Modern::BEGIN@36 at line 27 # spent 24µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@27
# spent 9µs making 1 call to Exporter::import |
28 | |||||
29 | 1 | 3µs | our @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 | |||||
52 | 2 | 48µs | 1 | 10µs | # spent 10µs within JSON::Schema::Modern::Utilities::BEGIN@52 which was called:
# once (10µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 52 # spent 10µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@52 |
53 | 2 | 3.32ms | 4 | 161µs | # spent 91µs (21+70) within JSON::Schema::Modern::Utilities::BEGIN@53 which was called:
# once (21µs+70µs) by JSON::Schema::Modern::BEGIN@36 at line 53 # spent 91µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@53
# spent 68µs making 1 call to constant::import
# spent 2µs making 1 call to JSON::PP::true
# spent 0s making 1 call to JSON::PP::false |
54 | |||||
55 | 216930 | 51.0ms | # spent 365ms (274+90.5) within JSON::Schema::Modern::Utilities::is_type which was called 72310 times, avg 5µs/call:
# 32492 times (124ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 366 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call
# 11057 times (40.2ms+53.7ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 374 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 4795 times (16.1ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 269 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call
# 3747 times (8.81ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 116 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 2µs/call
# 3590 times (24.2ms+7.87ms) by JSON::Schema::Modern::Utilities::assert_keyword_type at line 291, avg 9µs/call
# 3369 times (12.8ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 408 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call
# 1835 times (7.59ms+8.91ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 451 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call
# 1799 times (7.62ms+11.4ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 415 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 11µs/call
# 1758 times (7.00ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 299 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call
# 1632 times (5.85ms+7.03ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 305 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 1403 times (2.41ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 211 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call
# 1244 times (3.80ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems at line 200 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call
# 977 times (3.12ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 441 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call
# 774 times (3.43ms+763µs) by List::Util::any at line 263 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call
# 627 times (1.84ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 476 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call
# 485 times (1.26ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties at line 254 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call
# 305 times (562µs+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 161 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call
# 262 times (2.35ms+667µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 183 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call
# 79 times (832µs+89µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum at line 146 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call
# 63 times (534µs+62µs) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 181 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 9µs/call
# 15 times (48µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_maxProperties at line 245 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call
# once (7µs+1000ns) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 286 of JSON/Schema/Modern/Vocabulary/Validation.pm
# once (3µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 282 of JSON/Schema/Modern/Vocabulary/Validation.pm | ||
56 | 72310 | 23.7ms | if ($type eq 'null') { | ||
57 | return !(defined $value); | ||||
58 | } | ||||
59 | 72310 | 80.3ms | 16507 | 82.6ms | if ($type eq 'boolean') { # spent 82.6ms making 16507 calls to JSON::MaybeXS::is_bool, avg 5µs/call |
60 | return is_bool($value); | ||||
61 | } | ||||
62 | 55803 | 186ms | if ($type eq 'object') { | ||
63 | return is_plain_hashref($value); | ||||
64 | } | ||||
65 | 8565 | 13.8ms | if ($type eq 'array') { | ||
66 | return is_plain_arrayref($value); | ||||
67 | } | ||||
68 | |||||
69 | 3748 | 1.42ms | if ($type eq 'string' or $type eq 'number' or $type eq 'integer') { | ||
70 | 3748 | 696µs | return 0 if not defined $value; | ||
71 | 3748 | 21.9ms | 7496 | 7.86ms | my $flags = B::svref_2object(\$value)->FLAGS; # spent 5.98ms making 3748 calls to B::svref_2object, avg 2µs/call
# spent 1.88ms making 3748 calls to B::SV::FLAGS, avg 501ns/call |
72 | |||||
73 | 3748 | 10.0ms | if ($type eq 'string') { | ||
74 | return !is_ref($value) && $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK)); | ||||
75 | } | ||||
76 | |||||
77 | 196 | 80µs | if ($type eq 'number') { | ||
78 | 109 | 547µs | 109 | 29µ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 | |||||
82 | 87 | 33µs | if ($type eq 'integer') { | ||
83 | 87 | 458µs | 87 | 41µs | return ref($value) =~ /^Math::Big(?:Int|Float)$/ && $value->is_int # spent 41µs making 87 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 471ns/call |
84 | || !($flags & B::SVf_POK) && ($flags & (B::SVf_IOK | B::SVf_NOK)) && int($value) == $value; | ||||
85 | } | ||||
86 | } | ||||
87 | |||||
88 | if ($type =~ /^reference to (.+)$/) { | ||||
89 | return !blessed($value) && ref($value) eq $1; | ||||
90 | } | ||||
91 | |||||
92 | return ref($value) eq $type; | ||||
93 | } | ||||
94 | |||||
95 | 323998 | 48.6ms | # spent 634ms (453+181) within JSON::Schema::Modern::Utilities::get_type which was called 161999 times, avg 4µs/call:
# 91595 times (164ms+0s) by JSON::Schema::Modern::_eval_subschema at line 530 of JSON/Schema/Modern.pm, avg 2µs/call
# 35648 times (105ms+79.5ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 62 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call
# 31892 times (178ms+97.6ms) by JSON::Schema::Modern::Utilities::is_equal at line 120, avg 9µs/call
# 2863 times (6.09ms+4.37ms) by JSON::Schema::Modern::_traverse_subschema at line 454 of JSON/Schema/Modern.pm, avg 4µs/call
# once (5µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 89 of JSON/Schema/Modern/Document/OpenAPI.pm | ||
96 | 161999 | 291ms | return 'object' if is_plain_hashref($value); | ||
97 | 41632 | 47.5ms | 41632 | 135ms | return 'boolean' if is_bool($value); # spent 135ms making 41632 calls to JSON::MaybeXS::is_bool, avg 3µs/call |
98 | 36846 | 5.73ms | return 'null' if not defined $value; | ||
99 | 36846 | 7.48ms | return 'array' if is_plain_arrayref($value); | ||
100 | |||||
101 | 35741 | 4.34ms | return ref($value) =~ /^Math::Big(?:Int|Float)$/ ? ($value->is_int ? 'integer' : 'number') | ||
102 | : (blessed($value) ? '' : 'reference to ').ref($value) | ||||
103 | if is_ref($value); | ||||
104 | |||||
105 | 35741 | 140ms | 71482 | 46.1ms | my $flags = B::svref_2object(\$value)->FLAGS; # spent 33.0ms making 35741 calls to B::svref_2object, avg 924ns/call
# spent 13.1ms making 35741 calls to B::SV::FLAGS, avg 366ns/call |
106 | 35741 | 62.1ms | return 'string' if $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK)); | ||
107 | 107 | 384µ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 | ||||
117 | 63784 | 12.1ms | # spent 373ms (97.0+276) within JSON::Schema::Modern::Utilities::is_equal which was called 15946 times, avg 23µs/call:
# 7494 times (44.9ms+142ms) by List::Util::any at line 85 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 25µs/call
# 7244 times (38.5ms+103ms) by JSON::Schema::Modern::Utilities::is_elements_unique at line 160, avg 20µs/call
# 1208 times (13.5ms+30.7ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 95 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 37µs/call | ||
118 | 15946 | 5.85ms | $state->{path} //= ''; | ||
119 | |||||
120 | 15946 | 25.3ms | 31892 | 275ms | my @types = map get_type($_), $x, $y; # spent 275ms making 31892 calls to JSON::Schema::Modern::Utilities::get_type, avg 9µs/call |
121 | |||||
122 | 15946 | 4.24ms | if ($state->{scalarref_booleans}) { | ||
123 | 7244 | 1.03ms | ($x, $types[0]) = (0+!!$$x, 'boolean') if $types[0] eq 'reference to SCALAR'; | ||
124 | 7244 | 823µs | ($y, $types[1]) = (0+!!$$y, 'boolean') if $types[1] eq 'reference to SCALAR'; | ||
125 | } | ||||
126 | |||||
127 | 15946 | 3.49ms | return 0 if $types[0] ne $types[1]; | ||
128 | 15484 | 1.97ms | return 1 if $types[0] eq 'null'; | ||
129 | 15484 | 26.4ms | return $x eq $y if $types[0] eq 'string'; | ||
130 | 173 | 1.16ms | 346 | 461µs | return $x == $y if grep $types[0] eq $_, qw(boolean number integer); # spent 461µs making 346 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:7], avg 1µs/call |
131 | |||||
132 | my $path = $state->{path}; | ||||
133 | if ($types[0] eq 'object') { | ||||
134 | return 0 if keys %$x != keys %$y; | ||||
135 | return 0 if not is_equal([ sort keys %$x ], [ sort keys %$y ]); | ||||
136 | foreach my $property (sort keys %$x) { | ||||
137 | $state->{path} = jsonp($path, $property); | ||||
138 | return 0 if not is_equal($x->{$property}, $y->{$property}, $state); | ||||
139 | } | ||||
140 | return 1; | ||||
141 | } | ||||
142 | |||||
143 | if ($types[0] eq 'array') { | ||||
144 | return 0 if @$x != @$y; | ||||
145 | foreach my $idx (0 .. $x->$#*) { | ||||
146 | $state->{path} = $path.'/'.$idx; | ||||
147 | return 0 if not is_equal($x->[$idx], $y->[$idx], $state); | ||||
148 | } | ||||
149 | return 1; | ||||
150 | } | ||||
151 | |||||
152 | return 0; # should never get here | ||||
153 | } | ||||
154 | |||||
155 | # checks array elements for uniqueness. short-circuits on first pair of matching elements | ||||
156 | # if second arrayref is provided, it is populated with the indices of identical items | ||||
157 | 1920 | 460µs | # spent 163ms (20.9+142) within JSON::Schema::Modern::Utilities::is_elements_unique which was called 640 times, avg 255µs/call:
# 288 times (9.47ms+64.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 213 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 257µs/call
# 275 times (10.7ms+74.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 264 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 310µs/call
# 76 times (795µs+2.78ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 51 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 47µs/call
# once (3µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 290 of JSON/Schema/Modern/Vocabulary/Validation.pm | ||
158 | 640 | 1.19ms | foreach my $idx0 (0 .. $array->$#*-1) { | ||
159 | 1141 | 1.62ms | foreach my $idx1 ($idx0+1 .. $array->$#*) { | ||
160 | 7244 | 11.1ms | 7244 | 142ms | if (is_equal($array->[$idx0], $array->[$idx1], { scalarref_booleans => 1 })) { # spent 142ms making 7244 calls to JSON::Schema::Modern::Utilities::is_equal, avg 20µs/call |
161 | push @$equal_indices, $idx0, $idx1 if defined $equal_indices; | ||||
162 | return 0; | ||||
163 | } | ||||
164 | } | ||||
165 | } | ||||
166 | 640 | 1.74ms | return 1; | ||
167 | } | ||||
168 | |||||
169 | # shorthand for creating and appending json pointers | ||||
170 | # the first argument is a a json pointer; remaining arguments are path segments to be encoded and | ||||
171 | # appended | ||||
172 | # spent 1.41s (1.24+169ms) within JSON::Schema::Modern::Utilities::jsonp which was called 221215 times, avg 6µs/call:
# 76007 times (427ms+72.8ms) by JSON::Schema::Modern::Utilities::canonical_uri at line 193, avg 7µs/call
# 71790 times (302ms+33.2ms) by JSON::Schema::Modern::Utilities::A at line 250, avg 5µs/call
# 41707 times (293ms+35.1ms) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 89 of JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call
# 21824 times (159ms+14.7ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 380 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 4217 times (16.7ms+2.02ms) by JSON::Schema::Modern::Utilities::E at line 216, avg 4µs/call
# 1835 times (11.4ms+3.94ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 457 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 1476 times (9.21ms+2.43ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 421 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 1349 times (13.7ms+2.03ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 55 of JSON/Schema/Modern/Vocabulary.pm, avg 12µs/call
# 713 times (3.92ms+2.47ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 480 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call
# 290 times (2.21ms+331µs) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 167 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call
# 6 times (47µs+9µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 64 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call
# once (9µs+1µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 132 of JSON/Schema/Modern/Vocabulary/Core.pm | ||||
173 | 221215 | 1.59s | 469020 | 169ms | return join('/', shift, map s/~/~0/gr =~ s!/!~1!gr, map +(is_plain_arrayref($_) ? @$_ : $_), grep defined, @_); # spent 169ms making 469020 calls to JSON::Schema::Modern::Utilities::CORE:subst, avg 360ns/call |
174 | } | ||||
175 | |||||
176 | # splits a json pointer apart into its path segments | ||||
177 | sub 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) | ||||
183 | 7494 | 1.56ms | # spent 886ms (575+310) within JSON::Schema::Modern::Utilities::local_annotations which was called 3747 times, avg 236µs/call:
# 3747 times (575ms+310ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 119 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 236µs/call | ||
184 | 3747 | 261ms | 371738 | 310ms | grep $_->instance_location eq $state->{data_path}, $state->{annotations}->@*; # spent 310ms making 371738 calls to JSON::Schema::Modern::Annotation::instance_location, avg 835ns/call |
185 | } | ||||
186 | |||||
187 | # shorthand for finding the canonical uri of the present schema location | ||||
188 | # last argument can be an arrayref, usually coming from $state->{_schema_path_suffix} | ||||
189 | 505032 | 121ms | # spent 6.96s (1.46+5.50) within JSON::Schema::Modern::Utilities::canonical_uri which was called 168344 times, avg 41µs/call:
# 91595 times (533ms+2.01s) by JSON::Schema::Modern::_eval_subschema at line 540 of JSON/Schema/Modern.pm, avg 28µs/call
# 71790 times (857ms+3.27s) by JSON::Schema::Modern::Utilities::A at line 247, avg 58µs/call
# 4217 times (52.0ms+181ms) by JSON::Schema::Modern::Utilities::E at line 213, avg 55µs/call
# 727 times (12.4ms+37.8ms) by JSON::Schema::Modern::Document::OpenAPI::_traverse_schema at line 218 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 69µs/call
# 15 times (122µs+368µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 162 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 33µs/call | ||
190 | 168344 | 157ms | return $state->{initial_schema_uri} if not length($state->{schema_path}) and not @extra_path; | ||
191 | 126625 | 46.9ms | splice(@extra_path, -1, 1, $extra_path[-1]->@*) if @extra_path and is_plain_arrayref($extra_path[-1]); | ||
192 | 126625 | 189ms | 126625 | 4.75s | my $uri = $state->{initial_schema_uri}->clone; # spent 4.75s making 126625 calls to Mojo::URL::clone, avg 38µs/call |
193 | 126625 | 310ms | 202632 | 627ms | my $fragment = ($uri->fragment//'').(@extra_path ? jsonp($state->{schema_path}, @extra_path) : $state->{schema_path}); # spent 500ms making 76007 calls to JSON::Schema::Modern::Utilities::jsonp, avg 7µs/call
# spent 126ms making 126625 calls to Mojo::URL::fragment, avg 998ns/call |
194 | 126625 | 30.5ms | undef $fragment if not length($fragment); | ||
195 | 126625 | 77.8ms | 126625 | 121ms | $uri->fragment($fragment); # spent 121ms making 126625 calls to Mojo::URL::fragment, avg 953ns/call |
196 | 126625 | 237ms | $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 | ||||
208 | 16868 | 4.85ms | # spent 1.17s (117ms+1.05) within JSON::Schema::Modern::Utilities::E which was called 4217 times, avg 277µs/call:
# 1438 times (43.5ms+355ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 273 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 277µs/call
# 1115 times (34.5ms+290ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 73 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 291µs/call
# 799 times (20.2ms+199ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 97 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 275µs/call
# 799 times (16.6ms+190ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 392 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 259µs/call
# 66 times (2.00ms+17.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum at line 88 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 297µs/call | ||
209 | 4217 | 1.51ms | croak 'E called in void context' if not defined wantarray; | ||
210 | |||||
211 | # sometimes the keyword shouldn't be at the very end of the schema path | ||||
212 | my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix}) | ||||
213 | 4217 | 24.6ms | 8434 | 395ms | ->to_abs($state->{effective_base_uri}); # spent 233ms making 4217 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 55µs/call
# spent 162ms making 4217 calls to Mojo::URL::to_abs, avg 38µs/call |
214 | |||||
215 | my $keyword_location = $state->{traversed_schema_path} | ||||
216 | 4217 | 8.10ms | 4217 | 18.7ms | .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix}); # spent 18.7ms making 4217 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call |
217 | |||||
218 | 4217 | 14.6ms | 8434 | 404ms | undef $uri if $uri eq '' and $keyword_location eq '' # spent 401ms making 4217 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 95µs/call
# spent 2.65ms making 4217 calls to Mojo::URL::fragment, avg 629ns/call |
219 | or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq ''; | ||||
220 | |||||
221 | push $state->{errors}->@*, JSON::Schema::Modern::Error->new( | ||||
222 | keyword => $state->{keyword}, | ||||
223 | instance_location => $state->{data_path}, | ||||
224 | keyword_location => $keyword_location, | ||||
225 | defined $uri ? ( absolute_keyword_location => $uri ) : (), | ||||
226 | error => @args ? sprintf($error_string, @args) : $error_string, | ||||
227 | 4217 | 28.7ms | 4217 | 235ms | $state->{exception} ? ( exception => $state->{exception} ) : (), # spent 235ms making 4217 calls to JSON::Schema::Modern::Error::new, avg 56µs/call |
228 | ); | ||||
229 | |||||
230 | 4217 | 13.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 | ||||
243 | 215376 | 43.9ms | # spent 19.7s (1.64+18.1) within JSON::Schema::Modern::Utilities::A which was called 71792 times, avg 275µs/call:
# 32214 times (705ms+8.00s) by JSON::Schema::Modern::Utilities::annotate_self at line 345, avg 270µs/call
# 28612 times (694ms+7.34s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 391 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 281µs/call
# 3747 times (71.0ms+912ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 147 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 262µs/call
# 3369 times (84.9ms+878ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 433 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 286µs/call
# 2167 times (53.6ms+541ms) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_eval_keyword_format at line 40 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 275µs/call
# 977 times (18.7ms+234ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 468 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 259µs/call
# 643 times (14.8ms+161ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 325 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 274µs/call
# 63 times (1.54ms+17.0ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 183 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 294µs/call | ||
244 | 71792 | 52.7ms | return 1 if not $state->{collect_annotations} or $state->{spec_version} eq 'draft7'; | ||
245 | |||||
246 | my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix}) | ||||
247 | 71790 | 366ms | 143580 | 6.98s | ->to_abs($state->{effective_base_uri}); # spent 4.13s making 71790 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 58µs/call
# spent 2.85s making 71790 calls to Mojo::URL::to_abs, avg 40µs/call |
248 | |||||
249 | my $keyword_location = $state->{traversed_schema_path} | ||||
250 | 71790 | 146ms | 71790 | 335ms | .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix}); # spent 335ms making 71790 calls to JSON::Schema::Modern::Utilities::jsonp, avg 5µs/call |
251 | |||||
252 | 71790 | 222ms | 143580 | 7.34s | undef $uri if $uri eq '' and $keyword_location eq '' # spent 7.29s making 71790 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 102µs/call
# spent 45.9ms making 71790 calls to Mojo::URL::fragment, avg 639ns/call |
253 | or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq ''; | ||||
254 | |||||
255 | push $state->{annotations}->@*, JSON::Schema::Modern::Annotation->new( | ||||
256 | keyword => $state->{keyword}, | ||||
257 | instance_location => $state->{data_path}, | ||||
258 | keyword_location => $keyword_location, | ||||
259 | defined $uri ? ( absolute_keyword_location => $uri ) : (), | ||||
260 | annotation => $annotation, | ||||
261 | 71790 | 254ms | 71790 | 3.42s | $state->{_unknown} ? ( unknown => 1 ) : (), # spent 3.42s making 71790 calls to JSON::Schema::Modern::Annotation::new, avg 48µs/call |
262 | ); | ||||
263 | |||||
264 | 71790 | 224ms | return 1; | ||
265 | } | ||||
266 | |||||
267 | # creates an error object, but also aborts evaluation immediately | ||||
268 | # only this error is returned, because other errors on the stack might not actually be "real" | ||||
269 | # errors (consider if we were in the middle of evaluating a "not" or "if"). | ||||
270 | # Therefore this is only appropriate during the evaluation phase, not the traverse phase. | ||||
271 | sub abort ($state, $error_string, @args) { | ||||
272 | ()= E({ %$state, exception => 1 }, $error_string, @args); | ||||
273 | croak 'abort() called during traverse' if $state->{traverse}; | ||||
274 | die pop $state->{errors}->@*; | ||||
275 | } | ||||
276 | |||||
277 | 3 | 1µs | # spent 5µs within JSON::Schema::Modern::Utilities::assert_keyword_exists which was called:
# once (5µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm | ||
278 | 1 | 0s | croak 'assert_keyword_exists called in void context' if not defined wantarray; | ||
279 | 1 | 1µs | return E($state, '%s keyword is required', $state->{keyword}) if not exists $schema->{$state->{keyword}}; | ||
280 | 1 | 3µs | return 1; | ||
281 | } | ||||
282 | |||||
283 | 14360 | 2.16ms | # spent 51.3ms (19.3+32.1) within JSON::Schema::Modern::Utilities::assert_keyword_type which was called 3590 times, avg 14µs/call:
# 1306 times (7.24ms+15.1ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 54 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 17µs/call
# 732 times (3.86ms+7.69ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 203 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 16µs/call
# 402 times (3.02ms+1.19ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 50 of JSON/Schema/Modern/Vocabulary.pm, avg 10µs/call
# 275 times (1.19ms+515µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 261 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 6µs/call
# 150 times (531µs+1.68ms) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_deprecated at line 55 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 15µs/call
# 131 times (632µs+1.09ms) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_title at line 38 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 13µs/call
# 118 times (618µs+1.16ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_comment at line 285 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 15µs/call
# 87 times (329µs+917µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer at line 318 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call
# 76 times (342µs+151µs) by JSON::Schema::Modern::Vocabulary::traverse_array_schemas at line 38 of JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call
# 69 times (361µs+723µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 16µs/call
# 60 times (221µs+97µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum at line 78 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call
# 50 times (166µs+292µs) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_traverse_keyword_format at line 35 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 9µs/call
# 31 times (146µs+341µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 265 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 16µs/call
# 30 times (124µs+290µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_number at line 313 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call
# 15 times (121µs+229µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 112 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 23µs/call
# 15 times (95µs+207µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 153 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 20µs/call
# 14 times (124µs+270µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 28µs/call
# 11 times (79µs+59µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 256 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 13µs/call
# 6 times (24µs+14µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 397 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 6µs/call
# 6 times (23µs+12µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 61 of JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call
# 3 times (13µs+36µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems at line 206 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 16µs/call
# once (7µs+36µs) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm
# once (4µs+2µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 277 of JSON/Schema/Modern/Vocabulary/Validation.pm
# once (3µs+2µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding at line 39 of JSON/Schema/Modern/Vocabulary/Content.pm | ||
284 | 3590 | 860µs | croak 'assert_keyword_type called in void context' if not defined wantarray; | ||
285 | 3590 | 2.83ms | my $value = $schema->{$state->{keyword}}; | ||
286 | 3590 | 747µs | my $thing = 'value'; | ||
287 | ($value, $thing) = is_plain_hashref($value) ? ($value->{$state->{_schema_path_suffix}}, 'value at "'.$state->{_schema_path_suffix}.'"') | ||||
288 | : is_plain_arrayref($value) ? ($value->[$state->{_schema_path_suffix}], 'item '.$state->{_schema_path_suffix}) | ||||
289 | : die 'unknown type' | ||||
290 | 3590 | 816µs | if exists $state->{_schema_path_suffix}; | ||
291 | 3590 | 11.7ms | 3590 | 32.1ms | return 1 if is_type($type, $value); # spent 32.1ms making 3590 calls to JSON::Schema::Modern::Utilities::is_type, avg 9µs/call |
292 | E($state, '%s %s is not a%s %s', $state->{keyword}, $thing, ($type =~ /^[aeiou]/ ? 'n' : ''), $type); | ||||
293 | } | ||||
294 | |||||
295 | 225 | 51µs | # spent 3.64ms (1.30+2.34) within JSON::Schema::Modern::Utilities::assert_pattern which was called 75 times, avg 48µs/call:
# 69 times (1.18ms+2.17ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 49µs/call
# 6 times (114µs+171µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 401 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 47µs/call | ||
296 | 75 | 24µs | croak 'assert_pattern called in void context' if not defined wantarray; | ||
297 | 75 | 79µs | try { | ||
298 | 75 | 418µs | local $SIG{__WARN__} = sub { die @_ }; | ||
299 | 75 | 2.96ms | 150 | 2.34ms | qr/$pattern/; # spent 2.16ms making 75 calls to JSON::Schema::Modern::Utilities::CORE:regcomp, avg 29µs/call
# spent 183µs making 75 calls to JSON::Schema::Modern::Utilities::CORE:qr, avg 2µs/call |
300 | } | ||||
301 | catch ($e) { return E($state, $e); }; | ||||
302 | 75 | 141µs | return 1; | ||
303 | } | ||||
304 | |||||
305 | # this is only suitable for checking URIs within schemas themselves | ||||
306 | 2238 | 394µs | # spent 195ms (12.9+182) within JSON::Schema::Modern::Utilities::assert_uri_reference which was called 746 times, avg 261µs/call:
# 732 times (12.7ms+180ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 203 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 263µs/call
# 14 times (206µs+2.31ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 180µs/call | ||
307 | 746 | 274µs | croak 'assert_uri_reference called in void context' if not defined wantarray; | ||
308 | |||||
309 | 746 | 489µs | my $string = $schema->{$state->{keyword}}; | ||
310 | return E($state, '%s value is not a valid URI reference', $state->{keyword}) | ||||
311 | # see also uri-reference format sub | ||||
312 | 746 | 15.4ms | 5108 | 182ms | if fc(Mojo::URL->new($string)->to_unsafe_string) ne fc($string) # spent 105ms making 746 calls to Mojo::URL::new, avg 141µs/call
# spent 70.8ms making 746 calls to Mojo::URL::to_unsafe_string, avg 95µs/call
# spent 5.71ms making 3616 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 2µs/call |
313 | or $string =~ /[^[:ascii:]]/ | ||||
314 | or $string =~ /#/ | ||||
315 | and $string !~ m{#$} # empty fragment | ||||
316 | and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment | ||||
317 | and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment | ||||
318 | |||||
319 | 746 | 1.87ms | return 1; | ||
320 | } | ||||
321 | |||||
322 | # this is only suitable for checking URIs within schemas themselves | ||||
323 | 184 | 46µs | # spent 7.97ms (786µs+7.19) within JSON::Schema::Modern::Utilities::assert_uri which was called 46 times, avg 173µs/call:
# 31 times (481µs+4.52ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 266 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 161µs/call
# 15 times (305µs+2.67ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 112 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 198µs/call | ||
324 | 46 | 14µs | croak 'assert_uri called in void context' if not defined wantarray; | ||
325 | |||||
326 | 46 | 23µs | my $string = $override // $schema->{$state->{keyword}}; | ||
327 | 46 | 93µs | 46 | 2.24ms | my $uri = Mojo::URL->new($string); # spent 2.24ms making 46 calls to Mojo::URL::new, avg 49µs/call |
328 | |||||
329 | 46 | 341µs | 184 | 4.94ms | return E($state, '"%s" is not a valid URI', $string) # spent 4.73ms making 46 calls to Mojo::URL::to_unsafe_string, avg 103µs/call
# spent 170µs making 46 calls to Mojo::URL::is_abs, avg 4µs/call
# spent 46µs making 92 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 500ns/call |
330 | # see also uri format sub | ||||
331 | if fc($uri->to_unsafe_string) ne fc($string) | ||||
332 | or $string =~ /[^[:ascii:]]/ | ||||
333 | or not $uri->is_abs | ||||
334 | or $string =~ /#/ | ||||
335 | and $string !~ m{#$} # empty fragment | ||||
336 | and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment | ||||
337 | and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment | ||||
338 | |||||
339 | 46 | 198µs | return 1; | ||
340 | } | ||||
341 | |||||
342 | # produces an annotation whose value is the same as that of the current keyword | ||||
343 | 96642 | 16.4ms | # spent 8.95s (212ms+8.74) within JSON::Schema::Modern::Utilities::annotate_self which was called 32214 times, avg 278µs/call:
# 32214 times (212ms+8.74s) by JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_title at line 43 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 278µs/call | ||
344 | A($state, is_ref($schema->{$state->{keyword}}) ? dclone($schema->{$state->{keyword}}) | ||||
345 | 32214 | 186ms | 33327 | 8.74s | : $schema->{$state->{keyword}}); # spent 8.70s making 32214 calls to JSON::Schema::Modern::Utilities::A, avg 270µs/call
# spent 40.9ms making 1113 calls to Storable::dclone, avg 37µs/call |
346 | } | ||||
347 | |||||
348 | sub sprintf_num ($value) { | ||||
349 | # use original value as stored in the NV, without losing precision | ||||
350 | ref($value) =~ /^Math::Big(?:Int|Float)$/ ? $value->bstr : sprintf('%s', $value); | ||||
351 | } | ||||
352 | |||||
353 | 1 | 7µs | 1; | ||
354 | |||||
355 | 1 | 54µs | 1 | 324µs | __END__ # spent 324µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 5.82ms within JSON::Schema::Modern::Utilities::CORE:match which was called 3904 times, avg 1µs/call:
# 3616 times (5.71ms+0s) by JSON::Schema::Modern::Utilities::assert_uri_reference at line 312, avg 2µs/call
# 109 times (29µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 78, avg 266ns/call
# 92 times (46µs+0s) by JSON::Schema::Modern::Utilities::assert_uri at line 329, avg 500ns/call
# 87 times (41µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 83, avg 471ns/call | |||||
# spent 183µs within JSON::Schema::Modern::Utilities::CORE:qr which was called 75 times, avg 2µs/call:
# 75 times (183µs+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 299, avg 2µs/call | |||||
# spent 2.16ms within JSON::Schema::Modern::Utilities::CORE:regcomp which was called 75 times, avg 29µs/call:
# 75 times (2.16ms+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 299, avg 29µs/call | |||||
# spent 169ms within JSON::Schema::Modern::Utilities::CORE:subst which was called 469020 times, avg 360ns/call:
# 469020 times (169ms+0s) by JSON::Schema::Modern::Utilities::jsonp at line 173, avg 360ns/call | |||||
sub JSON::Schema::Modern::Utilities::__ANON__; # xsub |