| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm |
| Statements | Executed 12730331 statements in 15.4s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 91595 | 3 | 2 | 12.2s | 97.2s | JSON::Schema::Modern::_eval_subschema (recurses: max depth 74, inclusive time 2188s) |
| 46881 | 5 | 3 | 2.16s | 19.3s | JSON::Schema::Modern::_fetch_from_uri |
| 953819 | 3 | 1 | 376ms | 376ms | JSON::Schema::Modern::CORE:subst (opcode) |
| 1 | 1 | 1 | 319ms | 97.6s | JSON::Schema::Modern::evaluate |
| 2123434 | 4 | 1 | 307ms | 307ms | JSON::Schema::Modern::CORE:match (opcode) |
| 39123 | 1 | 1 | 178ms | 6.36s | JSON::Schema::Modern::_get_or_load_resource |
| 2856 | 5 | 2 | 170ms | 642ms | JSON::Schema::Modern::_traverse_subschema (recurses: max depth 6, inclusive time 674ms) |
| 128929 | 4 | 1 | 98.7ms | 98.7ms | JSON::Schema::Modern::CORE:sort (opcode) |
| 87311 | 1 | 1 | 87.5ms | 87.5ms | JSON::Schema::Modern::CORE:regcomp (opcode) |
| 87311 | 1 | 1 | 80.4ms | 80.4ms | JSON::Schema::Modern::CORE:qr (opcode) |
| 743 | 4 | 3 | 27.6ms | 1.25s | JSON::Schema::Modern::traverse (recurses: max depth 1, inclusive time 2.21ms) |
| 1 | 1 | 1 | 11.0ms | 15.7ms | JSON::Schema::Modern::BEGIN@25 |
| 1 | 1 | 1 | 8.94ms | 87.2ms | JSON::Schema::Modern::BEGIN@31 |
| 743 | 1 | 1 | 4.52ms | 97.2ms | JSON::Schema::Modern::_get_metaschema_info (recurses: max depth 1, inclusive time 30µs) |
| 1 | 1 | 1 | 3.71ms | 189ms | JSON::Schema::Modern::BEGIN@23 |
| 1 | 1 | 1 | 3.67ms | 5.80ms | JSON::Schema::Modern::BEGIN@36 |
| 1 | 1 | 1 | 3.23ms | 29.8ms | JSON::Schema::Modern::BEGIN@27 |
| 1 | 1 | 1 | 2.72ms | 3.00ms | JSON::Schema::Modern::BEGIN@28 |
| 1 | 1 | 1 | 2.52ms | 37.2ms | JSON::Schema::Modern::BEGIN@34 |
| 1 | 1 | 1 | 1.96ms | 14.6ms | JSON::Schema::Modern::BEGIN@18 |
| 1 | 1 | 1 | 1.84ms | 49.8ms | JSON::Schema::Modern::BEGIN@35 |
| 1 | 1 | 1 | 1.60ms | 76.0ms | JSON::Schema::Modern::BEGIN@33 |
| 1 | 1 | 1 | 1.33ms | 1.64ms | JSON::Schema::Modern::BEGIN@30 |
| 9 | 3 | 2 | 1.13ms | 133ms | JSON::Schema::Modern::add_schema |
| 1 | 1 | 1 | 1.07ms | 7.30ms | JSON::Schema::Modern::BEGIN@29 |
| 15 | 1 | 1 | 626µs | 10.2ms | JSON::Schema::Modern::__ANON__[:646] |
| 1 | 1 | 1 | 171µs | 64.8ms | JSON::Schema::Modern::add_vocabulary |
| 1 | 1 | 1 | 118µs | 56.5ms | JSON::Schema::Modern::__ANON__[:670] |
| 1 | 1 | 1 | 76µs | 1.09ms | JSON::Schema::Modern::__ANON__[:124] |
| 1 | 1 | 1 | 67µs | 407µs | JSON::Schema::Modern::BEGIN@11 |
| 1 | 1 | 1 | 28µs | 30µs | OpenAPI::Modern::BEGIN@1 |
| 1 | 1 | 1 | 22µs | 969µs | JSON::Schema::Modern::BEGIN@12 |
| 1 | 1 | 1 | 20µs | 71µs | JSON::Schema::Modern::BEGIN@20 |
| 1 | 1 | 1 | 19µs | 46µs | JSON::Schema::Modern::BEGIN@754 |
| 1 | 1 | 1 | 16µs | 73µs | JSON::Schema::Modern::BEGIN@748 |
| 1 | 1 | 1 | 15µs | 45µs | JSON::Schema::Modern::BEGIN@21 |
| 1 | 1 | 1 | 15µs | 76µs | JSON::Schema::Modern::BEGIN@32 |
| 26 | 2 | 1 | 14µs | 14µs | JSON::Schema::Modern::CACHED_METASCHEMAS (xsub) |
| 1 | 1 | 1 | 14µs | 55µs | JSON::Schema::Modern::BEGIN@14 |
| 1 | 1 | 1 | 14µs | 108µs | JSON::Schema::Modern::__ANON__[:712] |
| 1 | 1 | 1 | 13µs | 34µs | JSON::Schema::Modern::BEGIN@15 |
| 15 | 1 | 1 | 12µs | 12µs | JSON::Schema::Modern::METASCHEMA_URIS (xsub) |
| 1 | 1 | 1 | 11µs | 22µs | JSON::Schema::Modern::BEGIN@16 |
| 1 | 1 | 1 | 11µs | 121µs | JSON::Schema::Modern::BEGIN@24 |
| 1 | 1 | 1 | 10µs | 10µs | JSON::Schema::Modern::BEGIN@10 |
| 1 | 1 | 1 | 10µs | 141µs | JSON::Schema::Modern::BEGIN@13 |
| 1 | 1 | 1 | 10µs | 24µs | JSON::Schema::Modern::BEGIN@17 |
| 1 | 1 | 1 | 9µs | 16µs | JSON::Schema::Modern::__ANON__[:90] |
| 1 | 1 | 1 | 8µs | 26µs | JSON::Schema::Modern::BEGIN@19 |
| 1 | 1 | 1 | 8µs | 45µs | JSON::Schema::Modern::BEGIN@26 |
| 1 | 1 | 1 | 8µs | 668µs | JSON::Schema::Modern::BEGIN@37 |
| 1 | 1 | 1 | 8µs | 50µs | JSON::Schema::Modern::BEGIN@46 |
| 1 | 1 | 1 | 8µs | 13µs | JSON::Schema::Modern::__ANON__[:133] |
| 1 | 1 | 1 | 8µs | 43µs | JSON::Schema::Modern::__ANON__[:870] |
| 1 | 1 | 1 | 7µs | 20µs | JSON::Schema::Modern::BEGIN@22 |
| 1 | 1 | 1 | 7µs | 14µs | JSON::Schema::Modern::__ANON__[:69] |
| 1 | 1 | 1 | 7µs | 41µs | OpenAPI::Modern::BEGIN@2 |
| 1 | 1 | 1 | 6µs | 29µs | JSON::Schema::Modern::BEGIN@47 |
| 1 | 1 | 1 | 2µs | 2µs | JSON::Schema::Modern::__ANON__[:610] |
| 1 | 1 | 1 | 1µs | 1µs | JSON::Schema::Modern::SPECIFICATION_VERSION_DEFAULT (xsub) |
| 2 | 2 | 1 | 1µs | 1µs | JSON::Schema::Modern::__ANON__ (xsub) |
| 1 | 1 | 1 | 1µs | 1µs | JSON::Schema::Modern::__ANON__[:121] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::FREEZE |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::THAW |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:177] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:53] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:55] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:56] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:666] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:833] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:887] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:893] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:896] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:905] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:907] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:909] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:922] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:927] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::__ANON__[:929] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::evaluate_json_string |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::get |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::validate_schema |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 31µs | 2 | 32µs | # spent 30µs (28+2) within OpenAPI::Modern::BEGIN@1 which was called:
# once (28µs+2µs) by OpenAPI::Modern::BEGIN@26 at line 1 # spent 30µs making 1 call to OpenAPI::Modern::BEGIN@1
# spent 2µs making 1 call to strict::import |
| 2 | 2 | 49µs | 2 | 75µs | # spent 41µs (7+34) within OpenAPI::Modern::BEGIN@2 which was called:
# once (7µs+34µs) by OpenAPI::Modern::BEGIN@26 at line 2 # spent 41µs making 1 call to OpenAPI::Modern::BEGIN@2
# spent 34µs making 1 call to warnings::import |
| 3 | package JSON::Schema::Modern; # git description: v0.551-3-gb026a1f2 | ||||
| 4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||
| 5 | # ABSTRACT: Validate data against a schema | ||||
| 6 | # KEYWORDS: JSON Schema data validation structure specification | ||||
| 7 | |||||
| 8 | 1 | 2µs | our $VERSION = '0.552'; | ||
| 9 | |||||
| 10 | 2 | 32µs | 1 | 10µs | # spent 10µs within JSON::Schema::Modern::BEGIN@10 which was called:
# once (10µs+0s) by OpenAPI::Modern::BEGIN@26 at line 10 # spent 10µs making 1 call to JSON::Schema::Modern::BEGIN@10 |
| 11 | 2 | 64µs | 2 | 747µs | # spent 407µs (67+340) within JSON::Schema::Modern::BEGIN@11 which was called:
# once (67µs+340µs) by OpenAPI::Modern::BEGIN@26 at line 11 # spent 407µs making 1 call to JSON::Schema::Modern::BEGIN@11
# spent 340µs making 1 call to Moo::import |
| 12 | 3 | 43µs | 3 | 1.92ms | # spent 969µs (22+947) within JSON::Schema::Modern::BEGIN@12 which was called:
# once (22µs+947µs) by OpenAPI::Modern::BEGIN@26 at line 12 # spent 969µs making 1 call to JSON::Schema::Modern::BEGIN@12
# spent 924µs making 1 call to strictures::import
# spent 22µs making 1 call to strictures::VERSION |
| 13 | 2 | 50µs | 2 | 272µs | # spent 141µs (10+131) within JSON::Schema::Modern::BEGIN@13 which was called:
# once (10µs+131µs) by OpenAPI::Modern::BEGIN@26 at line 13 # spent 141µs making 1 call to JSON::Schema::Modern::BEGIN@13
# spent 131µs making 1 call to experimental::import |
| 14 | 2 | 36µs | 2 | 59µs | # spent 55µs (14+41) within JSON::Schema::Modern::BEGIN@14 which was called:
# once (14µs+41µs) by OpenAPI::Modern::BEGIN@26 at line 14 # spent 55µs making 1 call to JSON::Schema::Modern::BEGIN@14
# spent 4µs making 1 call to if::import |
| 15 | 2 | 30µs | 2 | 36µs | # spent 34µs (13+21) within JSON::Schema::Modern::BEGIN@15 which was called:
# once (13µs+21µs) by OpenAPI::Modern::BEGIN@26 at line 15 # spent 34µs making 1 call to JSON::Schema::Modern::BEGIN@15
# spent 2µs making 1 call to if::unimport |
| 16 | 2 | 29µs | 2 | 24µs | # spent 22µs (11+11) within JSON::Schema::Modern::BEGIN@16 which was called:
# once (11µs+11µs) by OpenAPI::Modern::BEGIN@26 at line 16 # spent 22µs making 1 call to JSON::Schema::Modern::BEGIN@16
# spent 2µs making 1 call to if::unimport |
| 17 | 2 | 21µs | 2 | 25µs | # spent 24µs (10+14) within JSON::Schema::Modern::BEGIN@17 which was called:
# once (10µs+14µs) by OpenAPI::Modern::BEGIN@26 at line 17 # spent 24µs making 1 call to JSON::Schema::Modern::BEGIN@17
# spent 1µs making 1 call to if::unimport |
| 18 | 2 | 635µs | 2 | 14.7ms | # spent 14.6ms (1.96+12.7) within JSON::Schema::Modern::BEGIN@18 which was called:
# once (1.96ms+12.7ms) by OpenAPI::Modern::BEGIN@26 at line 18 # spent 14.6ms making 1 call to JSON::Schema::Modern::BEGIN@18
# spent 52µs making 1 call to Exporter::import |
| 19 | 2 | 34µs | 2 | 44µs | # spent 26µs (8+18) within JSON::Schema::Modern::BEGIN@19 which was called:
# once (8µs+18µs) by OpenAPI::Modern::BEGIN@26 at line 19 # spent 26µs making 1 call to JSON::Schema::Modern::BEGIN@19
# spent 18µs making 1 call to Exporter::import |
| 20 | 3 | 48µs | 3 | 93µs | # spent 71µs (20+51) within JSON::Schema::Modern::BEGIN@20 which was called:
# once (20µs+51µs) by OpenAPI::Modern::BEGIN@26 at line 20 # spent 71µs making 1 call to JSON::Schema::Modern::BEGIN@20
# spent 13µs making 1 call to List::Util::import
# spent 9µs making 1 call to UNIVERSAL::VERSION |
| 21 | 3 | 38µs | 3 | 75µs | # spent 45µs (15+30) within JSON::Schema::Modern::BEGIN@21 which was called:
# once (15µs+30µs) by OpenAPI::Modern::BEGIN@26 at line 21 # spent 45µs making 1 call to JSON::Schema::Modern::BEGIN@21
# spent 25µs making 1 call to Exporter::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
| 22 | 2 | 20µs | 2 | 33µs | # spent 20µs (7+13) within JSON::Schema::Modern::BEGIN@22 which was called:
# once (7µs+13µs) by OpenAPI::Modern::BEGIN@26 at line 22 # spent 20µs making 1 call to JSON::Schema::Modern::BEGIN@22
# spent 13µs making 1 call to Exporter::import |
| 23 | 2 | 1.13ms | 2 | 189ms | # spent 189ms (3.71+185) within JSON::Schema::Modern::BEGIN@23 which was called:
# once (3.71ms+185ms) by OpenAPI::Modern::BEGIN@26 at line 23 # spent 189ms making 1 call to JSON::Schema::Modern::BEGIN@23
# spent 4µs making 1 call to Mojo::Base::import |
| 24 | 2 | 33µs | 2 | 231µs | # spent 121µs (11+110) within JSON::Schema::Modern::BEGIN@24 which was called:
# once (11µs+110µs) by OpenAPI::Modern::BEGIN@26 at line 24 # spent 121µs making 1 call to JSON::Schema::Modern::BEGIN@24
# spent 110µs making 1 call to Exporter::import |
| 25 | 2 | 892µs | 2 | 15.8ms | # spent 15.7ms (11.0+4.72) within JSON::Schema::Modern::BEGIN@25 which was called:
# once (11.0ms+4.72ms) by OpenAPI::Modern::BEGIN@26 at line 25 # spent 15.7ms making 1 call to JSON::Schema::Modern::BEGIN@25
# spent 27µs making 1 call to Exporter::import |
| 26 | 2 | 18µs | 2 | 82µs | # spent 45µs (8+37) within JSON::Schema::Modern::BEGIN@26 which was called:
# once (8µs+37µs) by OpenAPI::Modern::BEGIN@26 at line 26 # spent 45µs making 1 call to JSON::Schema::Modern::BEGIN@26
# spent 37µs making 1 call to Exporter::import |
| 27 | 2 | 932µs | 2 | 29.8ms | # spent 29.8ms (3.23+26.5) within JSON::Schema::Modern::BEGIN@27 which was called:
# once (3.23ms+26.5ms) by OpenAPI::Modern::BEGIN@26 at line 27 # spent 29.8ms making 1 call to JSON::Schema::Modern::BEGIN@27
# spent 22µs making 1 call to Exporter::import |
| 28 | 2 | 656µs | 2 | 3.04ms | # spent 3.00ms (2.72+289µs) within JSON::Schema::Modern::BEGIN@28 which was called:
# once (2.72ms+289µs) by OpenAPI::Modern::BEGIN@26 at line 28 # spent 3.00ms making 1 call to JSON::Schema::Modern::BEGIN@28
# spent 38µs making 1 call to Module::Runtime::import |
| 29 | 3 | 865µs | 3 | 13.4ms | # spent 7.30ms (1.07+6.24) within JSON::Schema::Modern::BEGIN@29 which was called:
# once (1.07ms+6.24ms) by OpenAPI::Modern::BEGIN@26 at line 29 # spent 7.30ms making 1 call to JSON::Schema::Modern::BEGIN@29
# spent 6.09ms making 1 call to MooX::TypeTiny::import
# spent 12µs making 1 call to UNIVERSAL::VERSION |
| 30 | 2 | 690µs | 2 | 1.75ms | # spent 1.64ms (1.33+313µs) within JSON::Schema::Modern::BEGIN@30 which was called:
# once (1.33ms+313µs) by OpenAPI::Modern::BEGIN@26 at line 30 # spent 1.64ms making 1 call to JSON::Schema::Modern::BEGIN@30
# spent 106µs making 1 call to MooX::HandlesVia::import |
| 31 | 3 | 1.03ms | 3 | 89.1ms | # spent 87.2ms (8.94+78.3) within JSON::Schema::Modern::BEGIN@31 which was called:
# once (8.94ms+78.3ms) by OpenAPI::Modern::BEGIN@26 at line 31 # spent 87.2ms making 1 call to JSON::Schema::Modern::BEGIN@31
# spent 1.89ms making 1 call to Exporter::Tiny::import
# spent 9µs making 1 call to UNIVERSAL::VERSION |
| 32 | 2 | 37µs | 2 | 137µs | # spent 76µs (15+61) within JSON::Schema::Modern::BEGIN@32 which was called:
# once (15µs+61µs) by OpenAPI::Modern::BEGIN@26 at line 32 # spent 76µs making 1 call to JSON::Schema::Modern::BEGIN@32
# spent 61µs making 1 call to Feature::Compat::Try::import |
| 33 | 2 | 694µs | 2 | 76.0ms | # spent 76.0ms (1.60+74.4) within JSON::Schema::Modern::BEGIN@33 which was called:
# once (1.60ms+74.4ms) by OpenAPI::Modern::BEGIN@26 at line 33 # spent 76.0ms making 1 call to JSON::Schema::Modern::BEGIN@33
# spent 0s making 1 call to JSON::Schema::Modern::__ANON__ |
| 34 | 2 | 777µs | 2 | 37.2ms | # spent 37.2ms (2.52+34.6) within JSON::Schema::Modern::BEGIN@34 which was called:
# once (2.52ms+34.6ms) by OpenAPI::Modern::BEGIN@26 at line 34 # spent 37.2ms making 1 call to JSON::Schema::Modern::BEGIN@34
# spent 1µs making 1 call to JSON::Schema::Modern::__ANON__ |
| 35 | 2 | 487µs | 2 | 49.8ms | # spent 49.8ms (1.84+47.9) within JSON::Schema::Modern::BEGIN@35 which was called:
# once (1.84ms+47.9ms) by OpenAPI::Modern::BEGIN@26 at line 35 # spent 49.8ms making 1 call to JSON::Schema::Modern::BEGIN@35
# spent 6µs making 1 call to Mojo::Base::import |
| 36 | 2 | 516µs | 2 | 5.88ms | # spent 5.80ms (3.67+2.13) within JSON::Schema::Modern::BEGIN@36 which was called:
# once (3.67ms+2.13ms) by OpenAPI::Modern::BEGIN@26 at line 36 # spent 5.80ms making 1 call to JSON::Schema::Modern::BEGIN@36
# spent 79µs making 1 call to Exporter::import |
| 37 | 2 | 54µs | 2 | 1.33ms | # spent 668µs (8+660) within JSON::Schema::Modern::BEGIN@37 which was called:
# once (8µs+660µs) by OpenAPI::Modern::BEGIN@26 at line 37 # spent 668µs making 1 call to JSON::Schema::Modern::BEGIN@37
# spent 660µs making 1 call to namespace::clean::import |
| 38 | |||||
| 39 | 1 | 3µs | our @CARP_NOT = qw( | ||
| 40 | JSON::Schema::Modern::Document | ||||
| 41 | JSON::Schema::Modern::Vocabulary | ||||
| 42 | JSON::Schema::Modern::Vocabulary::Applicator | ||||
| 43 | OpenAPI::Modern | ||||
| 44 | ); | ||||
| 45 | |||||
| 46 | 2 | 29µs | 2 | 92µs | # spent 50µs (8+42) within JSON::Schema::Modern::BEGIN@46 which was called:
# once (8µs+42µs) by OpenAPI::Modern::BEGIN@26 at line 46 # spent 50µs making 1 call to JSON::Schema::Modern::BEGIN@46
# spent 42µs making 1 call to constant::import |
| 47 | 2 | 4.63ms | 2 | 52µs | # spent 29µs (6+23) within JSON::Schema::Modern::BEGIN@47 which was called:
# once (6µs+23µs) by OpenAPI::Modern::BEGIN@26 at line 47 # spent 29µs making 1 call to JSON::Schema::Modern::BEGIN@47
# spent 23µs making 1 call to constant::import |
| 48 | |||||
| 49 | has specification_version => ( | ||||
| 50 | is => 'ro', | ||||
| 51 | isa => Enum(SPECIFICATION_VERSIONS_SUPPORTED), | ||||
| 52 | coerce => sub { | ||||
| 53 | return $_[0] if any { $_[0] eq $_ } SPECIFICATION_VERSIONS_SUPPORTED->@*; | ||||
| 54 | my $real = 'draft'.($_[0]//''); | ||||
| 55 | (any { $real eq $_ } SPECIFICATION_VERSIONS_SUPPORTED->@*) ? $real : $_[0]; | ||||
| 56 | }, | ||||
| 57 | 1 | 6µs | 2 | 1.79ms | ); # spent 1.10ms making 1 call to MooX::HandlesVia::has
# spent 687µs making 1 call to Types::Standard::Enum |
| 58 | |||||
| 59 | 1 | 20µs | 3 | 729µs | has output_format => ( # spent 594µs making 1 call to MooX::HandlesVia::has
# spent 134µs making 1 call to Types::Standard::Enum
# spent 1µs making 1 call to JSON::Schema::Modern::Result::OUTPUT_FORMATS |
| 60 | is => 'ro', | ||||
| 61 | isa => Enum(JSON::Schema::Modern::Result->OUTPUT_FORMATS), | ||||
| 62 | default => 'basic', | ||||
| 63 | ); | ||||
| 64 | |||||
| 65 | has short_circuit => ( | ||||
| 66 | is => 'ro', | ||||
| 67 | isa => Bool, | ||||
| 68 | lazy => 1, | ||||
| 69 | 1 | 6µs | 1 | 7µs | # spent 14µs (7+7) within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:69] which was called:
# once (7µs+7µs) by JSON::Schema::Modern::short_circuit at line 23 of (eval 312)[Sub/Quote.pm:3] # spent 7µs making 1 call to JSON::Schema::Modern::output_format |
| 70 | 1 | 37µs | 2 | 1.18ms | ); # spent 1.15ms making 1 call to MooX::HandlesVia::has
# spent 29µs making 1 call to Types::Standard::Bool |
| 71 | |||||
| 72 | 1 | 4µs | 2 | 825µs | has max_traversal_depth => ( # spent 822µs making 1 call to MooX::HandlesVia::has
# spent 3µs making 1 call to Types::Standard::Int |
| 73 | is => 'ro', | ||||
| 74 | isa => Int, | ||||
| 75 | default => 50, | ||||
| 76 | ); | ||||
| 77 | |||||
| 78 | 1 | 4µs | 2 | 478µs | has validate_formats => ( # spent 476µs making 1 call to MooX::HandlesVia::has
# spent 2µs making 1 call to Types::Standard::Bool |
| 79 | is => 'ro', | ||||
| 80 | isa => Bool, | ||||
| 81 | default => 0, # as specified by https://json-schema.org/draft/<version>/schema#/$vocabulary | ||||
| 82 | ); | ||||
| 83 | |||||
| 84 | has validate_content_schemas => ( | ||||
| 85 | is => 'ro', | ||||
| 86 | isa => Bool, | ||||
| 87 | lazy => 1, | ||||
| 88 | # defaults to false in latest versions, as specified by | ||||
| 89 | # https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.8.2 | ||||
| 90 | 1 | 7µs | 1 | 7µs | # spent 16µs (9+7) within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:90] which was called:
# once (9µs+7µs) by JSON::Schema::Modern::validate_content_schemas at line 23 of (eval 315)[Sub/Quote.pm:3] # spent 7µs making 1 call to JSON::Schema::Modern::specification_version |
| 91 | 1 | 4µs | 2 | 982µs | ); # spent 982µs making 1 call to MooX::HandlesVia::has
# spent 0s making 1 call to Types::Standard::Bool |
| 92 | |||||
| 93 | 1 | 3µs | 2 | 633µs | has collect_annotations => ( # spent 631µs making 1 call to MooX::HandlesVia::has
# spent 2µs making 1 call to Types::Standard::Bool |
| 94 | is => 'ro', | ||||
| 95 | isa => Bool, | ||||
| 96 | ); | ||||
| 97 | |||||
| 98 | 1 | 1µs | 2 | 421µs | has scalarref_booleans => ( # spent 420µs making 1 call to MooX::HandlesVia::has
# spent 1µs making 1 call to Types::Standard::Bool |
| 99 | is => 'ro', | ||||
| 100 | isa => Bool, | ||||
| 101 | ); | ||||
| 102 | |||||
| 103 | 1 | 3µs | 2 | 585µs | has strict => ( # spent 583µs making 1 call to MooX::HandlesVia::has
# spent 2µs making 1 call to Types::Standard::Bool |
| 104 | is => 'ro', | ||||
| 105 | isa => Bool, | ||||
| 106 | ); | ||||
| 107 | |||||
| 108 | has _format_validations => ( | ||||
| 109 | is => 'bare', | ||||
| 110 | isa => my $format_type = Dict[ | ||||
| 111 | (map +($_ => Optional[CodeRef]), qw(date-time date time duration email idn-email hostname idn-hostname ipv4 ipv6 uri uri-reference iri iri-reference uuid uri-template json-pointer relative-json-pointer regex)), | ||||
| 112 | slurpy HashRef[Dict[type => Enum[qw(null object array boolean string number integer)], sub => CodeRef]], | ||||
| 113 | ], | ||||
| 114 | init_arg => 'format_validations', | ||||
| 115 | handles_via => 'Hash', | ||||
| 116 | handles => { | ||||
| 117 | _get_format_validation => 'get', | ||||
| 118 | add_format_validation => 'set', | ||||
| 119 | }, | ||||
| 120 | lazy => 1, | ||||
| 121 | 1 | 2µs | # spent 1µs within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:121] which was called:
# once (1µs+0s) by JSON::Schema::Modern::_assert__format_validations at line 23 of (eval 325)[Sub/Quote.pm:3] | ||
| 122 | 1 | 80µs | 45 | 32.1ms | ); # spent 13.3ms making 2 calls to Types::Standard::Dict, avg 6.64ms/call
# spent 10.5ms making 1 call to MooX::HandlesVia::has
# spent 3.97ms making 1 call to Types::Standard::slurpy
# spent 1.76ms making 1 call to Types::Standard::HashRef
# spent 1.50ms making 19 calls to Types::Standard::Optional, avg 79µs/call
# spent 1.05ms making 1 call to Types::Standard::Enum
# spent 11µs making 20 calls to Types::Standard::CodeRef, avg 550ns/call |
| 123 | |||||
| 124 | 5 | 125µs | 17 | 1.17ms | # spent 1.09ms (76µs+1.01) within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:124] which was called:
# once (76µs+1.01ms) by JSON::Schema::Modern::add_format_validation at line 4 of (eval 327)[Class/Method/Modifiers.pm:148] # spent 936µs making 5 calls to Sub::Defer::__ANON__[Sub/Defer.pm:178], avg 187µs/call
# spent 201µs making 1 call to Moo::before
# spent 31µs making 10 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 3µs/call
# spent 3µs making 1 call to List::Util::pairs |
| 125 | |||||
| 126 | 4 | 1µs | # spent 13µs (8+5) within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:133] which was called:
# once (8µs+5µs) by JSON::Schema::Modern::__ANON__[(eval 329)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 329)[Class/Method/Modifiers.pm:89] | ||
| 127 | 1 | 2µs | 1 | 5µs | my $args = $class->$orig(@args); # spent 5µs making 1 call to Moo::Object::BUILDARGS |
| 128 | croak 'output_format: strict_basic can only be used with specification_version: draft2019-09' | ||||
| 129 | if ($args->{output_format}//'') eq 'strict_basic' | ||||
| 130 | 1 | 1µs | and ($args->{specification_version}//'') ne 'draft2019-09'; | ||
| 131 | |||||
| 132 | 1 | 3µs | return $args; | ||
| 133 | 1 | 4µs | 1 | 219µs | }; # spent 219µs making 1 call to Moo::around |
| 134 | |||||
| 135 | # spent 133ms (1.13+131) within JSON::Schema::Modern::add_schema which was called 9 times, avg 14.7ms/call:
# 6 times (722µs+122ms) by JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas at line 204 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 20.5ms/call
# 2 times (81µs+1.33ms) by JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas at line 206 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 707µs/call
# once (325µs+7.59ms) by OpenAPI::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/OpenAPI/Modern.pm:79] at line 75 of OpenAPI/Modern.pm | ||||
| 136 | 9 | 31µs | croak 'insufficient arguments' if @_ < 2; | ||
| 137 | 9 | 16µs | my $self = shift; | ||
| 138 | |||||
| 139 | # TODO: resolve $uri against $self->base_uri | ||||
| 140 | 9 | 87µs | 10 | 556µs | my $uri = !is_ref($_[0]) ? Mojo::URL->new(shift) # spent 517µs making 9 calls to Mojo::URL::new, avg 57µs/call
# spent 39µs making 1 call to Safe::Isa::__ANON__[Safe/Isa.pm:23] |
| 141 | : $_[0]->$_isa('Mojo::URL') ? shift : Mojo::URL->new; | ||||
| 142 | |||||
| 143 | 9 | 7µs | 9 | 9µs | croak 'cannot add a schema with a uri with a fragment' if defined $uri->fragment; # spent 9µs making 9 calls to Mojo::URL::fragment, avg 1µs/call |
| 144 | |||||
| 145 | 9 | 11µs | if (not @_) { | ||
| 146 | my $schema_info = $self->_fetch_from_uri($uri); | ||||
| 147 | return if not $schema_info or not defined wantarray; | ||||
| 148 | return $schema_info->{document}; | ||||
| 149 | } | ||||
| 150 | |||||
| 151 | # document BUILD will trigger $self->traverse($schema) | ||||
| 152 | 9 | 89µs | 21 | 103ms | my $document = $_[0]->$_isa('JSON::Schema::Modern::Document') ? shift # spent 103ms making 6 calls to JSON::Schema::Modern::Document::new, avg 17.1ms/call
# spent 83µs making 9 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 9µs/call
# spent 32µs making 6 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 5µs/call |
| 153 | : JSON::Schema::Modern::Document->new( | ||||
| 154 | schema => shift, | ||||
| 155 | $uri ? (canonical_uri => $uri) : (), | ||||
| 156 | evaluator => $self, # used mainly for traversal during document construction | ||||
| 157 | ); | ||||
| 158 | |||||
| 159 | 9 | 33µs | 9 | 259µs | if ($document->has_errors) { # spent 259µs making 9 calls to JSON::Schema::Modern::Document::has_errors, avg 29µs/call |
| 160 | my $result = JSON::Schema::Modern::Result->new( | ||||
| 161 | output_format => $self->output_format, | ||||
| 162 | valid => 0, | ||||
| 163 | errors => [ $document->errors ], | ||||
| 164 | exception => 1, | ||||
| 165 | ); | ||||
| 166 | die $result; | ||||
| 167 | } | ||||
| 168 | |||||
| 169 | 9 | 314µs | 189 | 199µs | if (not grep refaddr($_->{document}) == refaddr($document), $self->_canonical_resources) { # spent 169µs making 9 calls to JSON::Schema::Modern::_canonical_resources, avg 19µs/call
# spent 30µs making 180 calls to Scalar::Util::refaddr, avg 167ns/call |
| 170 | 7 | 6.13ms | 35 | 6.20ms | my $schema_content = $document->_serialized_schema # spent 6.00ms making 7 calls to Cpanel::JSON::XS::encode, avg 856µs/call
# spent 150µs making 14 calls to JSON::Schema::Modern::Document::_serialized_schema, avg 11µs/call
# spent 46µs making 7 calls to JSON::Schema::Modern::_json_decoder, avg 7µs/call
# spent 13µs making 7 calls to JSON::Schema::Modern::Document::schema, avg 2µs/call |
| 171 | // $document->_serialized_schema($self->_json_decoder->encode($document->schema)); | ||||
| 172 | |||||
| 173 | 7 | 189µs | 21 | 692µs | if (my $existing_doc = first { # spent 548µs making 7 calls to List::Util::first, avg 78µs/call
# spent 90µs making 7 calls to JSON::Schema::Modern::_canonical_resources, avg 13µs/call
# spent 54µs making 7 calls to List::Util::uniqint, avg 8µs/call |
| 174 | 29 | 357µs | 61 | 380µs | my $existing_content = $_->_serialized_schema # spent 283µs making 8 calls to Cpanel::JSON::XS::encode, avg 35µs/call
# spent 75µs making 37 calls to JSON::Schema::Modern::Document::_serialized_schema, avg 2µs/call
# spent 12µs making 8 calls to JSON::Schema::Modern::Document::schema, avg 2µs/call
# spent 10µs making 8 calls to JSON::Schema::Modern::_json_decoder, avg 1µs/call |
| 175 | // $_->_serialized_schema($self->_json_decoder->encode($_->schema)); | ||||
| 176 | 29 | 22µs | $existing_content eq $schema_content | ||
| 177 | } uniqint map $_->{document}, $self->_canonical_resources) { | ||||
| 178 | # we already have this schema content in another document object. | ||||
| 179 | $document = $existing_doc; | ||||
| 180 | } | ||||
| 181 | else { | ||||
| 182 | 7 | 122µs | 14 | 6.36ms | $self->_add_resources(map +($_->[0] => +{ $_->[1]->%*, document => $document }), # spent 6.25ms making 7 calls to JSON::Schema::Modern::_add_resources, avg 893µs/call
# spent 110µs making 7 calls to JSON::Schema::Modern::Document::resource_pairs, avg 16µs/call |
| 183 | $document->resource_pairs); | ||||
| 184 | } | ||||
| 185 | } | ||||
| 186 | |||||
| 187 | 9 | 32µs | 9 | 907µs | if ("$uri") { # spent 907µs making 9 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 101µs/call |
| 188 | 8 | 25µs | 16 | 683µs | my $resource = $document->_get_resource($document->canonical_uri); # spent 671µs making 8 calls to JSON::Schema::Modern::Document::_get_resource, avg 84µs/call
# spent 12µs making 8 calls to JSON::Schema::Modern::Document::canonical_uri, avg 2µs/call |
| 189 | $self->_add_resources($uri => { | ||||
| 190 | path => '', | ||||
| 191 | canonical_uri => $document->canonical_uri, | ||||
| 192 | specification_version => $resource->{specification_version}, | ||||
| 193 | vocabularies => $resource->{vocabularies}, # reference, not copy | ||||
| 194 | document => $document, | ||||
| 195 | configs => $resource->{configs}, | ||||
| 196 | 8 | 50µs | 16 | 4.10ms | }); # spent 4.09ms making 8 calls to JSON::Schema::Modern::_add_resources, avg 511µs/call
# spent 12µs making 8 calls to JSON::Schema::Modern::Document::canonical_uri, avg 2µs/call |
| 197 | } | ||||
| 198 | |||||
| 199 | 9 | 50µs | return $document; | ||
| 200 | } | ||||
| 201 | |||||
| 202 | sub evaluate_json_string ($self, $json_data, $schema, $config_override = {}) { | ||||
| 203 | croak 'evaluate_json_string called in void context' if not defined wantarray; | ||||
| 204 | |||||
| 205 | my $data; | ||||
| 206 | try { | ||||
| 207 | $data = $self->_json_decoder->decode($json_data) | ||||
| 208 | } | ||||
| 209 | catch ($e) { | ||||
| 210 | return JSON::Schema::Modern::Result->new( | ||||
| 211 | output_format => $self->output_format, | ||||
| 212 | valid => 0, | ||||
| 213 | exception => 1, | ||||
| 214 | errors => [ | ||||
| 215 | JSON::Schema::Modern::Error->new( | ||||
| 216 | keyword => undef, | ||||
| 217 | instance_location => '', | ||||
| 218 | keyword_location => '', | ||||
| 219 | error => $e, | ||||
| 220 | ) | ||||
| 221 | ], | ||||
| 222 | ); | ||||
| 223 | } | ||||
| 224 | |||||
| 225 | return $self->evaluate($data, $schema, $config_override); | ||||
| 226 | } | ||||
| 227 | |||||
| 228 | # this is called whenever we need to walk a document for something. | ||||
| 229 | # for now it is just called when a ::Document object is created, to verify the integrity of the | ||||
| 230 | # schema structure, to identify the metaschema (via the $schema keyword), and to extract all | ||||
| 231 | # embedded resources via $id and $anchor keywords within. | ||||
| 232 | # Returns the internal $state object accumulated during the traversal. | ||||
| 233 | 2972 | 789µs | # spent 1.25s (27.6ms+1.22) within JSON::Schema::Modern::traverse which was called 743 times, avg 1.69ms/call:
# 727 times (26.8ms+1.09s) by JSON::Schema::Modern::Document::OpenAPI::_traverse_schema at line 218 of JSON/Schema/Modern/Document/OpenAPI.pm, avg 1.53ms/call
# 14 times (718µs+137ms) by JSON::Schema::Modern::Document::traverse at line 178 of JSON/Schema/Modern/Document.pm, avg 9.80ms/call
# once (48µs+3.03ms) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 115 of JSON/Schema/Modern/Document/OpenAPI.pm
# once (46µs+-46µs) by JSON::Schema::Modern::_get_metaschema_info at line 724 | ||
| 234 | # Note: the starting position is not guaranteed to be at the root of the $document. | ||||
| 235 | 743 | 1.44ms | 743 | 256ms | my $initial_uri = Mojo::URL->new($config_override->{initial_schema_uri} // ''); # spent 256ms making 743 calls to Mojo::URL::new, avg 345µs/call |
| 236 | 743 | 640µs | my $initial_path = $config_override->{traversed_schema_path} // ''; | ||
| 237 | 743 | 2.29ms | 743 | 1.91ms | my $spec_version = $self->specification_version//SPECIFICATION_VERSION_DEFAULT; # spent 1.91ms making 743 calls to JSON::Schema::Modern::specification_version, avg 3µs/call |
| 238 | |||||
| 239 | my $state = { | ||||
| 240 | depth => 0, | ||||
| 241 | data_path => '', # this never changes since we don't have an instance yet | ||||
| 242 | initial_schema_uri => $initial_uri, # the canonical URI as of the start of this method, or last $id | ||||
| 243 | traversed_schema_path => $initial_path, # the accumulated traversal path as of the start, or last $id | ||||
| 244 | schema_path => '', # the rest of the path, since the start of this method, or last $id | ||||
| 245 | effective_base_uri => Mojo::URL->new(''), | ||||
| 246 | errors => [], | ||||
| 247 | identifiers => [], | ||||
| 248 | configs => {}, | ||||
| 249 | callbacks => $config_override->{callbacks} // {}, | ||||
| 250 | 743 | 5.33ms | 743 | 58.8ms | evaluator => $self, # spent 58.8ms making 743 calls to Mojo::URL::new, avg 79µs/call |
| 251 | }; | ||||
| 252 | |||||
| 253 | 743 | 352µs | try { | ||
| 254 | my $for_canonical_uri = Mojo::URL->new( | ||||
| 255 | (is_plain_hashref($schema_reference) && exists $schema_reference->{'$id'} | ||||
| 256 | ? Mojo::URL->new($schema_reference->{'$id'}) : undef) | ||||
| 257 | 743 | 1.69ms | 757 | 170ms | // $state->{initial_schema_uri}); # spent 170ms making 757 calls to Mojo::URL::new, avg 224µs/call |
| 258 | 743 | 841µs | 758 | 389µs | $for_canonical_uri->fragment(undef) if not length $for_canonical_uri->fragment; # spent 389µs making 758 calls to Mojo::URL::fragment, avg 513ns/call |
| 259 | |||||
| 260 | # a subsequent "$schema" keyword can still change these values | ||||
| 261 | $state->@{qw(spec_version vocabularies)} = $self->_get_metaschema_info( | ||||
| 262 | 743 | 5.66ms | 758 | 97.2ms | $config_override->{metaschema_uri} // $self->METASCHEMA_URIS->{$spec_version}, # spent 97.2ms making 743 calls to JSON::Schema::Modern::_get_metaschema_info, avg 131µs/call, recursion: max depth 1, sum of overlapping time 30µs
# spent 12µs making 15 calls to JSON::Schema::Modern::METASCHEMA_URIS, avg 800ns/call |
| 263 | $for_canonical_uri, | ||||
| 264 | ); | ||||
| 265 | } | ||||
| 266 | catch ($e) { | ||||
| 267 | if ($e->$_isa('JSON::Schema::Modern::Result')) { | ||||
| 268 | push $state->{errors}->@*, $e->errors; | ||||
| 269 | } | ||||
| 270 | elsif ($e->$_isa('JSON::Schema::Modern::Error')) { | ||||
| 271 | push $state->{errors}->@*, $e; | ||||
| 272 | } | ||||
| 273 | else { | ||||
| 274 | ()= E({ %$state, exception => 1 }, 'EXCEPTION: '.$e); | ||||
| 275 | } | ||||
| 276 | |||||
| 277 | return $state; | ||||
| 278 | } | ||||
| 279 | |||||
| 280 | 743 | 278µs | try { | ||
| 281 | 743 | 2.15ms | 743 | 642ms | $self->_traverse_subschema($schema_reference, $state); # spent 642ms making 743 calls to JSON::Schema::Modern::_traverse_subschema, avg 864µs/call |
| 282 | } | ||||
| 283 | catch ($e) { | ||||
| 284 | if ($e->$_isa('JSON::Schema::Modern::Error')) { | ||||
| 285 | # note: we should never be here, since traversal subs are no longer be fatal | ||||
| 286 | push $state->{errors}->@*, $e; | ||||
| 287 | } | ||||
| 288 | else { | ||||
| 289 | E({ %$state, exception => 1 }, 'EXCEPTION: '.$e); | ||||
| 290 | } | ||||
| 291 | } | ||||
| 292 | |||||
| 293 | 743 | 447µs | delete $state->{traverse}; | ||
| 294 | 743 | 1.96ms | return $state; | ||
| 295 | } | ||||
| 296 | |||||
| 297 | # the actual runtime evaluation of the schema against input data. | ||||
| 298 | 5 | 0s | # spent 97.6s (319ms+97.3) within JSON::Schema::Modern::evaluate which was called:
# once (319ms+97.3s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 147 of JSON/Schema/Modern/Document/OpenAPI.pm | ||
| 299 | 1 | 1µs | croak 'evaluate called in void context' if not defined wantarray; | ||
| 300 | |||||
| 301 | 1 | 1µs | my $initial_path = $config_override->{traversed_schema_path} // ''; | ||
| 302 | 1 | 2µs | 1 | 194µs | my $effective_base_uri = Mojo::URL->new($config_override->{effective_base_uri}//''); # spent 194µs making 1 call to Mojo::URL::new |
| 303 | |||||
| 304 | my $state = { | ||||
| 305 | 1 | 5µs | 1 | 3µs | data_path => $config_override->{data_path} // '', # spent 3µs making 1 call to Mojo::URL::new |
| 306 | traversed_schema_path => $initial_path, # the accumulated path as of the start of evaluation, or last $id or $ref | ||||
| 307 | initial_schema_uri => Mojo::URL->new, # the canonical URI as of the start of evaluation, or last $id or $ref | ||||
| 308 | schema_path => '', # the rest of the path, since the start of evaluation, or last $id or $ref | ||||
| 309 | effective_base_uri => $effective_base_uri, # resolve locations against this for errors and annotations | ||||
| 310 | errors => [], | ||||
| 311 | }; | ||||
| 312 | |||||
| 313 | 1 | 1µs | my $valid; | ||
| 314 | 1 | 0s | try { | ||
| 315 | 1 | 0s | my $schema_info; | ||
| 316 | |||||
| 317 | 1 | 4µs | 1 | 16µs | if (not is_ref($schema_reference) or $schema_reference->$_isa('Mojo::URL')) { # spent 16µs making 1 call to Safe::Isa::__ANON__[Safe/Isa.pm:23] |
| 318 | 1 | 4µs | 1 | 651µs | $schema_info = $self->_fetch_from_uri($schema_reference); # spent 651µs making 1 call to JSON::Schema::Modern::_fetch_from_uri |
| 319 | 1 | 4µs | 1 | 162µs | $state->{initial_schema_uri} = Mojo::URL->new($config_override->{initial_schema_uri} // ''); # spent 162µs making 1 call to Mojo::URL::new |
| 320 | } | ||||
| 321 | else { | ||||
| 322 | # traverse is called via add_schema -> ::Document->new -> ::Document->BUILD | ||||
| 323 | my $document = $self->add_schema('', $schema_reference); | ||||
| 324 | my $base_resource = $document->_get_resource($document->canonical_uri) | ||||
| 325 | || croak "couldn't get resource: document parse error"; | ||||
| 326 | |||||
| 327 | $schema_info = { | ||||
| 328 | schema => $document->schema, | ||||
| 329 | document => $document, | ||||
| 330 | document_path => '', | ||||
| 331 | $base_resource->%{qw(canonical_uri specification_version vocabularies configs)}, | ||||
| 332 | }; | ||||
| 333 | } | ||||
| 334 | |||||
| 335 | 1 | 1µs | abort($state, 'EXCEPTION: unable to find resource %s', $schema_reference) | ||
| 336 | if not $schema_info; | ||||
| 337 | |||||
| 338 | $state = +{ | ||||
| 339 | %$state, | ||||
| 340 | depth => 0, | ||||
| 341 | initial_schema_uri => $schema_info->{canonical_uri}, # the canonical URI as of the start of evaluation, or last $id or $ref | ||||
| 342 | document => $schema_info->{document}, # the ::Document object containing this schema | ||||
| 343 | document_path => $schema_info->{document_path}, # the path within the document of this schema, as of the start of evaluation, or last $id or $ref | ||||
| 344 | dynamic_scope => [ $schema_info->{canonical_uri} ], | ||||
| 345 | annotations => [], | ||||
| 346 | seen => {}, | ||||
| 347 | spec_version => $schema_info->{specification_version}, | ||||
| 348 | vocabularies => $schema_info->{vocabularies}, | ||||
| 349 | callbacks => $config_override->{callbacks} // {}, | ||||
| 350 | evaluator => $self, | ||||
| 351 | $schema_info->{configs}->%*, | ||||
| 352 | (map { | ||||
| 353 | 7 | 41µs | 6 | 58µs | my $val = $config_override->{$_} // $self->$_; # spent 25µs making 1 call to JSON::Schema::Modern::validate_content_schemas
# spent 23µs making 1 call to JSON::Schema::Modern::short_circuit
# spent 3µs making 1 call to JSON::Schema::Modern::collect_annotations
# spent 3µs making 1 call to JSON::Schema::Modern::scalarref_booleans
# spent 3µs making 1 call to JSON::Schema::Modern::validate_formats
# spent 1µs making 1 call to JSON::Schema::Modern::strict |
| 354 | 6 | 0s | defined $val ? ( $_ => $val ) : () | ||
| 355 | } qw(validate_formats validate_content_schemas short_circuit collect_annotations scalarref_booleans strict)), | ||||
| 356 | }; | ||||
| 357 | |||||
| 358 | 1 | 49µs | 1 | 97.2s | $valid = $self->_eval_subschema($data, $schema_info->{schema}, $state); # spent 97.2s making 1 call to JSON::Schema::Modern::_eval_subschema |
| 359 | 1 | 65µs | warn 'result is false but there are no errors' if not $valid and not $state->{errors}->@*; | ||
| 360 | } | ||||
| 361 | catch ($e) { | ||||
| 362 | if ($e->$_isa('JSON::Schema::Modern::Result')) { | ||||
| 363 | return $e; | ||||
| 364 | } | ||||
| 365 | elsif ($e->$_isa('JSON::Schema::Modern::Error')) { | ||||
| 366 | push $state->{errors}->@*, $e; | ||||
| 367 | } | ||||
| 368 | else { | ||||
| 369 | $valid = E({ %$state, exception => 1 }, 'EXCEPTION: '.$e); | ||||
| 370 | } | ||||
| 371 | } | ||||
| 372 | |||||
| 373 | 1 | 20µs | die 'evaluate validity inconstent with error count' if $valid xor !$state->{errors}->@*; | ||
| 374 | |||||
| 375 | return JSON::Schema::Modern::Result->new( | ||||
| 376 | output_format => $self->output_format, | ||||
| 377 | valid => $valid, | ||||
| 378 | $valid | ||||
| 379 | # strip annotations from result if user didn't explicitly ask for them | ||||
| 380 | ? ($config_override->{collect_annotations} // $self->collect_annotations | ||||
| 381 | ? (annotations => $state->{annotations}) : ()) | ||||
| 382 | 1 | 319ms | 3 | 6.66ms | : (errors => $state->{errors}), # spent 6.49ms making 1 call to JSON::Schema::Modern::Result::new
# spent 103µs making 1 call to JSON::Schema::Modern::output_format
# spent 66µs making 1 call to JSON::Schema::Modern::collect_annotations |
| 383 | ); | ||||
| 384 | } | ||||
| 385 | |||||
| 386 | sub validate_schema ($self, $schema, $config_override = {}) { | ||||
| 387 | croak 'validate_schema called in void context' if not defined wantarray; | ||||
| 388 | |||||
| 389 | my $metaschema_uri = is_plain_hashref($schema) && $schema->{'$schema'} ? $schema->{'$schema'} | ||||
| 390 | : $self->METASCHEMA_URIS->{$self->specification_version // $self->SPECIFICATION_VERSION_DEFAULT}; | ||||
| 391 | |||||
| 392 | return $self->evaluate($schema, $metaschema_uri, $config_override); | ||||
| 393 | } | ||||
| 394 | |||||
| 395 | sub get ($self, $uri) { | ||||
| 396 | my $schema_info = $self->_fetch_from_uri($uri); | ||||
| 397 | return if not $schema_info; | ||||
| 398 | my $subschema = is_ref($schema_info->{schema}) ? dclone($schema_info->{schema}) : $schema_info->{schema}; | ||||
| 399 | return wantarray ? ($subschema, $schema_info->{canonical_uri}) : $subschema; | ||||
| 400 | } | ||||
| 401 | |||||
| 402 | # defined lower down: | ||||
| 403 | # sub add_vocabulary { ... } | ||||
| 404 | # sub add_encoding { ... } | ||||
| 405 | # sub add_media_type { ... } | ||||
| 406 | |||||
| 407 | ######## NO PUBLIC INTERFACES FOLLOW THIS POINT ######## | ||||
| 408 | |||||
| 409 | # current spec version => { keyword => undef, or arrayref of alternatives } | ||||
| 410 | 1 | 13µs | my %removed_keywords = ( | ||
| 411 | 'draft7' => { | ||||
| 412 | id => [ '$id' ], | ||||
| 413 | }, | ||||
| 414 | 'draft2019-09' => { | ||||
| 415 | id => [ '$id' ], | ||||
| 416 | definitions => [ '$defs' ], | ||||
| 417 | dependencies => [ qw(dependentSchemas dependentRequired) ], | ||||
| 418 | }, | ||||
| 419 | 'draft2020-12' => { | ||||
| 420 | id => [ '$id' ], | ||||
| 421 | definitions => [ '$defs' ], | ||||
| 422 | dependencies => [ qw(dependentSchemas dependentRequired) ], | ||||
| 423 | '$recursiveAnchor' => [ '$dynamicAnchor' ], | ||||
| 424 | '$recursiveRef' => [ '$dynamicRef' ], | ||||
| 425 | additionalItems => [ 'items' ], | ||||
| 426 | }, | ||||
| 427 | ); | ||||
| 428 | |||||
| 429 | 11424 | 3.00ms | # spent 642ms (170+472) within JSON::Schema::Modern::_traverse_subschema which was called 2856 times, avg 225µs/call:
# 1340 times (76.5ms+-76.5ms) by JSON::Schema::Modern::Vocabulary::traverse_object_schemas at line 55 of JSON/Schema/Modern/Vocabulary.pm, avg 0s/call
# 743 times (62.4ms+580ms) by JSON::Schema::Modern::traverse at line 281, avg 864µs/call
# 561 times (19.6ms+-19.6ms) by JSON::Schema::Modern::Vocabulary::traverse_subschema at line 34 of JSON/Schema/Modern/Vocabulary.pm, avg 0s/call
# 205 times (11.6ms+-11.6ms) by JSON::Schema::Modern::Vocabulary::traverse_array_schemas at line 44 of JSON/Schema/Modern/Vocabulary.pm, avg 0s/call
# 7 times (204µs+-204µs) by JSON::Schema::Modern::Vocabulary::traverse_property_schema at line 64 of JSON/Schema/Modern/Vocabulary.pm, avg 0s/call | ||
| 430 | 2856 | 911µs | delete $state->{keyword}; | ||
| 431 | |||||
| 432 | return E($state, 'EXCEPTION: maximum traversal depth exceeded') | ||||
| 433 | 2856 | 4.68ms | 2856 | 3.87ms | if $state->{depth}++ > $self->max_traversal_depth; # spent 3.87ms making 2856 calls to JSON::Schema::Modern::max_traversal_depth, avg 1µs/call |
| 434 | |||||
| 435 | 2856 | 3.30ms | 2856 | 9.04ms | my $schema_type = get_type($schema); # spent 9.04ms making 2856 calls to JSON::Schema::Modern::Utilities::get_type, avg 3µs/call |
| 436 | 2856 | 1.26ms | return 1 if $schema_type eq 'boolean'; | ||
| 437 | |||||
| 438 | 2483 | 473µs | return E($state, 'invalid schema type: %s', $schema_type) if $schema_type ne 'object'; | ||
| 439 | |||||
| 440 | 2483 | 1.38ms | return 1 if not keys %$schema; | ||
| 441 | |||||
| 442 | 2480 | 349µs | my $valid = 1; | ||
| 443 | 2480 | 10.1ms | my %unknown_keywords = map +($_ => undef), keys %$schema; | ||
| 444 | # we must check the array length on every iteration because some keywords can change it! | ||||
| 445 | 2480 | 13.6ms | for (my $idx = 0; $idx <= $state->{vocabularies}->$#*; ++$idx) { | ||
| 446 | 19378 | 6.90ms | my $vocabulary = $state->{vocabularies}[$idx]; | ||
| 447 | 19378 | 47.4ms | 19378 | 75.7ms | foreach my $keyword ($vocabulary->keywords($state->{spec_version})) { # spent 37.4ms making 2480 calls to JSON::Schema::Modern::Vocabulary::Applicator::keywords, avg 15µs/call
# spent 8.59ms making 2480 calls to JSON::Schema::Modern::Vocabulary::Unevaluated::keywords, avg 3µs/call
# spent 7.89ms making 2480 calls to JSON::Schema::Modern::Vocabulary::Validation::keywords, avg 3µs/call
# spent 7.26ms making 2480 calls to JSON::Schema::Modern::Vocabulary::Core::keywords, avg 3µs/call
# spent 5.03ms making 2480 calls to JSON::Schema::Modern::Vocabulary::Content::keywords, avg 2µs/call
# spent 4.89ms making 2480 calls to JSON::Schema::Modern::Vocabulary::MetaData::keywords, avg 2µs/call
# spent 2.46ms making 2018 calls to JSON::Schema::Modern::Vocabulary::OpenAPI::keywords, avg 1µs/call
# spent 2.18ms making 2480 calls to JSON::Schema::Modern::Vocabulary::FormatAnnotation::keywords, avg 880ns/call |
| 448 | 149432 | 18.3ms | next if not exists $schema->{$keyword}; | ||
| 449 | |||||
| 450 | # keywords adjacent to $ref are not evaluated before draft2019-09 | ||||
| 451 | 4381 | 1.70ms | next if $keyword ne '$ref' and exists $schema->{'$ref'} and $state->{spec_version} eq 'draft7'; | ||
| 452 | |||||
| 453 | 4381 | 1.52ms | delete $unknown_keywords{$keyword}; | ||
| 454 | 4381 | 1.28ms | $state->{keyword} = $keyword; | ||
| 455 | 4381 | 8.00ms | 4381 | 1.86ms | my $method = '_traverse_keyword_'.($keyword =~ s/^\$//r); # spent 1.86ms making 4381 calls to JSON::Schema::Modern::CORE:subst, avg 425ns/call |
| 456 | |||||
| 457 | 4381 | 8.00ms | 4381 | 991ms | if (not $vocabulary->$method($schema, $state)) { # spent 360ms making 387 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_properties, avg 929µs/call, recursion: max depth 3, sum of overlapping time 34.2ms
# spent 165ms making 703 calls to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_ref, avg 235µs/call
# spent 101ms making 98 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_items, avg 1.03ms/call, recursion: max depth 1, sum of overlapping time 3.98ms
# spent 94.5ms making 12 calls to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_defs, avg 7.87ms/call, recursion: max depth 1, sum of overlapping time 13.6ms
# spent 73.9ms making 276 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_required, avg 268µs/call
# spent 37.9ms making 1381 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_type, avg 27µs/call
# spent 39.4ms making 130 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_additionalProperties, avg 303µs/call, recursion: max depth 1, sum of overlapping time 7.30ms
# spent 25.4ms making 23 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_allOf, avg 1.10ms/call
# spent 19.5ms making 65 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_then, avg 300µs/call
# spent 18.9ms making 32 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_anyOf, avg 590µs/call, recursion: max depth 1, sum of overlapping time 186µs
# spent 15.9ms making 22 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_oneOf, avg 723µs/call
# spent 15.0ms making 65 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_if, avg 230µs/call
# spent 12.3ms making 60 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_enum, avg 205µs/call
# spent 6.74ms making 3 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_contains, avg 2.25ms/call
# spent 6.00ms making 2 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_dependentSchemas, avg 3.00ms/call
# spent 5.94ms making 11 calls to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_vocabulary, avg 540µs/call
# spent 5.94ms making 14 calls to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_id, avg 424µs/call
# spent 5.63ms making 22 calls to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_dynamicRef, avg 256µs/call
# spent 5.62ms making 156 calls to JSON::Schema::Modern::Vocabulary::Unevaluated::_traverse_keyword_unevaluatedProperties, avg 36µs/call
# spent 4.58ms making 15 calls to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema, avg 305µs/call
# spent 4.33ms making 69 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_pattern, avg 63µs/call
# spent 4.10ms making 14 calls to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_dynamicAnchor, avg 293µs/call
# spent 3.69ms making 15 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_else, avg 246µs/call
# spent 3.63ms making 14 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_propertyNames, avg 259µs/call
# spent 2.64ms making 135 calls to JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_readOnly, avg 20µs/call
# spent 2.33ms making 118 calls to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_comment, avg 20µs/call
# spent 1.82ms making 7 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_patternProperties, avg 260µs/call
# spent 1.72ms making 14 calls to JSON::Schema::Modern::Vocabulary::Applicator::_traverse_keyword_not, avg 123µs/call
# spent 1.38ms making 97 calls to JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_description, avg 14µs/call
# spent 1.07ms making 50 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minProperties, avg 21µs/call
# spent 718µs making 50 calls to JSON::Schema::Modern::Vocabulary::FormatAnnotation::_traverse_keyword_format, avg 14µs/call
# spent 532µs making 34 calls to JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_title, avg 16µs/call
# spent 368µs making 21 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minimum, avg 18µs/call
# spent 362µs making 1 call to JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_anchor
# spent 265µs making 14 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minItems, avg 19µs/call
# spent 222µs making 8 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxLength, avg 28µs/call
# spent 210µs making 15 calls to JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_deprecated, avg 14µs/call
# spent 181µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentSchema
# spent 176µs making 8 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minLength, avg 22µs/call
# spent 150µs making 8 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maximum, avg 19µs/call
# spent 108µs making 95 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_const, avg 1µs/call
# spent 82µs making 3 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxProperties, avg 27µs/call
# spent 76µs making 3 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_uniqueItems, avg 25µs/call
# spent 66µs making 2 calls to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxContains, avg 33µs/call
# spent 63µs making 98 calls to JSON::Schema::Modern::Vocabulary::MetaData::_traverse_keyword_default, avg 643ns/call
# spent 60µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_dependentRequired
# spent 36µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::_traverse_keyword_contentMediaType
# spent 29µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_maxItems
# spent 19µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_exclusiveMinimum
# spent 18µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::_traverse_keyword_minContains
# spent 5µs making 5 calls to JSON::Schema::Modern::Vocabulary::OpenAPI::_traverse_keyword_externalDocs, avg 1µs/call |
| 458 | die 'traverse returned false but we have no errors' if not $state->{errors}->@*; | ||||
| 459 | $valid = 0; | ||||
| 460 | next; | ||||
| 461 | } | ||||
| 462 | |||||
| 463 | 4381 | 2.72ms | if (my $sub = $state->{callbacks}{$keyword}) { | ||
| 464 | $sub->($schema, $state); | ||||
| 465 | } | ||||
| 466 | } | ||||
| 467 | } | ||||
| 468 | |||||
| 469 | 2480 | 844µs | delete $state->{keyword}; | ||
| 470 | |||||
| 471 | 2480 | 3.45ms | 2480 | 2.72ms | if ($self->strict and keys %unknown_keywords) { # spent 2.72ms making 2480 calls to JSON::Schema::Modern::strict, avg 1µs/call |
| 472 | ()= E($state, 'unknown keyword%s found: %s', keys %unknown_keywords > 1 ? 's' : '', | ||||
| 473 | join(', ', sort keys %unknown_keywords)); | ||||
| 474 | } | ||||
| 475 | |||||
| 476 | # check for previously-supported but now removed keywords | ||||
| 477 | 2480 | 12.1ms | 2480 | 2.92ms | foreach my $keyword (sort keys $removed_keywords{$state->{spec_version}}->%*) { # spent 2.92ms making 2480 calls to JSON::Schema::Modern::CORE:sort, avg 1µs/call |
| 478 | 14880 | 1.49ms | next if not exists $schema->{$keyword}; | ||
| 479 | my $message ='no-longer-supported "'.$keyword.'" keyword present (at location "' | ||||
| 480 | .canonical_uri($state).'")'; | ||||
| 481 | if (my $alternates = $removed_keywords{$state->{spec_version}}->{$keyword}) { | ||||
| 482 | my @list = map '"'.$_.'"', @$alternates; | ||||
| 483 | @list = ((map $_.',', @list[0..$#list-1]), $list[-1]) if @list > 2; | ||||
| 484 | splice(@list, -1, 0, 'or') if @list > 1; | ||||
| 485 | $message .= ': this should be rewritten as '.join(' ', @list); | ||||
| 486 | } | ||||
| 487 | carp $message; | ||||
| 488 | } | ||||
| 489 | |||||
| 490 | 2480 | 5.37ms | return $valid; | ||
| 491 | } | ||||
| 492 | |||||
| 493 | 457975 | 84.0ms | # spent 97.2s (12.2+85.1) within JSON::Schema::Modern::_eval_subschema which was called 91595 times, avg 1.06ms/call:
# 49887 times (5.72s+-5.72s) by JSON::Schema::Modern::Vocabulary::eval at line 68 of JSON/Schema/Modern/Vocabulary.pm, avg 0s/call
# 41707 times (6.45s+-6.45s) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 89 of JSON/Schema/Modern/Vocabulary.pm, avg 0s/call
# once (19.9ms+97.2s) by JSON::Schema::Modern::evaluate at line 358 | ||
| 494 | 91595 | 26.2ms | croak '_eval_subschema called in void context' if not defined wantarray; | ||
| 495 | |||||
| 496 | # callers created a new $state for us, so we do not propagate upwards changes to depth, traversed | ||||
| 497 | # paths; but annotations, errors are arrayrefs so their contents will be shared | ||||
| 498 | 91595 | 110ms | $state->{dynamic_scope} = [ ($state->{dynamic_scope}//[])->@* ]; | ||
| 499 | 91595 | 2.19s | 2015087 | 238ms | delete $state->@{'keyword', grep /^_/, keys %$state}; # spent 238ms making 2015087 calls to JSON::Schema::Modern::CORE:match, avg 118ns/call |
| 500 | |||||
| 501 | abort($state, 'EXCEPTION: maximum evaluation depth exceeded') | ||||
| 502 | 91595 | 205ms | 91595 | 156ms | if $state->{depth}++ > $self->max_traversal_depth; # spent 156ms making 91595 calls to JSON::Schema::Modern::max_traversal_depth, avg 2µs/call |
| 503 | |||||
| 504 | # find all schema locations in effect at this data path + canonical_uri combination | ||||
| 505 | # if any of them are absolute prefix of this schema location, we are in a loop. | ||||
| 506 | 91595 | 104ms | 91595 | 4.21s | my $canonical_uri = canonical_uri($state); # spent 4.21s making 91595 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 46µs/call |
| 507 | 91595 | 64.8ms | my $schema_location = $state->{traversed_schema_path}.$state->{schema_path}; | ||
| 508 | abort($state, 'EXCEPTION: infinite loop detected (same location evaluated twice)') | ||||
| 509 | if grep substr($schema_location, 0, length) eq $_, | ||||
| 510 | 91595 | 425ms | 91595 | 8.16s | keys $state->{seen}{$state->{data_path}}{$canonical_uri}->%*; # spent 8.16s making 91595 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 89µs/call |
| 511 | 91595 | 318ms | 91595 | 6.92s | $state->{seen}{$state->{data_path}}{$canonical_uri}{$schema_location}++; # spent 6.92s making 91595 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 76µs/call |
| 512 | |||||
| 513 | 91595 | 127ms | 91595 | 179ms | my $schema_type = get_type($schema); # spent 179ms making 91595 calls to JSON::Schema::Modern::Utilities::get_type, avg 2µs/call |
| 514 | 91595 | 34.9ms | return $schema || E($state, 'subschema is false') if $schema_type eq 'boolean'; | ||
| 515 | |||||
| 516 | # this should never happen, due to checks in traverse | ||||
| 517 | 91595 | 24.4ms | abort($state, 'invalid schema type: %s', $schema_type) if $schema_type ne 'object'; | ||
| 518 | |||||
| 519 | 91595 | 31.6ms | return 1 if not keys %$schema; | ||
| 520 | |||||
| 521 | 91595 | 20.0ms | my $valid = 1; | ||
| 522 | 91595 | 318ms | my %unknown_keywords = map +($_ => undef), keys %$schema; | ||
| 523 | 91595 | 31.7ms | my $orig_annotations = $state->{annotations}; | ||
| 524 | 91595 | 39.6ms | $state->{annotations} = []; | ||
| 525 | 91595 | 18.4ms | my @new_annotations; | ||
| 526 | |||||
| 527 | 91595 | 91.5ms | my @vocabularies = $state->{vocabularies}->@*; # override locally only (copy, not reference) | ||
| 528 | 91595 | 35.2ms | if ($state->{validate_formats}) { | ||
| 529 | 91595 | 931ms | 641165 | 232ms | s/^JSON::Schema::Modern::Vocabulary::Format\KAnnotation$/Assertion/ foreach @vocabularies; # spent 232ms making 641165 calls to JSON::Schema::Modern::CORE:subst, avg 363ns/call |
| 530 | 91595 | 73.9ms | require JSON::Schema::Modern::Vocabulary::FormatAssertion; | ||
| 531 | } | ||||
| 532 | |||||
| 533 | ALL_KEYWORDS: | ||||
| 534 | 91595 | 49.7ms | foreach my $vocabulary (@vocabularies) { | ||
| 535 | 641165 | 1.97s | 641165 | 2.93s | foreach my $keyword ($vocabulary->keywords($state->{spec_version})) { # spent 1.52s making 91595 calls to JSON::Schema::Modern::Vocabulary::Applicator::keywords, avg 17µs/call
# spent 333ms making 91595 calls to JSON::Schema::Modern::Vocabulary::Unevaluated::keywords, avg 4µs/call
# spent 325ms making 91595 calls to JSON::Schema::Modern::Vocabulary::Validation::keywords, avg 4µs/call
# spent 324ms making 91595 calls to JSON::Schema::Modern::Vocabulary::Core::keywords, avg 4µs/call
# spent 191ms making 91595 calls to JSON::Schema::Modern::Vocabulary::MetaData::keywords, avg 2µs/call
# spent 155ms making 91595 calls to JSON::Schema::Modern::Vocabulary::Content::keywords, avg 2µs/call
# spent 85.7ms making 91595 calls to JSON::Schema::Modern::Vocabulary::FormatAssertion::keywords, avg 936ns/call |
| 536 | 5220915 | 725ms | next if not exists $schema->{$keyword}; | ||
| 537 | |||||
| 538 | # keywords adjacent to $ref are not evaluated before draft2019-09 | ||||
| 539 | 308273 | 91.2ms | next if $keyword ne '$ref' and exists $schema->{'$ref'} and $state->{spec_version} eq 'draft7'; | ||
| 540 | |||||
| 541 | 308273 | 94.7ms | delete $unknown_keywords{$keyword}; | ||
| 542 | 308273 | 92.9ms | $state->{keyword} = $keyword; | ||
| 543 | |||||
| 544 | 308273 | 565ms | 308273 | 141ms | my $method = '_eval_keyword_'.($keyword =~ s/^\$//r); # spent 141ms making 308273 calls to JSON::Schema::Modern::CORE:subst, avg 459ns/call |
| 545 | 308273 | 1.08s | 308273 | 525ms | if (my $sub = $vocabulary->can($method)) { # spent 525ms making 308273 calls to UNIVERSAL::can, avg 2µs/call |
| 546 | 202718 | 66.2ms | my $error_count = $state->{errors}->@*; | ||
| 547 | |||||
| 548 | 202718 | 318ms | 202718 | 601s | if (not $sub->($vocabulary, $data, $schema, $state)) { # spent 1036s making 39121 calls to JSON::Schema::Modern::Vocabulary::Core::_eval_keyword_ref, avg 26.5ms/call, recursion: max depth 31, sum of overlapping time 939s
# spent 391s making 32492 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_properties, avg 12.0ms/call, recursion: max depth 10, sum of overlapping time 294s
# spent 185s making 3616 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_patternProperties, avg 51.2ms/call, recursion: max depth 3, sum of overlapping time 105s
# spent 77.0s making 3013 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_if, avg 25.6ms/call, recursion: max depth 1, sum of overlapping time 4.31s
# spent 262s making 6002 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_allOf, avg 43.6ms/call, recursion: max depth 13, sum of overlapping time 190s
# spent 141s making 2586 calls to JSON::Schema::Modern::Vocabulary::Core::_eval_keyword_dynamicRef, avg 54.5ms/call, recursion: max depth 6, sum of overlapping time 72.9s
# spent 108s making 977 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_additionalProperties, avg 111ms/call, recursion: max depth 4, sum of overlapping time 40.8s
# spent 26.5s making 1758 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_items, avg 15.1ms/call, recursion: max depth 4, sum of overlapping time 2.66s
# spent 6.46s making 25860 calls to JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_title, avg 250µs/call
# spent 4.33s making 305 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_dependentSchemas, avg 14.2ms/call
# spent 3.16s making 1182 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_anyOf, avg 2.68ms/call
# spent 1.99s making 3747 calls to JSON::Schema::Modern::Vocabulary::Unevaluated::_eval_keyword_unevaluatedProperties, avg 531µs/call
# spent 1.87s making 25862 calls to JSON::Schema::Modern::Vocabulary::Core::_eval_keyword_id, avg 72µs/call
# spent 1.20s making 5174 calls to JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_description, avg 233µs/call
# spent 1.09s making 2230 calls to JSON::Schema::Modern::Vocabulary::FormatAssertion::_eval_keyword_format, avg 487µs/call
# spent 896ms making 35648 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_type, avg 25µs/call
# spent 496ms making 627 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_propertyNames, avg 791µs/call
# spent 446ms making 4795 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_required, avg 93µs/call
# spent 350ms making 1180 calls to JSON::Schema::Modern::Vocabulary::MetaData::_eval_keyword_default, avg 297µs/call
# spent 324ms making 305 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_oneOf, avg 1.06ms/call
# spent 273ms making 1208 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_const, avg 226µs/call
# spent 218ms making 1538 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_enum, avg 141µs/call
# spent 80.0ms making 1403 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_uniqueItems, avg 57µs/call
# spent 9.58ms making 1244 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minItems, avg 8µs/call
# spent 6.07ms making 262 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_pattern, avg 23µs/call
# spent 4.38ms making 485 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minProperties, avg 9µs/call
# spent 2.63ms making 4 calls to JSON::Schema::Modern::Vocabulary::Applicator::_eval_keyword_not, avg 657µs/call
# spent 1.42ms making 79 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_minimum, avg 18µs/call
# spent 107µs making 15 calls to JSON::Schema::Modern::Vocabulary::Validation::_eval_keyword_maxProperties, avg 7µs/call |
| 549 | warn 'result is false but there are no errors (keyword: '.$keyword.')' | ||||
| 550 | 4283 | 2.68ms | if $error_count == $state->{errors}->@*; | ||
| 551 | 4283 | 1.16ms | $valid = 0; | ||
| 552 | |||||
| 553 | 4283 | 1.01ms | last ALL_KEYWORDS if $state->{short_circuit}; | ||
| 554 | 4283 | 3.52ms | next; | ||
| 555 | } | ||||
| 556 | } | ||||
| 557 | |||||
| 558 | 303990 | 222ms | 41641 | 128ms | if (my $sub = $state->{callbacks}{$keyword}) { # spent 118ms making 39055 calls to JSON::Schema::Modern::Document::OpenAPI::__ANON__[JSON/Schema/Modern/Document/OpenAPI.pm:144], avg 3µs/call
# spent 10.5ms making 2586 calls to JSON::Schema::Modern::Document::OpenAPI::__ANON__[JSON/Schema/Modern/Document/OpenAPI.pm:140], avg 4µs/call |
| 559 | $sub->($data, $schema, $state); | ||||
| 560 | } | ||||
| 561 | |||||
| 562 | 303990 | 429ms | push @new_annotations, $state->{annotations}->@[$#new_annotations+1 .. $state->{annotations}->$#*]; | ||
| 563 | } | ||||
| 564 | } | ||||
| 565 | |||||
| 566 | 91595 | 45.8ms | delete $state->{keyword}; | ||
| 567 | |||||
| 568 | 91595 | 31.4ms | if ($state->{strict} and keys %unknown_keywords) { | ||
| 569 | abort($state, 'unknown keyword%s found: %s', keys %unknown_keywords > 1 ? 's' : '', | ||||
| 570 | join(', ', sort keys %unknown_keywords)); | ||||
| 571 | } | ||||
| 572 | |||||
| 573 | 91595 | 79.4ms | $state->{annotations} = $orig_annotations; | ||
| 574 | |||||
| 575 | 91595 | 72.0ms | if ($valid) { | ||
| 576 | 87312 | 153ms | push $state->{annotations}->@*, @new_annotations; | ||
| 577 | 87312 | 724ms | 349244 | 243ms | if ($state->{collect_annotations} and $state->{spec_version} !~ qr/^draft(7|2019-09)$/) { # spent 87.5ms making 87311 calls to JSON::Schema::Modern::CORE:regcomp, avg 1µs/call
# spent 80.4ms making 87311 calls to JSON::Schema::Modern::CORE:qr, avg 921ns/call
# spent 51.7ms making 87311 calls to JSON::Schema::Modern::CORE:match, avg 592ns/call
# spent 23.3ms making 87311 calls to JSON::Schema::Modern::CORE:sort, avg 267ns/call |
| 578 | annotate_self(+{ %$state, keyword => $_, _unknown => 1 }, $schema) | ||||
| 579 | foreach sort keys %unknown_keywords; | ||||
| 580 | } | ||||
| 581 | } | ||||
| 582 | |||||
| 583 | 91595 | 527ms | return $valid; | ||
| 584 | } | ||||
| 585 | |||||
| 586 | has _resource_index => ( | ||||
| 587 | is => 'bare', | ||||
| 588 | isa => HashRef[my $resource_type = Dict[ | ||||
| 589 | canonical_uri => InstanceOf['Mojo::URL'], | ||||
| 590 | path => Str, | ||||
| 591 | specification_version => my $spec_version_type = Enum(SPECIFICATION_VERSIONS_SUPPORTED), | ||||
| 592 | document => InstanceOf['JSON::Schema::Modern::Document'], | ||||
| 593 | # the vocabularies used when evaluating instance data against schema | ||||
| 594 | vocabularies => ArrayRef[my $vocabulary_class_type = ClassName->where(q{$_->DOES('JSON::Schema::Modern::Vocabulary')})], | ||||
| 595 | configs => HashRef, | ||||
| 596 | slurpy HashRef[Undef], # no other fields allowed | ||||
| 597 | ]], | ||||
| 598 | handles_via => 'Hash', | ||||
| 599 | handles => { | ||||
| 600 | _add_resources => 'set', | ||||
| 601 | _get_resource => 'get', | ||||
| 602 | _remove_resource => 'delete', | ||||
| 603 | _resource_index => 'elements', | ||||
| 604 | _resource_keys => 'keys', | ||||
| 605 | _add_resources_unsafe => 'set', | ||||
| 606 | _canonical_resources => 'values', | ||||
| 607 | _resource_exists => 'exists', | ||||
| 608 | }, | ||||
| 609 | lazy => 1, | ||||
| 610 | 1 | 2µs | # spent 2µs within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:610] which was called:
# once (2µs+0s) by JSON::Schema::Modern::_assert__resource_index at line 23 of (eval 344)[Sub/Quote.pm:3] | ||
| 611 | 1 | 44µs | 14 | 21.8ms | ); # spent 11.0ms making 1 call to MooX::HandlesVia::has
# spent 5.12ms making 1 call to Types::Standard::Dict
# spent 4.29ms making 3 calls to Types::Standard::HashRef, avg 1.43ms/call
# spent 560µs making 1 call to Types::Standard::ArrayRef
# spent 524µs making 2 calls to Types::Standard::InstanceOf, avg 262µs/call
# spent 181µs making 1 call to Type::Tiny::where
# spent 93µs making 1 call to Types::Standard::Enum
# spent 60µs making 1 call to Types::Standard::slurpy
# spent 3µs making 1 call to Types::Standard::Str
# spent 2µs making 1 call to Types::Standard::ClassName
# spent 1µs making 1 call to Types::Standard::Undef |
| 612 | |||||
| 613 | # spent 10.2ms (626µs+9.59) within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:646] which was called 15 times, avg 681µs/call:
# 15 times (626µs+9.59ms) by JSON::Schema::Modern::__ANON__[(eval 346)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 329)[Class/Method/Modifiers.pm:89], avg 681µs/call | ||||
| 614 | 15 | 48µs | my ($orig, $self) = (shift, shift); | ||
| 615 | |||||
| 616 | 15 | 3µs | my @resources; | ||
| 617 | 15 | 200µs | 30 | 66µs | foreach my $pair (sort { $a->[0] cmp $b->[0] } pairs @_) { # spent 38µs making 15 calls to List::Util::pairs, avg 3µs/call
# spent 28µs making 15 calls to JSON::Schema::Modern::CORE:sort, avg 2µs/call |
| 618 | 24 | 9µs | my ($key, $value) = @$pair; | ||
| 619 | |||||
| 620 | 24 | 123µs | 72 | 5.14ms | $resource_type->($value); # check type of hash value against Dict # spent 2.90ms making 24 calls to Sub::Defer::__ANON__[Sub/Defer.pm:178], avg 121µs/call
# spent 2.24ms making 48 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 47µs/call |
| 621 | |||||
| 622 | 24 | 164µs | 44 | 1.49ms | if (my $existing = $self->_get_resource($key)) { # spent 1.37ms making 24 calls to JSON::Schema::Modern::_get_resource, avg 57µs/call
# spent 119µs making 2 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 60µs/call
# spent 9µs making 18 calls to JSON::Schema::Modern::CACHED_METASCHEMAS, avg 500ns/call |
| 623 | # we allow overwriting canonical_uri = '' to allow for ad hoc evaluation of schemas that | ||||
| 624 | # lack all identifiers altogether, but preserve other resources from the original document | ||||
| 625 | 6 | 11µs | 6 | 523µs | if ($key ne '') { # spent 523µs making 6 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 87µs/call |
| 626 | next if $existing->{path} eq $value->{path} | ||||
| 627 | and $existing->{canonical_uri} eq $value->{canonical_uri} | ||||
| 628 | and $existing->{specification_version} eq $value->{specification_version} | ||||
| 629 | 6 | 67µs | 24 | 867µs | and refaddr($existing->{document}) == refaddr($value->{document}); # spent 859µs making 12 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 72µs/call
# spent 8µs making 12 calls to Scalar::Util::refaddr, avg 667ns/call |
| 630 | croak 'uri "'.$key.'" conflicts with an existing schema resource'; | ||||
| 631 | } | ||||
| 632 | } | ||||
| 633 | elsif ($self->CACHED_METASCHEMAS->{$key}) { | ||||
| 634 | croak 'uri "'.$key.'" conflicts with an existing meta-schema resource'; | ||||
| 635 | } | ||||
| 636 | |||||
| 637 | 18 | 23µs | 18 | 19µs | my $fragment = $value->{canonical_uri}->fragment; # spent 19µs making 18 calls to Mojo::URL::fragment, avg 1µs/call |
| 638 | croak sprintf('canonical_uri cannot contain an empty fragment (%s)', $value->{canonical_uri}) | ||||
| 639 | 18 | 5µs | if defined $fragment and $fragment eq ''; | ||
| 640 | |||||
| 641 | croak sprintf('canonical_uri cannot contain a plain-name fragment (%s)', $value->{canonical_uri}) | ||||
| 642 | 18 | 30µs | 18 | 7µs | if ($fragment // '') =~ m{^[^/]}; # spent 7µs making 18 calls to JSON::Schema::Modern::CORE:match, avg 389ns/call |
| 643 | |||||
| 644 | 18 | 43µs | 18 | 562µs | $self->$orig($key, $value); # spent 562µs making 18 calls to JSON::Schema::Modern::_add_resources, avg 31µs/call |
| 645 | } | ||||
| 646 | 1 | 5µs | 1 | 189µs | }; # spent 189µs making 1 call to Moo::around |
| 647 | |||||
| 648 | # $vocabulary uri (not its $id!) => [ spec_version, class ] | ||||
| 649 | has _vocabulary_classes => ( | ||||
| 650 | is => 'bare', | ||||
| 651 | isa => HashRef[ | ||||
| 652 | Tuple[ | ||||
| 653 | $spec_version_type, | ||||
| 654 | $vocabulary_class_type, | ||||
| 655 | ] | ||||
| 656 | ], | ||||
| 657 | handles_via => 'Hash', | ||||
| 658 | handles => { | ||||
| 659 | _get_vocabulary_class => 'get', | ||||
| 660 | _set_vocabulary_class => 'set', | ||||
| 661 | _get_vocabulary_values => 'values', | ||||
| 662 | }, | ||||
| 663 | lazy => 1, | ||||
| 664 | # spent 56.5ms (118µs+56.4) within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:670] which was called:
# once (118µs+56.4ms) by JSON::Schema::Modern::_assert__vocabulary_classes at line 23 of (eval 355)[Sub/Quote.pm:3] | ||||
| 665 | +{ | ||||
| 666 | 31 | 734µs | 24 | 56.4ms | map { my $class = $_; pairmap { $a => [ $b, $class ] } $class->vocabulary } # spent 55.8ms making 8 calls to Module::Runtime::use_module, avg 6.97ms/call
# spent 631µs making 8 calls to List::Util::pairmap, avg 79µs/call
# spent 3µs making 1 call to JSON::Schema::Modern::Vocabulary::Applicator::vocabulary
# spent 2µs making 1 call to JSON::Schema::Modern::Vocabulary::Unevaluated::vocabulary
# spent 2µs making 1 call to JSON::Schema::Modern::Vocabulary::Validation::vocabulary
# spent 1µs making 1 call to JSON::Schema::Modern::Vocabulary::Content::vocabulary
# spent 1µs making 1 call to JSON::Schema::Modern::Vocabulary::Core::vocabulary
# spent 1µs making 1 call to JSON::Schema::Modern::Vocabulary::FormatAnnotation::vocabulary
# spent 1µs making 1 call to JSON::Schema::Modern::Vocabulary::FormatAssertion::vocabulary
# spent 1µs making 1 call to JSON::Schema::Modern::Vocabulary::MetaData::vocabulary |
| 667 | map use_module('JSON::Schema::Modern::Vocabulary::'.$_), | ||||
| 668 | qw(Core Applicator Validation FormatAssertion FormatAnnotation Content MetaData Unevaluated) | ||||
| 669 | } | ||||
| 670 | }, | ||||
| 671 | 1 | 15µs | 3 | 7.38ms | ); # spent 4.18ms making 1 call to Types::Standard::Tuple
# spent 2.60ms making 1 call to MooX::HandlesVia::has
# spent 594µs making 1 call to Types::Standard::HashRef |
| 672 | |||||
| 673 | 3 | 1µs | # spent 64.8ms (171µs+64.6) within JSON::Schema::Modern::add_vocabulary which was called:
# once (171µs+64.6ms) by JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas at line 182 of JSON/Schema/Modern/Document/OpenAPI.pm | ||
| 674 | 1 | 7µs | 1 | 57.1ms | return if grep $_->[1] eq $classname, $self->_get_vocabulary_values; # spent 57.1ms making 1 call to JSON::Schema::Modern::_get_vocabulary_values |
| 675 | |||||
| 676 | 1 | 11µs | 4 | 5.88ms | $vocabulary_class_type->(use_module($classname)); # spent 4.97ms making 1 call to Module::Runtime::use_module
# spent 660µs making 1 call to Sub::Defer::__ANON__[Sub/Defer.pm:178]
# spent 247µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 124µs/call |
| 677 | |||||
| 678 | # uri => version, uri => version | ||||
| 679 | 1 | 55µs | 2 | 18µs | foreach my $pair (pairs $classname->vocabulary) { # spent 18µs making 1 call to List::Util::pairs
# spent 0s making 1 call to JSON::Schema::Modern::Vocabulary::OpenAPI::vocabulary |
| 680 | 1 | 4µs | my ($uri_string, $spec_version) = @$pair; | ||
| 681 | 1 | 8µs | 5 | 1.29ms | Str->where(q{my $uri = Mojo::URL->new($_); $uri->is_abs && !defined $uri->fragment})->($uri_string); # spent 751µs making 1 call to Sub::Defer::__ANON__[Sub/Defer.pm:178]
# spent 271µs making 1 call to Type::Tiny::where
# spent 261µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 130µs/call
# spent 3µs making 1 call to Types::Standard::Str |
| 682 | 1 | 118µs | 4 | 516µs | $spec_version_type->($spec_version); # spent 486µs making 1 call to Sub::Defer::__ANON__[Sub/Defer.pm:178]
# spent 20µs making 1 call to Type::Tiny::DESTROY
# spent 10µs making 2 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 5µs/call |
| 683 | 1 | 2µs | 1 | 105µs | $self->_set_vocabulary_class($uri_string => [ $spec_version, $classname ]) # spent 105µs making 1 call to JSON::Schema::Modern::_set_vocabulary_class |
| 684 | } | ||||
| 685 | } | ||||
| 686 | |||||
| 687 | # $schema uri => [ spec_version, [ vocab classes ] ]. | ||||
| 688 | has _metaschema_vocabulary_classes => ( | ||||
| 689 | is => 'bare', | ||||
| 690 | isa => HashRef[ | ||||
| 691 | Tuple[ | ||||
| 692 | $spec_version_type, | ||||
| 693 | ArrayRef[$vocabulary_class_type], | ||||
| 694 | ] | ||||
| 695 | ], | ||||
| 696 | handles_via => 'Hash', | ||||
| 697 | handles => { | ||||
| 698 | _get_metaschema_vocabulary_classes => 'get', | ||||
| 699 | _set_metaschema_vocabulary_classes => 'set', | ||||
| 700 | __all_metaschema_vocabulary_classes => 'values', | ||||
| 701 | }, | ||||
| 702 | lazy => 1, | ||||
| 703 | # spent 108µs (14+94) within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:712] which was called:
# once (14µs+94µs) by JSON::Schema::Modern::_assert__metaschema_vocabulary_classes at line 23 of (eval 360)[Sub/Quote.pm:3] | ||||
| 704 | 1 | 7µs | 7 | 94µs | my @modules = map use_module('JSON::Schema::Modern::Vocabulary::'.$_), # spent 94µs making 7 calls to Module::Runtime::use_module, avg 13µs/call |
| 705 | qw(Core Applicator Validation FormatAnnotation Content MetaData Unevaluated); | ||||
| 706 | +{ | ||||
| 707 | 'https://json-schema.org/draft/2020-12/schema' => [ 'draft2020-12', [ @modules ] ], | ||||
| 708 | 3 | 5µs | do { pop @modules; () }, | ||
| 709 | 'https://json-schema.org/draft/2019-09/schema' => [ 'draft2019-09', \@modules ], | ||||
| 710 | 'http://json-schema.org/draft-07/schema#' => [ 'draft7', \@modules ], | ||||
| 711 | }, | ||||
| 712 | }, | ||||
| 713 | 1 | 28µs | 4 | 7.38ms | ); # spent 3.57ms making 1 call to MooX::HandlesVia::has
# spent 2.70ms making 1 call to Types::Standard::Tuple
# spent 1.03ms making 1 call to Types::Standard::HashRef
# spent 85µs making 1 call to Types::Standard::ArrayRef |
| 714 | |||||
| 715 | # retrieves metaschema info either from cache or by parsing the schema for vocabularies | ||||
| 716 | # throws a JSON::Schema::Modern::Result on error | ||||
| 717 | 2972 | 764µs | # spent 97.2ms (4.52+92.7) within JSON::Schema::Modern::_get_metaschema_info which was called 743 times, avg 131µs/call:
# 743 times (4.52ms+92.7ms) by JSON::Schema::Modern::traverse at line 262, avg 131µs/call | ||
| 718 | # check the cache | ||||
| 719 | 743 | 2.25ms | 743 | 90.5ms | my $metaschema_info = $self->_get_metaschema_vocabulary_classes($metaschema_uri); # spent 90.5ms making 743 calls to JSON::Schema::Modern::_get_metaschema_vocabulary_classes, avg 122µs/call |
| 720 | 743 | 1.70ms | return @$metaschema_info if $metaschema_info; | ||
| 721 | |||||
| 722 | # otherwise, fetch the metaschema and parse its $vocabulary keyword. | ||||
| 723 | # we do this by traversing a baby schema with just the $schema keyword. | ||||
| 724 | 1 | 8µs | 1 | 0s | my $state = $self->traverse({ '$schema' => $metaschema_uri.'' }); # spent 2.21ms making 1 call to JSON::Schema::Modern::traverse, recursion: max depth 1, sum of overlapping time 2.21ms |
| 725 | die JSON::Schema::Modern::Result->new( | ||||
| 726 | output_format => $self->output_format, | ||||
| 727 | valid => JSON::PP::false, | ||||
| 728 | errors => [ | ||||
| 729 | map { | ||||
| 730 | my $e = $_; | ||||
| 731 | # absolute location is undef iff the location = '/$schema' | ||||
| 732 | my $absolute_location = $e->absolute_keyword_location // $for_canonical_uri; | ||||
| 733 | JSON::Schema::Modern::Error->new( | ||||
| 734 | keyword => $e->keyword eq '$schema' ? '' : $e->keyword, | ||||
| 735 | instance_location => $e->instance_location, | ||||
| 736 | keyword_location => ($for_canonical_uri->fragment//'').($e->keyword_location =~ s{^/\$schema\b}{}r), | ||||
| 737 | length $absolute_location ? ( absolute_keyword_location => $absolute_location ) : (), | ||||
| 738 | error => $e->error, | ||||
| 739 | ) | ||||
| 740 | } | ||||
| 741 | $state->{errors}->@* ], | ||||
| 742 | exception => 1, | ||||
| 743 | 1 | 0s | ) if $state->{errors}->@*; | ||
| 744 | 1 | 11µs | return ($state->{spec_version}, $state->{vocabularies}); | ||
| 745 | } | ||||
| 746 | |||||
| 747 | # used for determining a default '$schema' keyword where there is none | ||||
| 748 | 1 | 1µs | # spent 73µs (16+57) within JSON::Schema::Modern::BEGIN@748 which was called:
# once (16µs+57µs) by OpenAPI::Modern::BEGIN@26 at line 752 | ||
| 749 | 'draft2020-12' => 'https://json-schema.org/draft/2020-12/schema', | ||||
| 750 | 'draft2019-09' => 'https://json-schema.org/draft/2019-09/schema', | ||||
| 751 | 'draft7' => 'http://json-schema.org/draft-07/schema#', | ||||
| 752 | 1 | 101µs | 2 | 130µs | }; # spent 73µs making 1 call to JSON::Schema::Modern::BEGIN@748
# spent 57µs making 1 call to constant::import |
| 753 | |||||
| 754 | 1 | 1µs | # spent 46µs (19+27) within JSON::Schema::Modern::BEGIN@754 which was called:
# once (19µs+27µs) by OpenAPI::Modern::BEGIN@26 at line 777 | ||
| 755 | 'https://json-schema.org/draft/2020-12/meta/applicator' => 'draft2020-12/meta/applicator.json', | ||||
| 756 | 'https://json-schema.org/draft/2020-12/meta/content' => 'draft2020-12/meta/content.json', | ||||
| 757 | 'https://json-schema.org/draft/2020-12/meta/core' => 'draft2020-12/meta/core.json', | ||||
| 758 | 'https://json-schema.org/draft/2020-12/meta/format-annotation' => 'draft2020-12/meta/format-annotation.json', | ||||
| 759 | 'https://json-schema.org/draft/2020-12/meta/format-assertion' => 'draft2020-12/meta/format-assertion.json', | ||||
| 760 | 'https://json-schema.org/draft/2020-12/meta/meta-data' => 'draft2020-12/meta/meta-data.json', | ||||
| 761 | 'https://json-schema.org/draft/2020-12/meta/unevaluated' => 'draft2020-12/meta/unevaluated.json', | ||||
| 762 | 'https://json-schema.org/draft/2020-12/meta/validation' => 'draft2020-12/meta/validation.json', | ||||
| 763 | 'https://json-schema.org/draft/2020-12/output/schema' => 'draft2020-12/output/schema.json', | ||||
| 764 | 'https://json-schema.org/draft/2020-12/schema' => 'draft2020-12/schema.json', | ||||
| 765 | |||||
| 766 | 'https://json-schema.org/draft/2019-09/meta/applicator' => 'draft2019-09/meta/applicator.json', | ||||
| 767 | 'https://json-schema.org/draft/2019-09/meta/content' => 'draft2019-09/meta/content.json', | ||||
| 768 | 'https://json-schema.org/draft/2019-09/meta/core' => 'draft2019-09/meta/core.json', | ||||
| 769 | 'https://json-schema.org/draft/2019-09/meta/format' => 'draft2019-09/meta/format.json', | ||||
| 770 | 'https://json-schema.org/draft/2019-09/meta/meta-data' => 'draft2019-09/meta/meta-data.json', | ||||
| 771 | 'https://json-schema.org/draft/2019-09/meta/validation' => 'draft2019-09/meta/validation.json', | ||||
| 772 | 'https://json-schema.org/draft/2019-09/output/schema' => 'draft2019-09/output/schema.json', | ||||
| 773 | 'https://json-schema.org/draft/2019-09/schema' => 'draft2019-09/schema.json', | ||||
| 774 | |||||
| 775 | # trailing # is omitted because we always cache documents by its canonical (fragmentless) URI | ||||
| 776 | 'http://json-schema.org/draft-07/schema' => 'draft7/schema.json', | ||||
| 777 | 1 | 1.26ms | 2 | 73µs | }; # spent 46µs making 1 call to JSON::Schema::Modern::BEGIN@754
# spent 27µs making 1 call to constant::import |
| 778 | |||||
| 779 | # returns the same as _get_resource | ||||
| 780 | 117369 | 22.2ms | # spent 6.36s (178ms+6.18) within JSON::Schema::Modern::_get_or_load_resource which was called 39123 times, avg 163µs/call:
# 39123 times (178ms+6.18s) by JSON::Schema::Modern::_fetch_from_uri at line 827, avg 163µs/call | ||
| 781 | 39123 | 76.8ms | 39123 | 6.11s | my $resource = $self->_get_resource($uri); # spent 6.11s making 39123 calls to JSON::Schema::Modern::_get_resource, avg 156µs/call |
| 782 | 39123 | 102ms | return $resource if $resource; | ||
| 783 | |||||
| 784 | 8 | 43µs | 16 | 968µs | if (my $local_filename = $self->CACHED_METASCHEMAS->{$uri}) { # spent 963µs making 8 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 120µs/call
# spent 5µs making 8 calls to JSON::Schema::Modern::CACHED_METASCHEMAS, avg 625ns/call |
| 785 | 8 | 39µs | 16 | 1.06ms | my $file = path(dist_dir('JSON-Schema-Modern'), $local_filename); # spent 970µs making 8 calls to File::ShareDir::dist_dir, avg 121µs/call
# spent 87µs making 8 calls to Path::Tiny::path, avg 11µs/call |
| 786 | 8 | 359µs | 24 | 338µs | my $schema = $self->_json_decoder->decode($file->slurp_raw); # spent 282µs making 8 calls to Cpanel::JSON::XS::decode, avg 35µs/call
# spent 29µs making 8 calls to Path::Tiny::slurp_raw, avg 4µs/call
# spent 27µs making 8 calls to JSON::Schema::Modern::_json_decoder, avg 3µs/call |
| 787 | 8 | 53µs | 8 | 59.5ms | my $document = JSON::Schema::Modern::Document->new(schema => $schema, evaluator => $self); # spent 59.5ms making 8 calls to JSON::Schema::Modern::Document::new, avg 7.44ms/call |
| 788 | |||||
| 789 | # this should be caught by the try/catch in evaluate() | ||||
| 790 | 8 | 20µs | 8 | 185µs | die JSON::Schema::Modern::Result->new( # spent 185µs making 8 calls to JSON::Schema::Modern::Document::has_errors, avg 23µs/call |
| 791 | output_format => $self->output_format, | ||||
| 792 | valid => 0, | ||||
| 793 | errors => [ $document->errors ], | ||||
| 794 | exception => 1, | ||||
| 795 | ) if $document->has_errors; | ||||
| 796 | |||||
| 797 | # we have already performed the appropriate collision checks, so we bypass them here | ||||
| 798 | 8 | 85µs | 16 | 322µs | $self->_add_resources_unsafe( # spent 207µs making 8 calls to JSON::Schema::Modern::_add_resources_unsafe, avg 26µs/call
# spent 115µs making 8 calls to JSON::Schema::Modern::Document::resource_pairs, avg 14µs/call |
| 799 | map +($_->[0] => +{ $_->[1]->%*, document => $document }), | ||||
| 800 | $document->resource_pairs | ||||
| 801 | ); | ||||
| 802 | |||||
| 803 | 8 | 58µs | 8 | 1.10ms | return $self->_get_resource($uri); # spent 1.10ms making 8 calls to JSON::Schema::Modern::_get_resource, avg 138µs/call |
| 804 | } | ||||
| 805 | |||||
| 806 | # TODO: | ||||
| 807 | # - load from network or disk | ||||
| 808 | |||||
| 809 | return; | ||||
| 810 | }; | ||||
| 811 | |||||
| 812 | # returns information necessary to use a schema found at a particular URI: | ||||
| 813 | # - a schema (which may not be at a document root) | ||||
| 814 | # - the canonical uri for that schema, | ||||
| 815 | # - the JSON::Schema::Modern::Document object that holds that schema | ||||
| 816 | # - the path relative to the document root for this schema | ||||
| 817 | # - the specification version that applies to this schema | ||||
| 818 | # - the vocabularies to use when considering schema keywords | ||||
| 819 | # - the config overrides to set when considering schema keywords | ||||
| 820 | # creates a Document and adds it to the resource index, if not already present. | ||||
| 821 | 140643 | 27.6ms | # spent 19.3s (2.16+17.1) within JSON::Schema::Modern::_fetch_from_uri which was called 46881 times, avg 412µs/call:
# 41707 times (2.07s+16.1s) by JSON::Schema::Modern::Vocabulary::eval_subschema_at_uri at line 72 of JSON/Schema/Modern/Vocabulary.pm, avg 435µs/call
# 2586 times (53.1ms+609ms) by JSON::Schema::Modern::Vocabulary::Core::_eval_keyword_dynamicRef at line 223 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 256µs/call
# 2586 times (41.4ms+441ms) by JSON::Schema::Modern::Vocabulary::Core::_eval_keyword_dynamicRef at line 235 of JSON/Schema/Modern/Vocabulary/Core.pm, avg 187µs/call
# once (73µs+578µs) by JSON::Schema::Modern::evaluate at line 318
# once (88µs+463µs) by JSON::Schema::Modern::Vocabulary::Core::_traverse_keyword_schema at line 118 of JSON/Schema/Modern/Vocabulary/Core.pm | ||
| 822 | 46881 | 18.0ms | 1 | 45µs | $uri = Mojo::URL->new($uri) if not is_ref($uri); # spent 45µs making 1 call to Mojo::URL::new |
| 823 | 46881 | 50.9ms | 46881 | 36.7ms | my $fragment = $uri->fragment; # spent 36.7ms making 46881 calls to Mojo::URL::fragment, avg 783ns/call |
| 824 | |||||
| 825 | 46881 | 63.7ms | 21018 | 17.1ms | if (not length($fragment) or $fragment =~ m{^/}) { # spent 17.1ms making 21018 calls to JSON::Schema::Modern::CORE:match, avg 814ns/call |
| 826 | 39123 | 67.9ms | 78246 | 1.96s | my $base = $uri->clone->fragment(undef); # spent 1.92s making 39123 calls to Mojo::URL::clone, avg 49µs/call
# spent 43.2ms making 39123 calls to Mojo::URL::fragment, avg 1µs/call |
| 827 | 39123 | 67.6ms | 39123 | 6.36s | if (my $resource = $self->_get_or_load_resource($base)) { # spent 6.36s making 39123 calls to JSON::Schema::Modern::_get_or_load_resource, avg 163µs/call |
| 828 | 39123 | 138ms | 39123 | 752ms | my $subschema = $resource->{document}->get(my $document_path = $resource->{path}.($fragment//'')); # spent 752ms making 39123 calls to Mojo::JSON::Pointer::get, avg 19µs/call |
| 829 | 39123 | 11.5ms | return if not defined $subschema; | ||
| 830 | 39123 | 16.5ms | my $document = $resource->{document}; | ||
| 831 | my $closest_resource = first { !length($_->[1]{path}) # document root | ||||
| 832 | 39123 | 212ms | || length($document_path) | ||
| 833 | && $document_path =~ m{^\Q$_->[1]{path}\E(?:/|\z)} } # path is above present location | ||||
| 834 | sort { length($b->[1]{path}) <=> length($a->[1]{path}) } # sort by length, descending | ||||
| 835 | 39123 | 614ms | 295795 | 5.13s | grep { not length Mojo::URL->new($_->[0])->fragment } # omit anchors # spent 4.19s making 89213 calls to Mojo::URL::new, avg 47µs/call
# spent 702ms making 39123 calls to JSON::Schema::Modern::Document::resource_pairs, avg 18µs/call
# spent 115ms making 39123 calls to List::Util::first, avg 3µs/call
# spent 72.4ms making 39123 calls to JSON::Schema::Modern::CORE:sort, avg 2µs/call
# spent 55.8ms making 89213 calls to Mojo::URL::fragment, avg 625ns/call |
| 836 | $document->resource_pairs; | ||||
| 837 | |||||
| 838 | my $canonical_uri = $closest_resource->[1]{canonical_uri}->clone | ||||
| 839 | 39123 | 136ms | 78246 | 1.38s | ->fragment(substr($document_path, length($closest_resource->[1]{path}))); # spent 1.32s making 39123 calls to Mojo::URL::clone, avg 34µs/call
# spent 67.7ms making 39123 calls to Mojo::URL::fragment, avg 2µs/call |
| 840 | 39123 | 56.6ms | 64986 | 39.7ms | $canonical_uri->fragment(undef) if not length($canonical_uri->fragment); # spent 39.7ms making 64986 calls to Mojo::URL::fragment, avg 611ns/call |
| 841 | return { | ||||
| 842 | schema => $subschema, | ||||
| 843 | canonical_uri => $canonical_uri, | ||||
| 844 | document => $document, | ||||
| 845 | document_path => $document_path, | ||||
| 846 | 39123 | 416ms | $resource->%{qw(specification_version vocabularies configs)}, # reference, not copy | ||
| 847 | }; | ||||
| 848 | } | ||||
| 849 | } | ||||
| 850 | else { # we are following a URI with a plain-name fragment | ||||
| 851 | 7758 | 12.1ms | 7758 | 1.03s | if (my $resource = $self->_get_resource($uri)) { # spent 1.03s making 7758 calls to JSON::Schema::Modern::_get_resource, avg 133µs/call |
| 852 | 7758 | 17.0ms | 7758 | 174ms | my $subschema = $resource->{document}->get($resource->{path}); # spent 174ms making 7758 calls to Mojo::JSON::Pointer::get, avg 22µs/call |
| 853 | 7758 | 946µs | return if not defined $subschema; | ||
| 854 | return { | ||||
| 855 | schema => $subschema, | ||||
| 856 | canonical_uri => $resource->{canonical_uri}->clone, # this is *not* the anchor-containing URI | ||||
| 857 | document => $resource->{document}, | ||||
| 858 | document_path => $resource->{path}, | ||||
| 859 | 7758 | 71.7ms | 7758 | 249ms | $resource->%{qw(specification_version vocabularies configs)}, # reference, not copy # spent 249ms making 7758 calls to Mojo::URL::clone, avg 32µs/call |
| 860 | }; | ||||
| 861 | } | ||||
| 862 | } | ||||
| 863 | } | ||||
| 864 | |||||
| 865 | # used for internal encoding as well (when caching serialized schemas) | ||||
| 866 | has _json_decoder => ( | ||||
| 867 | is => 'ro', | ||||
| 868 | isa => HasMethods[qw(encode decode)], | ||||
| 869 | lazy => 1, | ||||
| 870 | 1 | 7µs | 1 | 35µs | # spent 43µs (8+35) within JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:870] which was called:
# once (8µs+35µs) by JSON::Schema::Modern::_json_decoder at line 23 of (eval 362)[Sub/Quote.pm:3] # spent 35µs making 1 call to JSON::MaybeXS::new |
| 871 | 1 | 9µs | 2 | 3.72ms | ); # spent 2.37ms making 1 call to Types::Standard::HasMethods
# spent 1.35ms making 1 call to MooX::HandlesVia::has |
| 872 | |||||
| 873 | # since media types are case-insensitive, all type names must be foldcased on insertion. | ||||
| 874 | has _media_type => ( | ||||
| 875 | is => 'bare', | ||||
| 876 | isa => my $media_type_type = Map[Str->where(q{$_ eq CORE::fc($_)}), CodeRef], | ||||
| 877 | handles_via => 'Hash', | ||||
| 878 | handles => { | ||||
| 879 | get_media_type => 'get', | ||||
| 880 | add_media_type => 'set', | ||||
| 881 | _media_types => 'keys', | ||||
| 882 | }, | ||||
| 883 | lazy => 1, | ||||
| 884 | default => sub ($self) { | ||||
| 885 | my $_json_media_type = sub ($content_ref) { | ||||
| 886 | \ JSON::MaybeXS->new(allow_nonref => 1, utf8 => 0)->decode($content_ref->$*); | ||||
| 887 | }; | ||||
| 888 | +{ | ||||
| 889 | # note: utf-8 decoding is NOT done, as we can't be sure that's the correct charset! | ||||
| 890 | 'application/json' => $_json_media_type, | ||||
| 891 | 'application/schema+json' => $_json_media_type, | ||||
| 892 | 'application/schema-instance+json' => $_json_media_type, | ||||
| 893 | map +($_ => sub ($content_ref) { $content_ref }), | ||||
| 894 | qw(text/plain application/octet-stream), | ||||
| 895 | }; | ||||
| 896 | }, | ||||
| 897 | 1 | 17µs | 5 | 5.54ms | ); # spent 2.81ms making 1 call to MooX::HandlesVia::has
# spent 2.53ms making 1 call to Types::Standard::Map
# spent 196µs making 1 call to Type::Tiny::where
# spent 3µs making 1 call to Types::Standard::Str
# spent 1µs making 1 call to Types::Standard::CodeRef |
| 898 | |||||
| 899 | # get_media_type('TExT/bloop') will match an entry for 'text/*' or '*/*' | ||||
| 900 | # TODO: support queries for application/schema+json to match entry of application/json | ||||
| 901 | around get_media_type => sub ($orig, $self, $type) { | ||||
| 902 | my $mt = $self->$orig(fc $type); | ||||
| 903 | return $mt if $mt; | ||||
| 904 | |||||
| 905 | return $self->$orig((first { m{([^/]+)/\*$} && fc($type) =~ m{^\Q$1\E/[^/]+$} } $self->_media_types) | ||||
| 906 | // '*/*'); | ||||
| 907 | 1 | 5µs | 1 | 244µs | }; # spent 244µs making 1 call to Moo::around |
| 908 | |||||
| 909 | 1 | 4µs | 1 | 312µs | before add_media_type => sub ($self, $type, $sub) { $media_type_type->({ $type => $sub }) }; # spent 312µs making 1 call to Moo::before |
| 910 | |||||
| 911 | has _encoding => ( | ||||
| 912 | is => 'bare', | ||||
| 913 | isa => HashRef[CodeRef], | ||||
| 914 | handles_via => 'Hash', | ||||
| 915 | handles => { | ||||
| 916 | get_encoding => 'get', | ||||
| 917 | add_encoding => 'set', | ||||
| 918 | }, | ||||
| 919 | lazy => 1, | ||||
| 920 | default => sub ($self) { | ||||
| 921 | +{ | ||||
| 922 | identity => sub ($content_ref) { $content_ref }, | ||||
| 923 | base64 => sub ($content_ref) { | ||||
| 924 | die "invalid characters in base64 string" | ||||
| 925 | if $content_ref->$* =~ m{[^A-Za-z0-9+/=]} or $content_ref->$* =~ m{=(?=[^=])}; | ||||
| 926 | require MIME::Base64; \ MIME::Base64::decode($content_ref->$*); | ||||
| 927 | }, | ||||
| 928 | }; | ||||
| 929 | }, | ||||
| 930 | 1 | 13µs | 3 | 2.79ms | ); # spent 2.40ms making 1 call to MooX::HandlesVia::has
# spent 383µs making 1 call to Types::Standard::HashRef
# spent 3µs making 1 call to Types::Standard::CodeRef |
| 931 | |||||
| 932 | sub FREEZE ($self, $serializer) { | ||||
| 933 | my $data = +{ %$self }; | ||||
| 934 | # Cpanel::JSON::XS doesn't serialize: https://github.com/Sereal/Sereal/issues/266 | ||||
| 935 | # coderefs can't serialize cleanly and must be re-added by the user. | ||||
| 936 | delete $data->@{qw(_json_decoder _format_validations _media_type _encoding)}; | ||||
| 937 | return $data; | ||||
| 938 | } | ||||
| 939 | |||||
| 940 | sub THAW ($class, $serializer, $data) { | ||||
| 941 | my $self = bless($data, $class); | ||||
| 942 | |||||
| 943 | # load all vocabulary classes | ||||
| 944 | require_module($_) foreach uniq map $_->{vocabularies}->@*, $self->_canonical_resources; | ||||
| 945 | |||||
| 946 | return $self; | ||||
| 947 | } | ||||
| 948 | |||||
| 949 | 1 | 108µs | 1; | ||
| 950 | |||||
| 951 | 1 | 171µs | 1 | 1.55ms | __END__ # spent 1.55ms making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 14µs within JSON::Schema::Modern::CACHED_METASCHEMAS which was called 26 times, avg 538ns/call:
# 18 times (9µs+0s) by JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:646] at line 622, avg 500ns/call
# 8 times (5µs+0s) by JSON::Schema::Modern::_get_or_load_resource at line 784, avg 625ns/call | |||||
# spent 307ms within JSON::Schema::Modern::CORE:match which was called 2123434 times, avg 145ns/call:
# 2015087 times (238ms+0s) by JSON::Schema::Modern::_eval_subschema at line 499, avg 118ns/call
# 87311 times (51.7ms+0s) by JSON::Schema::Modern::_eval_subschema at line 577, avg 592ns/call
# 21018 times (17.1ms+0s) by JSON::Schema::Modern::_fetch_from_uri at line 825, avg 814ns/call
# 18 times (7µs+0s) by JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:646] at line 642, avg 389ns/call | |||||
# spent 80.4ms within JSON::Schema::Modern::CORE:qr which was called 87311 times, avg 921ns/call:
# 87311 times (80.4ms+0s) by JSON::Schema::Modern::_eval_subschema at line 577, avg 921ns/call | |||||
# spent 87.5ms within JSON::Schema::Modern::CORE:regcomp which was called 87311 times, avg 1µs/call:
# 87311 times (87.5ms+0s) by JSON::Schema::Modern::_eval_subschema at line 577, avg 1µs/call | |||||
# spent 98.7ms within JSON::Schema::Modern::CORE:sort which was called 128929 times, avg 766ns/call:
# 87311 times (23.3ms+0s) by JSON::Schema::Modern::_eval_subschema at line 577, avg 267ns/call
# 39123 times (72.4ms+0s) by JSON::Schema::Modern::_fetch_from_uri at line 835, avg 2µs/call
# 2480 times (2.92ms+0s) by JSON::Schema::Modern::_traverse_subschema at line 477, avg 1µs/call
# 15 times (28µs+0s) by JSON::Schema::Modern::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern.pm:646] at line 617, avg 2µs/call | |||||
# spent 376ms within JSON::Schema::Modern::CORE:subst which was called 953819 times, avg 394ns/call:
# 641165 times (232ms+0s) by JSON::Schema::Modern::_eval_subschema at line 529, avg 363ns/call
# 308273 times (141ms+0s) by JSON::Schema::Modern::_eval_subschema at line 544, avg 459ns/call
# 4381 times (1.86ms+0s) by JSON::Schema::Modern::_traverse_subschema at line 455, avg 425ns/call | |||||
# spent 12µs within JSON::Schema::Modern::METASCHEMA_URIS which was called 15 times, avg 800ns/call:
# 15 times (12µs+0s) by JSON::Schema::Modern::traverse at line 262, avg 800ns/call | |||||
# spent 1µs within JSON::Schema::Modern::SPECIFICATION_VERSION_DEFAULT which was called:
# once (1µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 76 of JSON/Schema/Modern/Document/OpenAPI.pm | |||||
sub JSON::Schema::Modern::__ANON__; # xsub |