Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Utilities.pm |
Statements | Executed 4032517 statements in 5.67s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
168591 | 5 | 4 | 1.74s | 8.21s | canonical_uri | JSON::Schema::Modern::Utilities::
72039 | 7 | 4 | 1.48s | 17.8s | A | JSON::Schema::Modern::Utilities::
314039 | 13 | 4 | 1.22s | 1.38s | jsonp | JSON::Schema::Modern::Utilities::
3747 | 1 | 1 | 499ms | 805ms | local_annotations | JSON::Schema::Modern::Utilities::
163180 | 5 | 4 | 445ms | 612ms | get_type | JSON::Schema::Modern::Utilities::
74094 | 23 | 5 | 241ms | 338ms | is_type | JSON::Schema::Modern::Utilities::
469978 | 1 | 1 | 156ms | 156ms | CORE:subst (opcode) | JSON::Schema::Modern::Utilities::
32214 | 1 | 1 | 147ms | 7.88s | annotate_self | JSON::Schema::Modern::Utilities::
4217 | 5 | 2 | 113ms | 1.14s | E | JSON::Schema::Modern::Utilities::
16540 | 6 | 2 | 92.5ms | 331ms | is_equal (recurses: max depth 2, inclusive time 93µs) | JSON::Schema::Modern::Utilities::
701 | 5 | 1 | 18.4ms | 147ms | is_elements_unique | JSON::Schema::Modern::Utilities::
3585 | 24 | 8 | 18.2ms | 44.3ms | assert_keyword_type | JSON::Schema::Modern::Utilities::
739 | 2 | 1 | 12.3ms | 158ms | assert_uri_reference | JSON::Schema::Modern::Utilities::
3869 | 4 | 1 | 5.13ms | 5.13ms | CORE:match (opcode) | JSON::Schema::Modern::Utilities::
76 | 1 | 1 | 1.92ms | 1.92ms | CORE:regcomp (opcode) | JSON::Schema::Modern::Utilities::
76 | 2 | 2 | 1.23ms | 3.22ms | assert_pattern | JSON::Schema::Modern::Utilities::
46 | 2 | 1 | 634µs | 7.05ms | assert_uri | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 62µs | 923µs | BEGIN@10 | JSON::Schema::Modern::Utilities::
76 | 1 | 1 | 60µs | 60µs | CORE:qr (opcode) | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 28µs | 31µs | BEGIN@1.158 | JSON::Schema::Modern::
1 | 1 | 1 | 22µs | 23µs | BEGIN@23 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 16µs | 16µs | BEGIN@24 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 15µs | 53µs | BEGIN@12 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 15µs | 57µs | BEGIN@18 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 15µs | 77µs | BEGIN@53 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 13µs | 32µs | BEGIN@13 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 12µs | 24µs | BEGIN@14 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 11µs | 125µs | BEGIN@11 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 11µs | 11µs | BEGIN@9 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 10µs | 22µs | BEGIN@15 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 10µs | 37µs | BEGIN@19 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 10µs | 19µs | BEGIN@21 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 8µs | 36µs | BEGIN@2.159 | JSON::Schema::Modern::
1 | 1 | 1 | 8µs | 10µs | BEGIN@16 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 8µs | 15µs | BEGIN@27 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 7µs | 30µs | BEGIN@22 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 7µs | 194µs | BEGIN@25 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 6µs | 39µs | BEGIN@17 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 6µs | 19µs | BEGIN@20 | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 6µs | 6µs | assert_keyword_exists | JSON::Schema::Modern::Utilities::
1 | 1 | 1 | 3µs | 3µs | BEGIN@52 | JSON::Schema::Modern::Utilities::
3 | 2 | 1 | 1µs | 1µs | CORE:sort (opcode) | JSON::Schema::Modern::Utilities::
2 | 2 | 1 | 1µs | 1µs | __ANON__ (xsub) | JSON::Schema::Modern::Utilities::
0 | 0 | 0 | 0s | 0s | __ANON__[:293] | 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 | 35µs | 2 | 34µs | # spent 31µs (28+3) within JSON::Schema::Modern::BEGIN@1.158 which was called:
# once (28µs+3µs) by JSON::Schema::Modern::BEGIN@36 at line 1 # spent 31µs making 1 call to JSON::Schema::Modern::BEGIN@1.158
# spent 3µs making 1 call to strict::import |
2 | 2 | 45µs | 2 | 64µs | # spent 36µs (8+28) within JSON::Schema::Modern::BEGIN@2.159 which was called:
# once (8µs+28µs) by JSON::Schema::Modern::BEGIN@36 at line 2 # spent 36µs making 1 call to JSON::Schema::Modern::BEGIN@2.159
# spent 28µ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.552'; | ||
8 | |||||
9 | 2 | 39µ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 | 39µs | 3 | 1.78ms | # spent 923µs (62+861) within JSON::Schema::Modern::Utilities::BEGIN@10 which was called:
# once (62µs+861µs) by JSON::Schema::Modern::BEGIN@36 at line 10 # spent 923µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@10
# spent 839µs making 1 call to strictures::import
# spent 21µs making 1 call to strictures::VERSION |
11 | 2 | 46µs | 2 | 239µs | # spent 125µs (11+114) within JSON::Schema::Modern::Utilities::BEGIN@11 which was called:
# once (11µs+114µs) by JSON::Schema::Modern::BEGIN@36 at line 11 # spent 125µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@11
# spent 114µs making 1 call to experimental::import |
12 | 2 | 33µs | 2 | 56µs | # spent 53µs (15+38) within JSON::Schema::Modern::Utilities::BEGIN@12 which was called:
# once (15µs+38µs) by JSON::Schema::Modern::BEGIN@36 at line 12 # spent 53µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@12
# spent 3µs making 1 call to if::import |
13 | 2 | 28µs | 2 | 34µs | # spent 32µs (13+19) within JSON::Schema::Modern::Utilities::BEGIN@13 which was called:
# once (13µs+19µs) by JSON::Schema::Modern::BEGIN@36 at line 13 # spent 32µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@13
# spent 2µs making 1 call to if::unimport |
14 | 2 | 26µs | 2 | 25µs | # spent 24µs (12+12) within JSON::Schema::Modern::Utilities::BEGIN@14 which was called:
# once (12µs+12µs) by JSON::Schema::Modern::BEGIN@36 at line 14 # spent 24µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@14
# spent 1µs making 1 call to if::unimport |
15 | 2 | 23µs | 2 | 24µs | # spent 22µs (10+12) within JSON::Schema::Modern::Utilities::BEGIN@15 which was called:
# once (10µs+12µs) by JSON::Schema::Modern::BEGIN@36 at line 15 # spent 22µ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 | 24µs | 2 | 72µs | # spent 39µs (6+33) within JSON::Schema::Modern::Utilities::BEGIN@17 which was called:
# once (6µs+33µs) by JSON::Schema::Modern::BEGIN@36 at line 17 # spent 39µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@17
# spent 33µs making 1 call to Exporter::import |
18 | 3 | 43µs | 3 | 99µs | # spent 57µs (15+42) within JSON::Schema::Modern::Utilities::BEGIN@18 which was called:
# once (15µs+42µs) by JSON::Schema::Modern::BEGIN@36 at line 18 # spent 57µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@18
# spent 34µs making 1 call to Exporter::import
# spent 8µs making 1 call to UNIVERSAL::VERSION |
19 | 3 | 32µs | 3 | 64µs | # spent 37µs (10+27) within JSON::Schema::Modern::Utilities::BEGIN@19 which was called:
# once (10µs+27µs) by JSON::Schema::Modern::BEGIN@36 at line 19 # spent 37µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@19
# spent 22µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
20 | 2 | 16µs | 2 | 32µs | # spent 19µs (6+13) within JSON::Schema::Modern::Utilities::BEGIN@20 which was called:
# once (6µs+13µs) by JSON::Schema::Modern::BEGIN@36 at line 20 # spent 19µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@20
# spent 13µs making 1 call to Exporter::import |
21 | 2 | 21µs | 2 | 28µs | # spent 19µs (10+9) within JSON::Schema::Modern::Utilities::BEGIN@21 which was called:
# once (10µs+9µs) by JSON::Schema::Modern::BEGIN@36 at line 21 # spent 19µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@21
# spent 9µs making 1 call to Exporter::import |
22 | 2 | 25µs | 2 | 53µs | # spent 30µs (7+23) within JSON::Schema::Modern::Utilities::BEGIN@22 which was called:
# once (7µs+23µs) by JSON::Schema::Modern::BEGIN@36 at line 22 # spent 30µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@22
# spent 23µs making 1 call to Feature::Compat::Try::import |
23 | 2 | 39µs | 2 | 24µs | # spent 23µs (22+1) within JSON::Schema::Modern::Utilities::BEGIN@23 which was called:
# once (22µs+1µs) by JSON::Schema::Modern::BEGIN@36 at line 23 # spent 23µ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 | 31µs | 2 | 16µs | # spent 16µs within JSON::Schema::Modern::Utilities::BEGIN@24 which was called:
# once (16µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 24 # spent 16µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@24
# spent 0s making 1 call to JSON::Schema::Modern::Utilities::__ANON__ |
25 | 2 | 30µs | 2 | 381µs | # spent 194µs (7+187) within JSON::Schema::Modern::Utilities::BEGIN@25 which was called:
# once (7µs+187µs) by JSON::Schema::Modern::BEGIN@36 at line 25 # spent 194µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@25
# spent 187µs making 1 call to namespace::clean::import |
26 | |||||
27 | 2 | 53µs | 2 | 22µs | # spent 15µs (8+7) within JSON::Schema::Modern::Utilities::BEGIN@27 which was called:
# once (8µs+7µs) by JSON::Schema::Modern::BEGIN@36 at line 27 # spent 15µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@27
# spent 7µ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 | 26µs | 1 | 3µs | # spent 3µs within JSON::Schema::Modern::Utilities::BEGIN@52 which was called:
# once (3µs+0s) by JSON::Schema::Modern::BEGIN@36 at line 52 # spent 3µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@52 |
53 | 2 | 2.65ms | 4 | 139µs | # spent 77µs (15+62) within JSON::Schema::Modern::Utilities::BEGIN@53 which was called:
# once (15µs+62µs) by JSON::Schema::Modern::BEGIN@36 at line 53 # spent 77µs making 1 call to JSON::Schema::Modern::Utilities::BEGIN@53
# spent 59µs making 1 call to constant::import
# spent 2µs making 1 call to JSON::PP::false
# spent 1µs making 1 call to JSON::PP::true |
54 | |||||
55 | 222282 | 47.7ms | # spent 338ms (241+97.6) within JSON::Schema::Modern::Utilities::is_type which was called 74094 times, avg 5µs/call:
# 32492 times (100ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 405 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call
# 10587 times (34.1ms+56.4ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 414 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call
# 4795 times (12.4ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 270 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 3µs/call
# 3747 times (7.72ms+0s) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 122 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 2µs/call
# 3616 times (11.1ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 452 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call
# 3585 times (19.1ms+6.97ms) by JSON::Schema::Modern::Utilities::assert_keyword_type at line 286, avg 7µs/call
# 2269 times (7.32ms+14.5ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 460 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 10µs/call
# 1835 times (6.20ms+9.44ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 501 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 9µs/call
# 1758 times (5.85ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 328 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call
# 1632 times (5.41ms+7.25ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 336 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 1604 times (14.0ms+1.79ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 181 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 10µs/call
# 1403 times (2.02ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 212 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 1µs/call
# 1244 times (3.08ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems at line 201 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call
# 977 times (2.43ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 490 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call
# 775 times (3.31ms+531µs) by List::Util::any at line 264 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call
# 627 times (1.74ms+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 530 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 3µs/call
# 485 times (1.12ms+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties at line 255 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 2µs/call
# 305 times (580µs+0s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 172 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 2µs/call
# 262 times (2.08ms+596µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern at line 184 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 10µs/call
# 79 times (867µs+69µs) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum at line 147 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call
# 15 times (21µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_maxProperties at line 246 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 1µs/call
# once (5µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 287 of JSON/Schema/Modern/Vocabulary/Validation.pm
# once (1µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 283 of JSON/Schema/Modern/Vocabulary/Validation.pm | ||
56 | 74094 | 18.6ms | if ($type eq 'null') { | ||
57 | return !(defined $value); | ||||
58 | } | ||||
59 | 74094 | 102ms | 16507 | 89.2ms | if ($type eq 'boolean') { # spent 89.2ms making 16507 calls to JSON::MaybeXS::is_bool, avg 5µs/call |
60 | return is_bool($value); | ||||
61 | } | ||||
62 | 57587 | 128ms | if ($type eq 'object') { | ||
63 | return is_plain_hashref($value); | ||||
64 | } | ||||
65 | 10101 | 12.9ms | if ($type eq 'array') { | ||
66 | return is_plain_arrayref($value); | ||||
67 | } | ||||
68 | |||||
69 | 5282 | 1.90ms | if ($type eq 'string' or $type eq 'number' or $type eq 'integer') { | ||
70 | 5282 | 1.28ms | return 0 if not defined $value; | ||
71 | 5282 | 26.3ms | 10564 | 8.34ms | my $flags = B::svref_2object(\$value)->FLAGS; # spent 5.77ms making 5282 calls to B::svref_2object, avg 1µs/call
# spent 2.57ms making 5282 calls to B::SV::FLAGS, avg 486ns/call |
72 | |||||
73 | 5282 | 11.3ms | if ($type eq 'string') { | ||
74 | return !is_ref($value) && $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK)); | ||||
75 | } | ||||
76 | |||||
77 | 196 | 129µs | if ($type eq 'number') { | ||
78 | 109 | 461µs | 109 | 28µs | return ref($value) =~ /^Math::Big(?:Int|Float)$/ # spent 28µs making 109 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 257ns/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 | 357µs | 87 | 20µs | return ref($value) =~ /^Math::Big(?:Int|Float)$/ && $value->is_int # spent 20µs making 87 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 230ns/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 | 326360 | 51.7ms | # spent 612ms (445+167) within JSON::Schema::Modern::Utilities::get_type which was called 163180 times, avg 4µs/call:
# 91595 times (179ms+0s) by JSON::Schema::Modern::_eval_subschema at line 513 of JSON/Schema/Modern.pm, avg 2µs/call
# 35648 times (113ms+73.0ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 62 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call
# 33080 times (147ms+90.8ms) by JSON::Schema::Modern::Utilities::is_equal at line 120, avg 7µs/call
# 2856 times (5.81ms+3.22ms) by JSON::Schema::Modern::_traverse_subschema at line 435 of JSON/Schema/Modern.pm, avg 3µs/call
# once (4µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 89 of JSON/Schema/Modern/Document/OpenAPI.pm | ||
96 | 163180 | 31.3ms | return 'null' if not defined $value; | ||
97 | 163158 | 257ms | return 'object' if is_plain_hashref($value); | ||
98 | 42797 | 7.76ms | return 'array' if is_plain_arrayref($value); | ||
99 | 41690 | 43.0ms | 41690 | 123ms | return 'boolean' if is_bool($value); # spent 123ms making 41690 calls to JSON::MaybeXS::is_bool, avg 3µs/call |
100 | |||||
101 | 36883 | 4.57ms | 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 | 36883 | 134ms | 73766 | 44.2ms | my $flags = B::svref_2object(\$value)->FLAGS; # spent 30.7ms making 36883 calls to B::svref_2object, avg 833ns/call
# spent 13.5ms making 36883 calls to B::SV::FLAGS, avg 365ns/call |
106 | 36883 | 56.8ms | return 'string' if $flags & B::SVf_POK && !($flags & (B::SVf_IOK | B::SVf_NOK)); | ||
107 | 139 | 428µ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 | 66160 | 11.3ms | # spent 331ms (92.5+238) within JSON::Schema::Modern::Utilities::is_equal which was called 16540 times, avg 20µs/call:
# 7835 times (36.1ms+93.0ms) by JSON::Schema::Modern::Utilities::is_elements_unique at line 160, avg 16µs/call
# 7494 times (43.1ms+115ms) by List::Util::any at line 86 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 21µs/call
# 1208 times (13.3ms+29.9ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 96 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 36µs/call
# once (17µs+-17µs) by JSON::Schema::Modern::Utilities::is_equal at line 135
# once (6µs+-6µs) by JSON::Schema::Modern::Utilities::is_equal at line 138
# once (4µs+-4µs) by JSON::Schema::Modern::Utilities::is_equal at line 147 | ||
118 | 16540 | 5.66ms | $state->{path} //= ''; | ||
119 | |||||
120 | 16540 | 23.9ms | 33080 | 238ms | my @types = map get_type($_), $x, $y; # spent 238ms making 33080 calls to JSON::Schema::Modern::Utilities::get_type, avg 7µs/call |
121 | |||||
122 | 16540 | 4.13ms | if ($state->{scalarref_booleans}) { | ||
123 | 7836 | 814µs | ($x, $types[0]) = (0+!!$$x, 'boolean') if $types[0] eq 'reference to SCALAR'; | ||
124 | 7836 | 789µs | ($y, $types[1]) = (0+!!$$y, 'boolean') if $types[1] eq 'reference to SCALAR'; | ||
125 | } | ||||
126 | |||||
127 | 16540 | 3.87ms | return 0 if $types[0] ne $types[1]; | ||
128 | 16030 | 2.28ms | return 1 if $types[0] eq 'null'; | ||
129 | 16030 | 25.2ms | return $x eq $y if $types[0] eq 'string'; | ||
130 | 181 | 1.34ms | 348 | 499µs | return $x == $y if grep $types[0] eq $_, qw(boolean number integer); # spent 499µs making 348 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:7], avg 1µs/call |
131 | |||||
132 | 2 | 15µs | my $path = $state->{path}; | ||
133 | 2 | 3µs | if ($types[0] eq 'object') { | ||
134 | 1 | 7µs | return 0 if keys %$x != keys %$y; | ||
135 | 1 | 13µs | 3 | 1µs | return 0 if not is_equal([ sort keys %$x ], [ sort keys %$y ]); # spent 1µs making 2 calls to JSON::Schema::Modern::Utilities::CORE:sort, avg 500ns/call
# spent 48µs making 1 call to JSON::Schema::Modern::Utilities::is_equal, recursion: max depth 1, sum of overlapping time 48µs |
136 | 1 | 2µs | 1 | 0s | foreach my $property (sort keys %$x) { # spent 0s making 1 call to JSON::Schema::Modern::Utilities::CORE:sort |
137 | 1 | 1µs | 1 | 8µs | $state->{path} = jsonp($path, $property); # spent 8µs making 1 call to JSON::Schema::Modern::Utilities::jsonp |
138 | 1 | 4µs | 1 | 0s | return 0 if not is_equal($x->{$property}, $y->{$property}, $state); # spent 17µs making 1 call to JSON::Schema::Modern::Utilities::is_equal, recursion: max depth 1, sum of overlapping time 17µs |
139 | } | ||||
140 | return 1; | ||||
141 | } | ||||
142 | |||||
143 | 1 | 1µs | if ($types[0] eq 'array') { | ||
144 | 1 | 0s | return 0 if @$x != @$y; | ||
145 | 1 | 1µs | foreach my $idx (0 .. $x->$#*) { | ||
146 | 1 | 1µs | $state->{path} = $path.'/'.$idx; | ||
147 | 1 | 1µs | 1 | 0s | return 0 if not is_equal($x->[$idx], $y->[$idx], $state); # spent 28µs making 1 call to JSON::Schema::Modern::Utilities::is_equal, recursion: max depth 2, sum of overlapping time 28µs |
148 | } | ||||
149 | 1 | 3µs | 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 | 2103 | 396µs | # spent 147ms (18.4+129) within JSON::Schema::Modern::Utilities::is_elements_unique which was called 701 times, avg 210µs/call:
# 288 times (8.32ms+60.1ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems at line 214 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 238µs/call
# 276 times (7.68ms+56.6ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 265 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 233µs/call
# 76 times (746µs+2.41ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 51 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 42µs/call
# 60 times (1.64ms+9.88ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum at line 79 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 192µs/call
# once (3µs+0s) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 291 of JSON/Schema/Modern/Vocabulary/Validation.pm | ||
158 | 701 | 1.26ms | foreach my $idx0 (0 .. $array->$#*-1) { | ||
159 | 1300 | 1.28ms | foreach my $idx1 ($idx0+1 .. $array->$#*) { | ||
160 | 7835 | 9.54ms | 7835 | 129ms | if (is_equal($array->[$idx0], $array->[$idx1], { scalarref_booleans => 1 })) { # spent 129ms making 7835 calls to JSON::Schema::Modern::Utilities::is_equal, avg 16µs/call |
161 | push @$equal_indices, $idx0, $idx1 if defined $equal_indices; | ||||
162 | return 0; | ||||
163 | } | ||||
164 | } | ||||
165 | } | ||||
166 | 701 | 1.41ms | return 1; | ||
167 | } | ||||
168 | |||||
169 | # shorthand for creating and appending json pointers | ||||
170 | # spent 1.38s (1.22+156ms) within JSON::Schema::Modern::Utilities::jsonp which was called 314039 times, avg 4µs/call:
# 168591 times (505ms+54.9ms) by JSON::Schema::Modern::Utilities::canonical_uri at line 189, avg 3µs/call
# 72037 times (262ms+31.3ms) by JSON::Schema::Modern::Utilities::A at line 245, avg 4µs/call
# 41707 times (273ms+33.9ms) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 89 of JSON/Schema/Modern/Vocabulary.pm, avg 7µs/call
# 20884 times (126ms+12.5ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 421 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 7µs/call
# 4217 times (14.9ms+1.83ms) by JSON::Schema::Modern::Utilities::E at line 211, avg 4µs/call
# 2416 times (14.6ms+3.51ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 467 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 1835 times (10.8ms+3.45ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 508 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 1340 times (10.00ms+1.66ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 55 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call
# 713 times (4.15ms+13.0ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames at line 537 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 24µs/call
# 290 times (2.08ms+288µs) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas at line 181 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 8µs/call
# 7 times (50µs+8µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 64 of JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call
# once (10µs+1000ns) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 123 of JSON/Schema/Modern/Vocabulary/Core.pm
# once (7µs+1000ns) by JSON::Schema::Modern::Utilities::is_equal at line 137 | ||||
171 | 314039 | 1.59s | 469978 | 156ms | return join('/', shift, map s/~/~0/gr =~ s!/!~1!gr, map +(is_plain_arrayref($_) ? @$_ : $_), grep defined, @_); # spent 156ms making 469978 calls to JSON::Schema::Modern::Utilities::CORE:subst, avg 333ns/call |
172 | } | ||||
173 | |||||
174 | # splits a json pointer apart into its path segments | ||||
175 | sub unjsonp ($path) { | ||||
176 | return map s!~0!~!gr =~ s!~1!/!gr, split m!/!, $path; | ||||
177 | } | ||||
178 | |||||
179 | # get all annotations produced for the current instance data location (that are visible to this | ||||
180 | # schema location) | ||||
181 | 7494 | 1.30ms | # spent 805ms (499+306) within JSON::Schema::Modern::Utilities::local_annotations which was called 3747 times, avg 215µs/call:
# 3747 times (499ms+306ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 125 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 215µs/call | ||
182 | 3747 | 251ms | 372479 | 306ms | grep $_->instance_location eq $state->{data_path}, $state->{annotations}->@*; # spent 306ms making 372479 calls to JSON::Schema::Modern::Annotation::instance_location, avg 821ns/call |
183 | } | ||||
184 | |||||
185 | # shorthand for finding the canonical uri of the present schema location | ||||
186 | 505773 | 111ms | # spent 8.21s (1.74+6.47) within JSON::Schema::Modern::Utilities::canonical_uri which was called 168591 times, avg 49µs/call:
# 91595 times (940ms+3.27s) by JSON::Schema::Modern::_eval_subschema at line 506 of JSON/Schema/Modern.pm, avg 46µs/call
# 72037 times (742ms+2.98s) by JSON::Schema::Modern::Utilities::A at line 242, avg 52µs/call
# 4217 times (44.2ms+181ms) by JSON::Schema::Modern::Utilities::E at line 208, avg 53µs/call
# 727 times (11.5ms+33.5ms) by JSON::Schema::Modern::Document::OpenAPI::_traverse_schema at line 218 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 62µs/call
# 15 times (197µs+623µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 153 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 55µs/call | ||
187 | 168591 | 44.0ms | splice(@extra_path, -1, 1, $extra_path[-1]->@*) if @extra_path and is_plain_arrayref($extra_path[-1]); | ||
188 | 168591 | 191ms | 168591 | 5.47s | my $uri = $state->{initial_schema_uri}->clone; # spent 5.47s making 168591 calls to Mojo::URL::clone, avg 32µs/call |
189 | 168591 | 507ms | 505773 | 903ms | $uri->fragment(($uri->fragment//'').jsonp($state->{schema_path}, @extra_path)); # spent 560ms making 168591 calls to JSON::Schema::Modern::Utilities::jsonp, avg 3µs/call
# spent 343ms making 337182 calls to Mojo::URL::fragment, avg 1µs/call |
190 | 168591 | 139ms | 194464 | 98.4ms | $uri->fragment(undef) if not length($uri->fragment); # spent 98.4ms making 194464 calls to Mojo::URL::fragment, avg 506ns/call |
191 | 168591 | 324ms | $uri; | ||
192 | } | ||||
193 | |||||
194 | # shorthand for creating error objects | ||||
195 | # uses these keys from $state: | ||||
196 | # - initial_schema_uri | ||||
197 | # - keyword | ||||
198 | # - data_path | ||||
199 | # - traversed_schema_path | ||||
200 | # - schema_path | ||||
201 | # - _schema_path_suffix | ||||
202 | # - errors | ||||
203 | 16868 | 5.06ms | # spent 1.14s (113ms+1.03) within JSON::Schema::Modern::Utilities::E which was called 4217 times, avg 270µs/call:
# 1438 times (41.6ms+341ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required at line 274 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 266µs/call
# 1115 times (34.2ms+278ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type at line 73 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 280µs/call
# 799 times (19.4ms+197ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const at line 98 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 271µs/call
# 799 times (15.6ms+195ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 436 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 264µs/call
# 66 times (1.79ms+16.4ms) by JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum at line 89 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 275µs/call | ||
204 | 4217 | 1.54ms | croak 'E called in void context' if not defined wantarray; | ||
205 | |||||
206 | # sometimes the keyword shouldn't be at the very end of the schema path | ||||
207 | my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix}) | ||||
208 | 4217 | 23.6ms | 8434 | 380ms | ->to_abs($state->{effective_base_uri}); # spent 225ms making 4217 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 53µs/call
# spent 155ms making 4217 calls to Mojo::URL::to_abs, avg 37µs/call |
209 | |||||
210 | my $keyword_location = $state->{traversed_schema_path} | ||||
211 | 4217 | 8.36ms | 4217 | 16.7ms | .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix}); # spent 16.7ms making 4217 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call |
212 | |||||
213 | 4217 | 14.4ms | 8434 | 394ms | undef $uri if $uri eq '' and $keyword_location eq '' # spent 391ms making 4217 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 93µs/call
# spent 2.35ms making 4217 calls to Mojo::URL::fragment, avg 557ns/call |
214 | or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq ''; | ||||
215 | |||||
216 | push $state->{errors}->@*, JSON::Schema::Modern::Error->new( | ||||
217 | keyword => $state->{keyword}, | ||||
218 | instance_location => $state->{data_path}, | ||||
219 | keyword_location => $keyword_location, | ||||
220 | defined $uri ? ( absolute_keyword_location => $uri ) : (), | ||||
221 | error => @args ? sprintf($error_string, @args) : $error_string, | ||||
222 | 4217 | 28.8ms | 4217 | 237ms | $state->{exception} ? ( exception => $state->{exception} ) : (), # spent 237ms making 4217 calls to JSON::Schema::Modern::Error::new, avg 56µs/call |
223 | ); | ||||
224 | |||||
225 | 4217 | 11.5ms | return 0; | ||
226 | } | ||||
227 | |||||
228 | # shorthand for creating annotations | ||||
229 | # uses these keys from $state: | ||||
230 | # - initial_schema_uri | ||||
231 | # - keyword | ||||
232 | # - data_path | ||||
233 | # - traversed_schema_path | ||||
234 | # - schema_path | ||||
235 | # - _schema_path_suffix | ||||
236 | # - annotations | ||||
237 | # - collect_annotations | ||||
238 | 216117 | 39.3ms | # spent 17.8s (1.48+16.3) within JSON::Schema::Modern::Utilities::A which was called 72039 times, avg 247µs/call:
# 32214 times (608ms+7.09s) by JSON::Schema::Modern::Utilities::annotate_self at line 340, avg 239µs/call
# 28612 times (628ms+6.57s) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties at line 435 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 252µs/call
# 3747 times (69.4ms+885ms) by JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties at line 158 of JSON/Schema/Modern/Vocabulary/Unevaluated.pm, avg 255µs/call
# 3616 times (88.6ms+902ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties at line 482 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 274µs/call
# 2230 times (54.5ms+535ms) by JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format at line 183 of JSON/Schema/Modern/Vocabulary/FormatAssertion.pm, avg 264µs/call
# 977 times (18.0ms+213ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties at line 522 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 237µs/call
# 643 times (14.6ms+150ms) by JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword__items_schema at line 360 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 255µs/call | ||
239 | 72039 | 48.3ms | return 1 if not $state->{collect_annotations} or $state->{spec_version} eq 'draft7'; | ||
240 | |||||
241 | my $uri = canonical_uri($state, $state->{keyword}, $state->{_schema_path_suffix}) | ||||
242 | 72037 | 327ms | 144074 | 6.24s | ->to_abs($state->{effective_base_uri}); # spent 3.73s making 72037 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 52µs/call
# spent 2.52s making 72037 calls to Mojo::URL::to_abs, avg 35µs/call |
243 | |||||
244 | my $keyword_location = $state->{traversed_schema_path} | ||||
245 | 72037 | 147ms | 72037 | 293ms | .jsonp($state->{schema_path}, $state->{keyword}, delete $state->{_schema_path_suffix}); # spent 293ms making 72037 calls to JSON::Schema::Modern::Utilities::jsonp, avg 4µs/call |
246 | |||||
247 | 72037 | 218ms | 144074 | 6.66s | undef $uri if $uri eq '' and $keyword_location eq '' # spent 6.62s making 72037 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 92µs/call
# spent 41.7ms making 72037 calls to Mojo::URL::fragment, avg 579ns/call |
248 | or ($uri->fragment // '') eq $keyword_location and $uri->clone->fragment(undef) eq ''; | ||||
249 | |||||
250 | push $state->{annotations}->@*, JSON::Schema::Modern::Annotation->new( | ||||
251 | keyword => $state->{keyword}, | ||||
252 | instance_location => $state->{data_path}, | ||||
253 | keyword_location => $keyword_location, | ||||
254 | defined $uri ? ( absolute_keyword_location => $uri ) : (), | ||||
255 | annotation => $annotation, | ||||
256 | 72037 | 235ms | 72037 | 3.14s | $state->{_unknown} ? ( unknown => 1 ) : (), # spent 3.14s making 72037 calls to JSON::Schema::Modern::Annotation::new, avg 44µs/call |
257 | ); | ||||
258 | |||||
259 | 72037 | 163ms | return 1; | ||
260 | } | ||||
261 | |||||
262 | # creates an error object, but also aborts evaluation immediately | ||||
263 | # only this error is returned, because other errors on the stack might not actually be "real" | ||||
264 | # errors (consider if we were in the middle of evaluating a "not" or "if"). | ||||
265 | # Therefore this is only appropriate during the evaluation phase, not the traverse phase. | ||||
266 | sub abort ($state, $error_string, @args) { | ||||
267 | ()= E({ %$state, exception => 1 }, $error_string, @args); | ||||
268 | croak 'abort() called during traverse' if $state->{traverse}; | ||||
269 | die pop $state->{errors}->@*; | ||||
270 | } | ||||
271 | |||||
272 | 3 | 0s | # spent 6µs within JSON::Schema::Modern::Utilities::assert_keyword_exists which was called:
# once (6µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm | ||
273 | 1 | 1µs | croak 'assert_keyword_exists called in void context' if not defined wantarray; | ||
274 | 1 | 2µs | return E($state, '%s keyword is required', $state->{keyword}) if not exists $schema->{$state->{keyword}}; | ||
275 | 1 | 4µs | return 1; | ||
276 | } | ||||
277 | |||||
278 | 14340 | 1.93ms | # spent 44.3ms (18.2+26.1) within JSON::Schema::Modern::Utilities::assert_keyword_type which was called 3585 times, avg 12µs/call:
# 1305 times (6.42ms+11.4ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type at line 54 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 14µs/call
# 725 times (4.43ms+6.38ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 194 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 15µs/call
# 401 times (2.30ms+914µs) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 50 of JSON/Schema/Modern/Vocabulary.pm, avg 8µs/call
# 276 times (940µs+417µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required at line 262 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 5µs/call
# 150 times (490µs+1.54ms) 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+732µs) by JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_title at line 38 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 9µs/call
# 118 times (834µs+976µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_comment at line 276 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 15µs/call
# 87 times (253µs+829µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_non_negative_integer at line 319 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 12µs/call
# 77 times (504µs+171µs) by JSON::Schema::Modern::Vocabulary::traverse_array_schemas at line 38 of JSON/Schema/Modern/Vocabulary.pm, avg 9µs/call
# 69 times (372µs+494µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 179 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 13µs/call
# 60 times (290µs+93µ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 (211µs+309µs) by JSON::Schema::Modern::Vocabulary::FormatAnnotation::_traverse_keyword_format at line 35 of JSON/Schema/Modern/Vocabulary/FormatAnnotation.pm, avg 10µs/call
# 31 times (145µs+418µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 256 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 18µs/call
# 30 times (101µs+220µs) by JSON::Schema::Modern::Vocabulary::Validation::_assert_number at line 314 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 11µs/call
# 15 times (85µs+190µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 103 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 18µs/call
# 15 times (86µs+114µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor at line 144 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 13µs/call
# 14 times (111µs+698µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 58µs/call
# 11 times (49µs+25µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 247 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 7µs/call
# 7 times (27µs+13µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 441 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 6µs/call
# 7 times (28µs+7µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 61 of JSON/Schema/Modern/Vocabulary.pm, avg 5µs/call
# 3 times (5µs+61µs) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems at line 207 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 22µs/call
# once (8µs+32µs) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 95 of JSON/Schema/Modern/Document/OpenAPI.pm
# once (4µs+6µs) by JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentEncoding at line 39 of JSON/Schema/Modern/Vocabulary/Content.pm
# once (5µs+1000ns) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired at line 278 of JSON/Schema/Modern/Vocabulary/Validation.pm | ||
279 | 3585 | 768µs | croak 'assert_keyword_type called in void context' if not defined wantarray; | ||
280 | 3585 | 4.91ms | my $value = $schema->{$state->{keyword}}; | ||
281 | 3585 | 746µs | my $thing = 'value'; | ||
282 | ($value, $thing) = is_plain_hashref($value) ? ($value->{$state->{_schema_path_suffix}}, 'value at "'.$state->{_schema_path_suffix}.'"') | ||||
283 | : is_plain_arrayref($value) ? ($value->[$state->{_schema_path_suffix}], 'item '.$state->{_schema_path_suffix}) | ||||
284 | : die 'unknown type' | ||||
285 | 3585 | 768µs | if exists $state->{_schema_path_suffix}; | ||
286 | 3585 | 9.38ms | 3585 | 26.1ms | return 1 if is_type($type, $value); # spent 26.1ms making 3585 calls to JSON::Schema::Modern::Utilities::is_type, avg 7µs/call |
287 | E($state, '%s %s is not a%s %s', $state->{keyword}, $thing, ($type =~ /^[aeiou]/ ? 'n' : ''), $type); | ||||
288 | } | ||||
289 | |||||
290 | 228 | 43µs | # spent 3.22ms (1.23+1.98) within JSON::Schema::Modern::Utilities::assert_pattern which was called 76 times, avg 42µs/call:
# 69 times (1.13ms+1.78ms) by JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern at line 179 of JSON/Schema/Modern/Vocabulary/Validation.pm, avg 42µs/call
# 7 times (104µs+208µs) by JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties at line 445 of JSON/Schema/Modern/Vocabulary/Applicator.pm, avg 45µs/call | ||
291 | 76 | 27µs | croak 'assert_pattern called in void context' if not defined wantarray; | ||
292 | 76 | 59µs | try { | ||
293 | 76 | 512µs | local $SIG{__WARN__} = sub { die @_ }; | ||
294 | 76 | 2.47ms | 152 | 1.98ms | qr/$pattern/; # spent 1.92ms making 76 calls to JSON::Schema::Modern::Utilities::CORE:regcomp, avg 25µs/call
# spent 60µs making 76 calls to JSON::Schema::Modern::Utilities::CORE:qr, avg 789ns/call |
295 | } | ||||
296 | catch ($e) { return E($state, $e); }; | ||||
297 | 76 | 145µs | return 1; | ||
298 | } | ||||
299 | |||||
300 | # this is only suitable for checking URIs within schemas themselves | ||||
301 | 2217 | 331µs | # spent 158ms (12.3+146) within JSON::Schema::Modern::Utilities::assert_uri_reference which was called 739 times, avg 214µs/call:
# 725 times (12.1ms+144ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref at line 194 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 215µs/call
# 14 times (203µs+2.07ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id at line 48 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 162µs/call | ||
302 | 739 | 193µs | croak 'assert_uri_reference called in void context' if not defined wantarray; | ||
303 | |||||
304 | 739 | 498µs | my $string = $schema->{$state->{keyword}}; | ||
305 | return E($state, '%s value is not a valid URI reference', $state->{keyword}) | ||||
306 | # see also uri-reference format sub | ||||
307 | 739 | 12.3ms | 5059 | 146ms | if fc(Mojo::URL->new($string)->to_unsafe_string) ne fc($string) # spent 81.8ms making 739 calls to Mojo::URL::new, avg 111µs/call
# spent 59.2ms making 739 calls to Mojo::URL::to_unsafe_string, avg 80µs/call
# spent 5.05ms making 3581 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 1µs/call |
308 | or $string =~ /[^[:ascii:]]/ | ||||
309 | or $string =~ /#/ | ||||
310 | and $string !~ m{#$} # empty fragment | ||||
311 | and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment | ||||
312 | and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment | ||||
313 | |||||
314 | 739 | 1.64ms | return 1; | ||
315 | } | ||||
316 | |||||
317 | # this is only suitable for checking URIs within schemas themselves | ||||
318 | 184 | 32µs | # spent 7.05ms (634µs+6.42) within JSON::Schema::Modern::Utilities::assert_uri which was called 46 times, avg 153µs/call:
# 31 times (391µs+4.36ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary at line 257 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 153µs/call
# 15 times (243µs+2.06ms) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 103 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 154µs/call | ||
319 | 46 | 11µs | croak 'assert_uri called in void context' if not defined wantarray; | ||
320 | |||||
321 | 46 | 23µs | my $string = $override // $schema->{$state->{keyword}}; | ||
322 | 46 | 53µs | 46 | 2.03ms | my $uri = Mojo::URL->new($string); # spent 2.03ms making 46 calls to Mojo::URL::new, avg 44µs/call |
323 | |||||
324 | 46 | 302µs | 184 | 4.39ms | return E($state, '"%s" is not a valid URI', $string) # spent 4.21ms making 46 calls to Mojo::URL::to_unsafe_string, avg 92µs/call
# spent 145µs making 46 calls to Mojo::URL::is_abs, avg 3µs/call
# spent 31µs making 92 calls to JSON::Schema::Modern::Utilities::CORE:match, avg 337ns/call |
325 | # see also uri format sub | ||||
326 | if fc($uri->to_unsafe_string) ne fc($string) | ||||
327 | or $string =~ /[^[:ascii:]]/ | ||||
328 | or not $uri->is_abs | ||||
329 | or $string =~ /#/ | ||||
330 | and $string !~ m{#$} # empty fragment | ||||
331 | and $string !~ m{#[A-Za-z][A-Za-z0-9_:.-]*$} # plain-name fragment | ||||
332 | and $string !~ m{#/(?:[^~]|~[01])*$}; # json pointer fragment | ||||
333 | |||||
334 | 46 | 155µs | return 1; | ||
335 | } | ||||
336 | |||||
337 | # produces an annotation whose value is the same as that of the current keyword | ||||
338 | 96642 | 17.0ms | # spent 7.88s (147ms+7.73) within JSON::Schema::Modern::Utilities::annotate_self which was called 32214 times, avg 245µs/call:
# 32214 times (147ms+7.73s) by JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_title at line 43 of JSON/Schema/Modern/Vocabulary/MetaData.pm, avg 245µs/call | ||
339 | A($state, is_ref($schema->{$state->{keyword}}) ? dclone($schema->{$state->{keyword}}) | ||||
340 | 32214 | 156ms | 33327 | 7.73s | : $schema->{$state->{keyword}}); # spent 7.69s making 32214 calls to JSON::Schema::Modern::Utilities::A, avg 239µs/call
# spent 40.8ms making 1113 calls to Storable::dclone, avg 37µs/call |
341 | } | ||||
342 | |||||
343 | sub sprintf_num ($value) { | ||||
344 | # use original value as stored in the NV, without losing precision | ||||
345 | ref($value) =~ /^Math::Big(?:Int|Float)$/ ? $value->bstr : sprintf('%s', $value); | ||||
346 | } | ||||
347 | |||||
348 | 1 | 6µs | 1; | ||
349 | |||||
350 | 1 | 38µs | 1 | 260µs | __END__ # spent 260µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 5.13ms within JSON::Schema::Modern::Utilities::CORE:match which was called 3869 times, avg 1µs/call:
# 3581 times (5.05ms+0s) by JSON::Schema::Modern::Utilities::assert_uri_reference at line 307, avg 1µs/call
# 109 times (28µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 78, avg 257ns/call
# 92 times (31µs+0s) by JSON::Schema::Modern::Utilities::assert_uri at line 324, avg 337ns/call
# 87 times (20µs+0s) by JSON::Schema::Modern::Utilities::is_type at line 83, avg 230ns/call | |||||
# spent 60µs within JSON::Schema::Modern::Utilities::CORE:qr which was called 76 times, avg 789ns/call:
# 76 times (60µs+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 294, avg 789ns/call | |||||
# spent 1.92ms within JSON::Schema::Modern::Utilities::CORE:regcomp which was called 76 times, avg 25µs/call:
# 76 times (1.92ms+0s) by JSON::Schema::Modern::Utilities::assert_pattern at line 294, avg 25µs/call | |||||
sub JSON::Schema::Modern::Utilities::CORE:sort; # opcode | |||||
# spent 156ms within JSON::Schema::Modern::Utilities::CORE:subst which was called 469978 times, avg 333ns/call:
# 469978 times (156ms+0s) by JSON::Schema::Modern::Utilities::jsonp at line 171, avg 333ns/call | |||||
sub JSON::Schema::Modern::Utilities::__ANON__; # xsub |