Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Utilities.pm |
Statements | Executed 3784360 statements in 5.03s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
168344 | 5 | 4 | 1.38s | 6.76s | canonical_uri | JSON::Schema::Modern::Utilities::
221215 | 12 | 4 | 1.19s | 1.35s | jsonp | JSON::Schema::Modern::Utilities::
71792 | 8 | 5 | 875ms | 5.16s | A | JSON::Schema::Modern::Utilities::
161999 | 5 | 4 | 460ms | 648ms | get_type | JSON::Schema::Modern::Utilities::
72310 | 23 | 5 | 288ms | 393ms | is_type | JSON::Schema::Modern::Utilities::
469020 | 1 | 1 | 155ms | 155ms | CORE:subst (opcode) | JSON::Schema::Modern::Utilities::
32214 | 1 | 1 | 146ms | 2.39s | annotate_self | JSON::Schema::Modern::Utilities::
3747 | 1 | 1 | 143ms | 143ms | local_annotations | JSON::Schema::Modern::Utilities::
4217 | 5 | 2 | 128ms | 1.24s | E | JSON::Schema::Modern::Utilities::
15946 | 3 | 2 | 101ms | 352ms | is_equal | JSON::Schema::Modern::Utilities::
640 | 4 | 1 | 18.7ms | 148ms | is_elements_unique | JSON::Schema::Modern::Utilities::
3590 | 24 | 8 | 16.2ms | 44.2ms | assert_keyword_type | JSON::Schema::Modern::Utilities::
746 | 2 | 1 | 10.4ms | 162ms | assert_uri_reference | JSON::Schema::Modern::Utilities::
3904 | 4 | 1 | 5.21ms | 5.21ms | CORE:match (opcode) | JSON::Schema::Modern::Utilities::
75 | 1 | 1 | 1.94ms | 1.94ms | CORE:regcomp (opcode) | JSON::Schema::Modern::Utilities::
75 | 2 | 2 | 1.15ms | 3.24ms | assert_pattern | JSON::Schema::Modern::Utilities::
46 | 2 | 1 | 613µs | 6.63ms | assert_uri | JSON::Schema::Modern::Utilities::
75 | 1 | 1 | 152µs | 152µs | CORE:qr (opcode) | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 102µs | 105µs | BEGIN@1.159 | JSON::Schema::Modern::
1 | 1 | 1 | 43µs | 49µs | BEGIN@14 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 38µs | 64µs | BEGIN@18 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 28µs | 30µs | BEGIN@16 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 13µs | 688µs | BEGIN@10 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 13µs | 14µs | BEGIN@23 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 12µs | 37µs | BEGIN@12 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 11µs | 68µs | BEGIN@53 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 11µs | 11µs | BEGIN@9 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 9µs | 18µs | BEGIN@15 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 8µs | 20µs | BEGIN@13 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 7µs | 8µs | BEGIN@24 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 6µs | 53µs | BEGIN@2.160 | JSON::Schema::Modern::
1 | 1 | 1 | 6µs | 87µs | BEGIN@11 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 6µs | 179µs | BEGIN@25 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 6µs | 11µs | BEGIN@27 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 5µs | 24µs | BEGIN@19 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 5µs | 11µs | BEGIN@20 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 5µs | 15µs | BEGIN@21 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 5µs | 21µs | BEGIN@22 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 5µs | 5µs | BEGIN@52 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 4µs | 29µs | BEGIN@17 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 4µs | 4µ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__[:299] | 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 | 40µs | 2 | 108µs | # spent 105µs (102+3) within JSON::Schema::Modern::BEGIN@1.159 which was called:
# once (102µs+3µs) by JSON::Schema::Modern::BEGIN@36 at line 1 # spent 105µs making 1 call to JSON::Schema::Modern::BEGIN@1.159
# spent 3µs making 1 call to strict::import |
2 | 2 | 34µs | 2 | 100µs | # spent 53µs (6+47) within JSON::Schema::Modern::BEGIN@2.160 which was called:
# once (6µs+47µs) by JSON::Schema::Modern::BEGIN@36 at line 2 # spent 53µs making 1 call to JSON::Schema::Modern::BEGIN@2.160
# spent 47µ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 | 0s | our $VERSION = '0.558'; | ||
8 | |||||
9 | 2 | 34µs | 1 | 11µs | # spent 11µs within JSON::Schema::Modern::Utilities::BEGIN@9 which was called:
# once (11µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 9 # spent 11µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@9 |
10 | 3 | 27µs | 3 | 1.36ms | # spent 688µs (13+675) within JSON::Schema::Modern::Utilities::BEGIN@10 which was called:
# once (13µs+675µs) by JSON::Schema::Modern::BEGIN@36 at line 10 # spent 688µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@10
# spent 660µs making 1 call to strictures::import
# spent 15µs making 1 call to strictures::VERSION |
11 | 2 | 31µs | 2 | 168µs | # spent 87µs (6+81) within JSON::Schema::Modern::Utilities::BEGIN@11 which was called:
# once (6µs+81µs) by JSON::Schema::Modern::BEGIN@36 at line 11 # spent 87µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@11
# spent 81µs making 1 call to experimental::import |
12 | 2 | 22µs | 2 | 40µs | # spent 37µs (12+25) within JSON::Schema::Modern::Utilities::BEGIN@12 which was called:
# once (12µs+25µs) by JSON::Schema::Modern::BEGIN@36 at line 12 # spent 37µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@12
# spent 3µs making 1 call to if::import |
13 | 2 | 42µs | 2 | 22µs | # spent 20µs (8+12) within JSON::Schema::Modern::Utilities::BEGIN@13 which was called:
# once (8µs+12µs) by JSON::Schema::Modern::BEGIN@36 at line 13 # spent 20µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@13
# spent 2µs making 1 call to if::unimport |
14 | 2 | 15µs | 2 | 49µs | # spent 49µs (43+6) within JSON::Schema::Modern::Utilities::BEGIN@14 which was called:
# once (43µs+6µs) by JSON::Schema::Modern::BEGIN@36 at line 14 # spent 49µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@14
# spent 0s making 1 call to if::unimport |
15 | 2 | 36µs | 2 | 19µs | # spent 18µs (9+9) within JSON::Schema::Modern::Utilities::BEGIN@15 which was called:
# once (9µs+9µs) by JSON::Schema::Modern::BEGIN@36 at line 15 # spent 18µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@15
# spent 1µs making 1 call to if::unimport |
16 | 2 | 14µs | 2 | 32µs | # spent 30µs (28+2) within JSON::Schema::Modern::Utilities::BEGIN@16 which was called:
# once (28µs+2µs) by JSON::Schema::Modern::BEGIN@36 at line 16 # spent 30µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@16
# spent 2µs making 1 call to B::import |
17 | 2 | 17µs | 2 | 54µs | # spent 29µs (4+25) within JSON::Schema::Modern::Utilities::BEGIN@17 which was called:
# once (4µs+25µs) by JSON::Schema::Modern::BEGIN@36 at line 17 # spent 29µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@17
# spent 25µs making 1 call to Exporter::import |
18 | 3 | 27µs | 3 | 90µs | # spent 64µs (38+26) within JSON::Schema::Modern::Utilities::BEGIN@18 which was called:
# once (38µs+26µs) by JSON::Schema::Modern::BEGIN@36 at line 18 # spent 64µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@18
# spent 21µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
19 | 3 | 23µs | 3 | 43µs | # spent 24µs (5+19) within JSON::Schema::Modern::Utilities::BEGIN@19 which was called:
# once (5µs+19µs) by JSON::Schema::Modern::BEGIN@36 at line 19 # spent 24µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@19
# spent 14µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
20 | 2 | 15µs | 2 | 17µs | # spent 11µs (5+6) within JSON::Schema::Modern::Utilities::BEGIN@20 which was called:
# once (5µs+6µs) by JSON::Schema::Modern::BEGIN@36 at line 20 # spent 11µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@20
# spent 6µs making 1 call to Exporter::import |
21 | 2 | 13µs | 2 | 25µs | # spent 15µs (5+10) within JSON::Schema::Modern::Utilities::BEGIN@21 which was called:
# once (5µs+10µs) by JSON::Schema::Modern::BEGIN@36 at line 21 # spent 15µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@21
# spent 10µs making 1 call to Exporter::import |
22 | 2 | 13µs | 2 | 37µs | # spent 21µs (5+16) within JSON::Schema::Modern::Utilities::BEGIN@22 which was called:
# once (5µs+16µs) by JSON::Schema::Modern::BEGIN@36 at line 22 # spent 21µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@22
# spent 16µs making 1 call to Feature::Compat::Try::import |
23 | 2 | 25µs | 2 | 15µs | # spent 14µs (13+1) within JSON::Schema::Modern::Utilities::BEGIN@23 which was called:
# once (13µs+1µs) by JSON::Schema::Modern::BEGIN@36 at line 23 # spent 14µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@23
# spent 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__ |
24 | 2 | 16µs | 2 | 9µs | # spent 8µs (7+1000ns) within JSON::Schema::Modern::Utilities::BEGIN@24 which was called:
# once (7µs+1000ns) by JSON::Schema::Modern::BEGIN@36 at line 24 # spent 8µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@24
# spent 1µs making 1 call to JSON::Schema::Modern::Utilities::__ANON__ |
25 | 2 | 23µs | 2 | 352µs | # spent 179µs (6+173) within JSON::Schema::Modern::Utilities::BEGIN@25 which was called:
# once (6µs+173µs) by JSON::Schema::Modern::BEGIN@36 at line 25 # spent 179µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@25
# spent 173µs making 1 call to namespace::clean::import |
26 | |||||
27 | 2 | 185µs | 2 | 16µs | # spent 11µs (6+5) within JSON::Schema::Modern::Utilities::BEGIN@27 which was called:
# once (6µs+5µs) by JSON::Schema::Modern::BEGIN@36 at line 27 # spent 11µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@27
# spent 5µs making 1 call to Exporter::import |
28 | |||||
29 | 1 | 2µ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 | 38µs | 1 | 5µ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 # spent 5µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@52 |
53 | 2 | 2.56ms | 4 | 125µs | # spent 68µs (11+57) within JSON::Schema::Modern::Utilities::BEGIN@53 which was called:
# once (11µs+57µs) by JSON::Schema::Modern::BEGIN@36 at line 53 # spent 68µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@53
# spent 53µs making 1 call to constant::import
# spent 2µs making 1 call to JSON::PP::false
# spent 2µs making 1 call to JSON::PP::true |
54 | |||||
55 | 216930 | 53.9ms | # spent 393ms (288+105) within JSON::Schema::Modern::Utilities::is_type which was called 72310 times, avg 5µs/call:
# 32492 times (132ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 366 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call
# 11057 times (43.9ms+65.8ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 374 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 10µs/call
# 4795 times (16.6ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 269 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call
# 3747 times (8.57ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 116 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 2µs/call
# 3590 times (21.2ms+6.84ms) by JSON::Schema::Modern::Utilities::assert_keyword_type at line 292, avg 8µs/call
# 3369 times (15.4ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 408 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 5µs/call
# 1835 times (7.14ms+11.1ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 451 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 10µs/call
# 1799 times (6.33ms+12.4ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 415 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 10µs/call
# 1758 times (8.20ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 299 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 5µs/call
# 1632 times (6.44ms+7.55ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 305 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call
# 1403 times (2.05ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 211 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 1µs/call
# 1244 times (4.39ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems at line 200 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 4µs/call
# 977 times (3.58ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 441 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 4µs/call
# 774 times (3.58ms+592µs) by List::Util::any at line 263 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call
# 627 times (1.65ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 476 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call
# 485 times (1.16ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties at line 254 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call
# 305 times (523µs+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 161 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call
# 262 times (2.64ms+768µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 183 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 13µs/call
# 79 times (1.02ms+91µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum at line 146 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call
# 63 times (650µs+170µs) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 182 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 13µs/call
# 15 times (41µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_maxProperties at line 245 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call
# once (1µs+2µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 286 of JSON/Schema/Modern/Vocabulary/Validation.pm
# once (0s+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 282 of JSON/Schema/Modern/Vocabulary/Validation.pm | ||
56 | 72310 | 29.9ms | if ($type eq 'null') { | ||
57 | return !(defined $value); | ||||
58 | } | ||||
59 | 72310 | 98.1ms | 16507 | 98.2ms | if ($type eq 'boolean') { # spent 98.2ms making 16507 calls to JSON::MaybeXS::is_bool, avg 6µs/call |
60 | return is_bool($value); | ||||
61 | } | ||||
62 | 55803 | 152ms | if ($type eq 'object') { | ||
63 | return is_plain_hashref($value); | ||||
64 | } | ||||
65 | 8565 | 14.8ms | if ($type eq 'array') { | ||
66 | return is_plain_arrayref($value); | ||||
67 | } | ||||
68 | |||||
69 | 3748 | 1.27ms | if ($type eq 'string' or $type eq 'number' or $type eq 'integer') { | ||
70 | 3748 | 741µs | return 0 if not defined $value; | ||
71 | 3748 | 18.9ms | 7496 | 6.99ms | my $flags = B::svref_2object(\$value)->FLAGS; # spent 5.34ms making 3748 calls to B::svref_2object, avg 1µs/call
# spent 1.64ms making 3748 calls to B::SV::FLAGS, avg 439ns/call |
72 | |||||
73 | 3748 | 8.74ms | if ($type eq 'string') { | ||
74 | return !is_ref($value) && $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK)); | ||||
75 | } | ||||
76 | |||||
77 | 196 | 98µs | if ($type eq 'number') { | ||
78 | 109 | 610µs | 109 | 35µs | return ref($value) =~ /^Math::Big(?:Int|Float)$/ # spent 35µs making 109 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 321ns/call |
79 | || !($flags & B::SVf_POK) && ($flags & (B::SVf_IOK | B::SVf_NOK)); | ||||
80 | } | ||||
81 | |||||
82 | 87 | 27µs | if ($type eq 'integer') { | ||
83 | 87 | 442µs | 87 | 21µs | return ref($value) =~ /^Math::Big(?:Int|Float)$/ && $value->is_int # spent 21µs making 87 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 241ns/call |
84 | || !($flags & B::SVf_POK) && ($flags & (B::SVf_IOK | B::SVf_NOK)) && int($value) == $value; | ||||
85 | } | ||||
86 | } | ||||
87 | |||||
88 | if ($type =~ /^reference to (.+)$/) { | ||||
89 | return !blessed($value) && ref($value) eq $1; | ||||
90 | } | ||||
91 | |||||
92 | return ref($value) eq $type; | ||||
93 | } | ||||
94 | |||||
95 | 323998 | 50.7ms | # spent 648ms (460+188) within JSON::Schema::Modern::Utilities::get_type which was called 161999 times, avg 4µs/call:
# 91595 times (186ms+0s) by JSON::Schema::Modern::_eval_subschema at line 534 of JSON/Schema/Modern.pm, avg 2µs/call
# 35648 times (114ms+88.1ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 62 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 6µs/call
# 31892 times (154ms+96.6ms) by JSON::Schema::Modern::Utilities::is_equal at line 120, avg 8µs/call
# 2863 times (5.57ms+3.22ms) by JSON::Schema::Modern::_traverse_subschema at line 458 of JSON/Schema/Modern.pm, avg 3µs/call
# once (3µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 89 of JSON/Schema/Modern/Document/OpenAPI.pm | ||
96 | 161999 | 320ms | return 'object' if is_plain_hashref($value); | ||
97 | 41632 | 48.1ms | 41632 | 140ms | return 'boolean' if is_bool($value); # spent 140ms making 41632 calls to JSON::MaybeXS::is_bool, avg 3µs/call |
98 | 36846 | 6.60ms | return 'null' if not defined $value; | ||
99 | 36846 | 7.54ms | return 'array' if is_plain_arrayref($value); | ||
100 | |||||
101 | 35741 | 4.70ms | return ref($value) =~ /^Math::Big(?:Int|Float)$/ ? ($value->is_int ? 'integer' : 'number') | ||
102 | : (blessed($value) ? '' : 'reference to ').ref($value) | ||||
103 | if is_ref($value); | ||||
104 | |||||
105 | 35741 | 142ms | 71482 | 47.9ms | my $flags = B::svref_2object(\$value)->FLAGS; # spent 34.2ms making 35741 calls to B::svref_2object, avg 956ns/call
# spent 13.7ms making 35741 calls to B::SV::FLAGS, avg 384ns/call |
106 | 35741 | 59.1ms | return 'string' if $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK)); | ||
107 | 107 | 332µ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.3ms | # spent 352ms (101+251) within JSON::Schema::Modern::Utilities::is_equal which was called 15946 times, avg 22µs/call:
# 7494 times (48.8ms+125ms) by List::Util::any at line 85 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 23µs/call
# 7244 times (36.3ms+92.7ms) by JSON::Schema::Modern::Utilities::is_elements_unique at line 160, avg 18µs/call
# 1208 times (15.4ms+33.7ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 95 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 41µs/call | ||
118 | 15946 | 6.99ms | $state->{path} //= ''; | ||
119 | |||||
120 | 15946 | 25.9ms | 31892 | 251ms | my @types = map get_type($_), $x, $y; # spent 251ms making 31892 calls to JSON::Schema::Modern::Utilities::get_type, avg 8µs/call |
121 | |||||
122 | 15946 | 4.59ms | if ($state->{scalarref_booleans}) { | ||
123 | 7244 | 954µs | ($x, $types[0]) = (0+!!$$x, 'boolean') if $types[0] eq 'reference to SCALAR'; | ||
124 | 7244 | 908µs | ($y, $types[1]) = (0+!!$$y, 'boolean') if $types[1] eq 'reference to SCALAR'; | ||
125 | } | ||||
126 | |||||
127 | 15946 | 3.74ms | return 0 if $types[0] ne $types[1]; | ||
128 | 15484 | 2.53ms | return 1 if $types[0] eq 'null'; | ||
129 | 15484 | 25.8ms | return $x eq $y if $types[0] eq 'string'; | ||
130 | 173 | 1.33ms | 346 | 555µs | return $x == $y if grep $types[0] eq $_, qw(boolean number integer); # spent 555µs making 346 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:7], avg 2µs/call |
131 | |||||
132 | my $path = $state->{path}; | ||||
133 | if ($types[0] eq 'object') { | ||||
134 | return 0 if keys %$x != keys %$y; | ||||
135 | return 0 if not is_equal([ sort keys %$x ], [ sort keys %$y ]); | ||||
136 | foreach my $property (sort keys %$x) { | ||||
137 | $state->{path} = jsonp($path, $property); | ||||
138 | return 0 if not is_equal($x->{$property}, $y->{$property}, $state); | ||||
139 | } | ||||
140 | return 1; | ||||
141 | } | ||||
142 | |||||
143 | if ($types[0] eq 'array') { | ||||
144 | return 0 if @$x != @$y; | ||||
145 | foreach my $idx (0 .. $x->$#*) { | ||||
146 | $state->{path} = $path.'/'.$idx; | ||||
147 | return 0 if not is_equal($x->[$idx], $y->[$idx], $state); | ||||
148 | } | ||||
149 | return 1; | ||||
150 | } | ||||
151 | |||||
152 | return 0; # should never get here | ||||
153 | } | ||||
154 | |||||
155 | # checks array elements for uniqueness. short-circuits on first pair of matching elements | ||||
156 | # if second arrayref is provided, it is populated with the indices of identical items | ||||
157 | 1920 | 394µs | # spent 148ms (18.7+129) within JSON::Schema::Modern::Utilities::is_elements_unique which was called 640 times, avg 231µs/call:
# 288 times (9.20ms+64.3ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 213 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 255µs/call
# 275 times (8.67ms+61.9ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 264 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 257µs/call
# 76 times (780µs+2.79ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 51 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 47µs/call
# once (4µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 290 of JSON/Schema/Modern/Vocabulary/Validation.pm | ||
158 | 640 | 1.12ms | foreach my $idx0 (0 .. $array->$#*-1) { | ||
159 | 1141 | 1.46ms | foreach my $idx1 ($idx0+1 .. $array->$#*) { | ||
160 | 7244 | 10.5ms | 7244 | 129ms | if (is_equal($array->[$idx0], $array->[$idx1], { scalarref_booleans => 1 })) { # spent 129ms making 7244 calls to JSON::Schema::Modern::Utilities::is_equal, avg 18µs/call |
161 | push @$equal_indices, $idx0, $idx1 if defined $equal_indices; | ||||
162 | return 0; | ||||
163 | } | ||||
164 | } | ||||
165 | } | ||||
166 | 640 | 1.37ms | return 1; | ||
167 | } | ||||
168 | |||||
169 | # shorthand for creating and appending json pointers | ||||
170 | # the first argument is a a json pointer; remaining arguments are path segments to be encoded and | ||||
171 | # appended | ||||
172 | # spent 1.35s (1.19+155ms) within JSON::Schema::Modern::Utilities::jsonp which was called 221215 times, avg 6µs/call:
# 76007 times (404ms+64.0ms) by JSON::Schema::Modern::Utilities::canonical_uri at line 193, avg 6µs/call
# 71790 times (270ms+24.0ms) by JSON::Schema::Modern::Utilities::A at line 253, avg 4µs/call
# 41707 times (324ms+39.5ms) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 89 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call
# 21824 times (142ms+14.9ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 380 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call
# 4217 times (17.1ms+1.88ms) by JSON::Schema::Modern::Utilities::E at line 216, avg 4µs/call
# 1835 times (11.6ms+3.73ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 457 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 1476 times (8.40ms+2.30ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 421 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call
# 1349 times (9.56ms+1.68ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 55 of JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call
# 713 times (4.06ms+2.52ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 480 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call
# 290 times (2.01ms+272µs) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 167 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 6 times (35µs+6µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 64 of JSON/Schema/Modern/Vocabulary.pm, avg 7µs/call
# once (4µs+2µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 132 of JSON/Schema/Modern/Vocabulary/Core.pm | ||||
173 | 221215 | 1.53s | 469020 | 155ms | return join('/', shift, map s/~/~0/gr =~ s!/!~1!gr, map +(is_plain_arrayref($_) ? @$_ : $_), grep defined, @_); # spent 155ms making 469020 calls to JSON::Schema::Modern::Utilities::CORE:subst, avg 330ns/call |
174 | } | ||||
175 | |||||
176 | # splits a json pointer apart into its path segments | ||||
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) - remember these are hashrefs, not Annotation objects | ||||
183 | 7494 | 1.33ms | # spent 143ms within JSON::Schema::Modern::Utilities::local_annotations which was called 3747 times, avg 38µs/call:
# 3747 times (143ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 119 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 38µs/call | ||
184 | 3747 | 145ms | 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} | ||||
189 | 505032 | 119ms | # spent 6.76s (1.38+5.38) within JSON::Schema::Modern::Utilities::canonical_uri which was called 168344 times, avg 40µs/call:
# 91595 times (522ms+1.97s) by JSON::Schema::Modern::_eval_subschema at line 544 of JSON/Schema/Modern.pm, avg 27µs/call
# 71790 times (799ms+3.19s) by JSON::Schema::Modern::Utilities::A at line 250, avg 56µs/call
# 4217 times (45.2ms+185ms) by JSON::Schema::Modern::Utilities::E at line 213, avg 55µs/call
# 727 times (11.4ms+33.8ms) by JSON::Schema::Modern::Document::OpenAPI::_traverse_schema at line 218 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 62µs/call
# 15 times (80µs+187µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 162 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 18µs/call | ||
190 | 168344 | 139ms | return $state->{initial_schema_uri} if not @extra_path and not length($state->{schema_path}); | ||
191 | 126625 | 40.8ms | splice(@extra_path, -1, 1, $extra_path[-1]->@*) if @extra_path and is_plain_arrayref($extra_path[-1]); | ||
192 | 126625 | 159ms | 126625 | 4.67s | my $uri = $state->{initial_schema_uri}->clone; # spent 4.67s making 126625 calls to Mojo::URL::clone, avg 37µs/call |
193 | 126625 | 297ms | 202632 | 591ms | my $fragment = ($uri->fragment//'').(@extra_path ? jsonp($state->{schema_path}, @extra_path) : $state->{schema_path}); # spent 468ms making 76007 calls to JSON::Schema::Modern::Utilities::jsonp, avg 6µs/call
# spent 123ms making 126625 calls to Mojo::URL::fragment, avg 970ns/call |
194 | 126625 | 27.9ms | undef $fragment if not length($fragment); | ||
195 | 126625 | 83.8ms | 126625 | 118ms | $uri->fragment($fragment); # spent 118ms making 126625 calls to Mojo::URL::fragment, avg 929ns/call |
196 | 126625 | 234ms | $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.88ms | # spent 1.24s (128ms+1.11) within JSON::Schema::Modern::Utilities::E which was called 4217 times, avg 293µs/call:
# 1438 times (47.6ms+380ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 273 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 297µs/call
# 1115 times (38.4ms+315ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 73 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 317µs/call
# 799 times (23.1ms+210ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 97 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 292µs/call
# 799 times (17.2ms+183ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 392 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 251µs/call
# 66 times (2.01ms+18.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum at line 88 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 312µs/call | ||
209 | 4217 | 1.36ms | croak 'E called in void context' if not defined wantarray; | ||
210 | |||||
211 | # sometimes the keyword shouldn't be at the very end of the schema path | ||||
212 | my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix}) | ||||
213 | 4217 | 27.5ms | 8434 | 392ms | ->to_abs($state->{effective_base_uri}); # spent 231ms making 4217 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 55µs/call
# spent 161ms making 4217 calls to Mojo::URL::to_abs, avg 38µs/call |
214 | |||||
215 | my $keyword_location = $state->{traversed_schema_path} | ||||
216 | 4217 | 8.99ms | 4217 | 19.0ms | .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix}); # spent 19.0ms making 4217 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call |
217 | |||||
218 | 4217 | 17.0ms | 8434 | 440ms | undef $uri if $uri eq '' and $keyword_location eq '' # spent 437ms making 4217 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 104µs/call
# spent 2.84ms making 4217 calls to Mojo::URL::fragment, avg 675ns/call |
219 | or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq ''; | ||||
220 | |||||
221 | push $state->{errors}->@*, JSON::Schema::Modern::Error->new( | ||||
222 | keyword => $state->{keyword}, | ||||
223 | instance_location => $state->{data_path}, | ||||
224 | keyword_location => $keyword_location, | ||||
225 | defined $uri ? ( absolute_keyword_location => $uri ) : (), | ||||
226 | error => @args ? sprintf($error_string, @args) : $error_string, | ||||
227 | 4217 | 32.4ms | 4217 | 256ms | $state->{exception} ? ( exception => $state->{exception} ) : (), # spent 256ms making 4217 calls to JSON::Schema::Modern::Error::new, avg 61µs/call |
228 | ); | ||||
229 | |||||
230 | 4217 | 12.8ms | return 0; | ||
231 | } | ||||
232 | |||||
233 | # shorthand for creating annotations | ||||
234 | # uses these keys from $state: | ||||
235 | # - initial_schema_uri | ||||
236 | # - keyword | ||||
237 | # - data_path | ||||
238 | # - traversed_schema_path | ||||
239 | # - schema_path | ||||
240 | # - _schema_path_suffix | ||||
241 | # - annotations | ||||
242 | # - collect_annotations | ||||
243 | 215376 | 44.7ms | # spent 5.16s (875ms+4.28) within JSON::Schema::Modern::Utilities::A which was called 71792 times, avg 72µs/call:
# 32214 times (344ms+1.84s) by JSON::Schema::Modern::Utilities::annotate_self at line 346, avg 68µs/call
# 28612 times (392ms+1.78s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 391 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 76µs/call
# 3747 times (34.1ms+203ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 147 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 63µs/call
# 3369 times (52.6ms+223ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 433 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 82µs/call
# 2167 times (32.9ms+137ms) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_eval_keyword_format at line 40 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 79µs/call
# 977 times (9.83ms+53.8ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 468 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 65µs/call
# 643 times (9.23ms+42.1ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 325 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 80µs/call
# 63 times (1.01ms+4.18ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 180 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 82µs/call | ||
244 | 71792 | 52.4ms | return 1 if not $state->{collect_annotations} or $state->{spec_version} eq 'draft7'; | ||
245 | |||||
246 | # we store the absolute uri in unresolved form until needed, | ||||
247 | # and perform the rest of the calculations later. | ||||
248 | |||||
249 | my $uri = [ canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix}), | ||||
250 | 71790 | 196ms | 71790 | 3.99s | $state->{effective_base_uri} ]; # spent 3.99s making 71790 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 56µs/call |
251 | |||||
252 | my $keyword_location = $state->{traversed_schema_path} | ||||
253 | 71790 | 136ms | 71790 | 294ms | .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix}); # spent 294ms making 71790 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call |
254 | |||||
255 | push $state->{annotations}->@*, { | ||||
256 | keyword => $state->{keyword}, | ||||
257 | instance_location => $state->{data_path}, | ||||
258 | keyword_location => $keyword_location, | ||||
259 | # we calculate absolute_keyword_location when instantiating the Annotation object for Result | ||||
260 | _uri => $uri, | ||||
261 | annotation => $annotation, | ||||
262 | 71790 | 228ms | $state->{_unknown} ? ( unknown => 1 ) : (), | ||
263 | }; | ||||
264 | |||||
265 | 71790 | 150ms | 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. | ||||
272 | sub 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 | |||||
278 | 3 | 1µ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 | ||
279 | 1 | 0s | croak 'assert_keyword_exists called in void context' if not defined wantarray; | ||
280 | 1 | 1µs | return E($state, '%s keyword is required', $state->{keyword}) if not exists $schema->{$state->{keyword}}; | ||
281 | 1 | 3µs | return 1; | ||
282 | } | ||||
283 | |||||
284 | 14360 | 2.19ms | # spent 44.2ms (16.2+28.0) within JSON::Schema::Modern::Utilities::assert_keyword_type which was called 3590 times, avg 12µs/call:
# 1306 times (6.17ms+12.7ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 54 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call
# 732 times (3.39ms+6.70ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 203 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 14µs/call
# 402 times (2.19ms+1.29ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 50 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call
# 275 times (1.03ms+499µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 261 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 6µs/call
# 150 times (487µs+1.55ms) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_deprecated at line 55 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 14µs/call
# 131 times (501µs+825µs) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_title at line 38 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 10µs/call
# 118 times (545µs+982µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_comment at line 285 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 13µs/call
# 87 times (276µs+1.02ms) by JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer at line 318 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 15µs/call
# 76 times (291µs+169µs) by JSON::Schema::Modern::Vocabulary::traverse_array_schemas at line 38 of JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call
# 69 times (282µs+567µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call
# 60 times (225µs+110µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum at line 78 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 6µs/call
# 50 times (181µs+246µs) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_traverse_keyword_format at line 35 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 9µs/call
# 31 times (150µs+340µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 265 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 16µs/call
# 30 times (72µs+239µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_number at line 313 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 10µs/call
# 15 times (79µs+234µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 112 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 21µs/call
# 15 times (58µs+185µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 153 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 16µs/call
# 14 times (111µs+266µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 27µs/call
# 11 times (48µs+28µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 256 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 7µs/call
# 6 times (28µs+6µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 61 of JSON/Schema/Modern/Vocabulary.pm, avg 6µs/call
# 6 times (11µs+8µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 397 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call
# 3 times (10µs+41µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems at line 206 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 17µs/call
# once (9µs+26µs) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm
# once (3µs+4µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding at line 39 of JSON/Schema/Modern/Vocabulary/Content.pm
# once (1µs+2µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 277 of JSON/Schema/Modern/Vocabulary/Validation.pm | ||
285 | 3590 | 776µs | croak 'assert_keyword_type called in void context' if not defined wantarray; | ||
286 | 3590 | 2.78ms | my $value = $schema->{$state->{keyword}}; | ||
287 | 3590 | 652µ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' | ||||
291 | 3590 | 775µs | if exists $state->{_schema_path_suffix}; | ||
292 | 3590 | 9.95ms | 3590 | 28.0ms | return 1 if is_type($type, $value); # spent 28.0ms making 3590 calls to JSON::Schema::Modern::Utilities::is_type, avg 8µs/call |
293 | E($state, '%s %s is not a%s %s', $state->{keyword}, $thing, ($type =~ /^[aeiou]/ ? 'n' : ''), $type); | ||||
294 | } | ||||
295 | |||||
296 | 225 | 41µs | # spent 3.24ms (1.15+2.10) within JSON::Schema::Modern::Utilities::assert_pattern which was called 75 times, avg 43µs/call:
# 69 times (1.06ms+1.95ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 178 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 44µs/call
# 6 times (88µs+145µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 401 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 39µs/call | ||
297 | 75 | 52µs | croak 'assert_pattern called in void context' if not defined wantarray; | ||
298 | 75 | 32µs | try { | ||
299 | 75 | 330µs | local $SIG{__WARN__} = sub { die @_ }; | ||
300 | 75 | 2.73ms | 150 | 2.10ms | qr/$pattern/; # spent 1.94ms making 75 calls to JSON::Schema::Modern::Utilities::CORE:regcomp, avg 26µs/call
# spent 152µs making 75 calls to JSON::Schema::Modern::Utilities::CORE:qr, avg 2µs/call |
301 | } | ||||
302 | catch ($e) { return E($state, $e); }; | ||||
303 | 75 | 162µs | return 1; | ||
304 | } | ||||
305 | |||||
306 | # this is only suitable for checking URIs within schemas themselves | ||||
307 | 2238 | 310µs | # spent 162ms (10.4+152) within JSON::Schema::Modern::Utilities::assert_uri_reference which was called 746 times, avg 218µs/call:
# 732 times (10.2ms+150ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 203 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 218µs/call
# 14 times (201µs+2.38ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 184µs/call | ||
308 | 746 | 227µs | croak 'assert_uri_reference called in void context' if not defined wantarray; | ||
309 | |||||
310 | 746 | 454µ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 | ||||
313 | 746 | 12.7ms | 5108 | 152ms | if fc(Mojo::URL->new($string)->to_unsafe_string) ne fc($string) # spent 85.8ms making 746 calls to Mojo::URL::new, avg 115µs/call
# spent 61.0ms making 746 calls to Mojo::URL::to_unsafe_string, avg 82µs/call
# spent 5.14ms making 3616 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 1µs/call |
314 | or $string =~ /[^[:ascii:]]/ | ||||
315 | or $string =~ /#/ | ||||
316 | and $string !~ m{#$} # empty fragment | ||||
317 | and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment | ||||
318 | and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment | ||||
319 | |||||
320 | 746 | 1.46ms | return 1; | ||
321 | } | ||||
322 | |||||
323 | # this is only suitable for checking URIs within schemas themselves | ||||
324 | 184 | 28µs | # spent 6.63ms (613µs+6.02) within JSON::Schema::Modern::Utilities::assert_uri which was called 46 times, avg 144µs/call:
# 31 times (375µs+3.79ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 266 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 134µs/call
# 15 times (238µs+2.23ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 112 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 164µs/call | ||
325 | 46 | 18µs | croak 'assert_uri called in void context' if not defined wantarray; | ||
326 | |||||
327 | 46 | 24µs | my $string = $override // $schema->{$state->{keyword}}; | ||
328 | 46 | 42µs | 46 | 1.97ms | my $uri = Mojo::URL->new($string); # spent 1.97ms making 46 calls to Mojo::URL::new, avg 43µs/call |
329 | |||||
330 | 46 | 295µs | 184 | 4.05ms | return E($state, '"%s" is not a valid URI', $string) # spent 3.88ms making 46 calls to Mojo::URL::to_unsafe_string, avg 84µs/call
# spent 148µs making 46 calls to Mojo::URL::is_abs, avg 3µs/call
# spent 22µs making 92 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 239ns/call |
331 | # see also uri format sub | ||||
332 | if fc($uri->to_unsafe_string) ne fc($string) | ||||
333 | or $string =~ /[^[:ascii:]]/ | ||||
334 | or not $uri->is_abs | ||||
335 | or $string =~ /#/ | ||||
336 | and $string !~ m{#$} # empty fragment | ||||
337 | and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment | ||||
338 | and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment | ||||
339 | |||||
340 | 46 | 142µs | return 1; | ||
341 | } | ||||
342 | |||||
343 | # produces an annotation whose value is the same as that of the current keyword | ||||
344 | 96642 | 15.3ms | # spent 2.39s (146ms+2.24) within JSON::Schema::Modern::Utilities::annotate_self which was called 32214 times, avg 74µs/call:
# 32214 times (146ms+2.24s) by JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_title at line 43 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 74µs/call | ||
345 | A($state, is_ref($schema->{$state->{keyword}}) ? dclone($schema->{$state->{keyword}}) | ||||
346 | 32214 | 170ms | 33327 | 2.24s | : $schema->{$state->{keyword}}); # spent 2.19s making 32214 calls to JSON::Schema::Modern::Utilities::A, avg 68µs/call
# spent 55.3ms making 1113 calls to Storable::dclone, avg 50µs/call |
347 | } | ||||
348 | |||||
349 | sub 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 | |||||
354 | 1 | 6µs | 1; | ||
355 | |||||
356 | 1 | 30µs | 1 | 207µs | __END__ # spent 207µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 5.21ms within JSON::Schema::Modern::Utilities::CORE:match which was called 3904 times, avg 1µs/call:
# 3616 times (5.14ms+0s) by JSON::Schema::Modern::Utilities::assert_uri_reference at line 313, avg 1µs/call
# 109 times (35µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 78, avg 321ns/call
# 92 times (22µs+0s) by JSON::Schema::Modern::Utilities::assert_uri at line 330, avg 239ns/call
# 87 times (21µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 83, avg 241ns/call | |||||
# spent 152µs within JSON::Schema::Modern::Utilities::CORE:qr which was called 75 times, avg 2µs/call:
# 75 times (152µs+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 300, avg 2µs/call | |||||
# spent 1.94ms within JSON::Schema::Modern::Utilities::CORE:regcomp which was called 75 times, avg 26µs/call:
# 75 times (1.94ms+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 300, avg 26µs/call | |||||
# spent 155ms within JSON::Schema::Modern::Utilities::CORE:subst which was called 469020 times, avg 330ns/call:
# 469020 times (155ms+0s) by JSON::Schema::Modern::Utilities::jsonp at line 173, avg 330ns/call | |||||
sub JSON::Schema::Modern::Utilities::__ANON__; # xsub |