Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm |
Statements | Executed 48513 statements in 156ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
47846 | 1 | 1 | 161ms | 261ms | data | JSON::Schema::Modern::Document::
22 | 1 | 1 | 1.02ms | 28.0ms | __ANON__[:135] | JSON::Schema::Modern::Document::
15 | 2 | 2 | 930µs | 94.3s | BUILD (recurses: max depth 1, inclusive time 160ms) | JSON::Schema::Modern::Document::
14 | 1 | 1 | 497µs | 126ms | traverse | JSON::Schema::Modern::Document::
12 | 1 | 1 | 123µs | 425µs | __ANON__[:90] | JSON::Schema::Modern::Document::
15 | 2 | 2 | 112µs | 1.29ms | __ANON__[:45] | JSON::Schema::Modern::Document::
25 | 4 | 4 | 105µs | 656µs | __ANON__[:39] | JSON::Schema::Modern::Document::
8 | 1 | 1 | 57µs | 118µs | __ANON__[:38] | JSON::Schema::Modern::Document::
15 | 2 | 2 | 52µs | 52µs | FOREIGNBUILDARGS | JSON::Schema::Modern::Document::
1 | 1 | 1 | 45µs | 72µs | BEGIN@19 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 38µs | 83µs | BEGIN@20 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 37µs | 42µs | BEGIN@17 | JSON::Schema::Modern::Document::
15 | 1 | 1 | 34µs | 34µs | __ANON__[:78] | JSON::Schema::Modern::Document::
1 | 1 | 1 | 30µs | 32µs | BEGIN@1.113 | JSON::Schema::Modern::
15 | 1 | 1 | 27µs | 27µs | __ANON__[:110] | JSON::Schema::Modern::Document::
1 | 1 | 1 | 19µs | 37µs | BEGIN@16 | JSON::Schema::Modern::Document::
36 | 1 | 1 | 18µs | 18µs | CORE:match (opcode) | JSON::Schema::Modern::Document::
1 | 1 | 1 | 15µs | 973µs | BEGIN@11 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 14µs | 44µs | BEGIN@13 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 13µs | 30µs | BEGIN@15 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 12µs | 1.06ms | BEGIN@24 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 11µs | 11µs | BEGIN@9 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 10µs | 174µs | BEGIN@21 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 9µs | 223µs | BEGIN@12 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 8µs | 197µs | BEGIN@10 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 8µs | 22µs | BEGIN@14 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 7µs | 379µs | BEGIN@22 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 6µs | 35µs | BEGIN@2.114 | JSON::Schema::Modern::
1 | 1 | 1 | 6µs | 31µs | BEGIN@18 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 6µs | 194µs | BEGIN@25 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 5µs | 49µs | BEGIN@23 | JSON::Schema::Modern::Document::
0 | 0 | 0 | 0s | 0s | TO_JSON | JSON::Schema::Modern::Document::
0 | 0 | 0 | 0s | 0s | validate | JSON::Schema::Modern::Document::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 27µs | 2 | 34µs | # spent 32µs (30+2) within JSON::Schema::Modern::BEGIN@1.113 which was called:
# once (30µs+2µs) by JSON::Schema::Modern::BEGIN@35 at line 1 # spent 32µs making 1 call to JSON::Schema::Modern::BEGIN@1.113
# spent 2µs making 1 call to strict::import |
2 | 2 | 86µs | 2 | 64µs | # spent 35µs (6+29) within JSON::Schema::Modern::BEGIN@2.114 which was called:
# once (6µs+29µs) by JSON::Schema::Modern::BEGIN@35 at line 2 # spent 35µs making 1 call to JSON::Schema::Modern::BEGIN@2.114
# spent 29µs making 1 call to warnings::import |
3 | package JSON::Schema::Modern::Document; | ||||
4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||
5 | # ABSTRACT: One JSON Schema document | ||||
6 | |||||
7 | 1 | 1µs | our $VERSION = '0.558'; | ||
8 | |||||
9 | 2 | 79µs | 1 | 11µs | # spent 11µs within JSON::Schema::Modern::Document::BEGIN@9 which was called:
# once (11µs+0s) by JSON::Schema::Modern::BEGIN@35 at line 9 # spent 11µs making 1 call to JSON::Schema::Modern::Document::BEGIN@9 |
10 | 2 | 23µs | 2 | 386µs | # spent 197µs (8+189) within JSON::Schema::Modern::Document::BEGIN@10 which was called:
# once (8µs+189µs) by JSON::Schema::Modern::BEGIN@35 at line 10 # spent 197µs making 1 call to JSON::Schema::Modern::Document::BEGIN@10
# spent 189µs making 1 call to Moo::import |
11 | 3 | 56µs | 3 | 1.93ms | # spent 973µs (15+958) within JSON::Schema::Modern::Document::BEGIN@11 which was called:
# once (15µs+958µs) by JSON::Schema::Modern::BEGIN@35 at line 11 # spent 973µs making 1 call to JSON::Schema::Modern::Document::BEGIN@11
# spent 941µs making 1 call to strictures::import
# spent 16µs making 1 call to strictures::VERSION |
12 | 2 | 57µs | 2 | 437µs | # spent 223µs (9+214) within JSON::Schema::Modern::Document::BEGIN@12 which was called:
# once (9µs+214µs) by JSON::Schema::Modern::BEGIN@35 at line 12 # spent 223µs making 1 call to JSON::Schema::Modern::Document::BEGIN@12
# spent 214µs making 1 call to experimental::import |
13 | 2 | 28µs | 2 | 47µs | # spent 44µs (14+30) within JSON::Schema::Modern::Document::BEGIN@13 which was called:
# once (14µs+30µs) by JSON::Schema::Modern::BEGIN@35 at line 13 # spent 44µs making 1 call to JSON::Schema::Modern::Document::BEGIN@13
# spent 3µs making 1 call to if::import |
14 | 2 | 19µs | 2 | 24µs | # spent 22µs (8+14) within JSON::Schema::Modern::Document::BEGIN@14 which was called:
# once (8µs+14µs) by JSON::Schema::Modern::BEGIN@35 at line 14 # spent 22µs making 1 call to JSON::Schema::Modern::Document::BEGIN@14
# spent 2µs making 1 call to if::unimport |
15 | 2 | 41µs | 2 | 30µs | # spent 30µs (13+17) within JSON::Schema::Modern::Document::BEGIN@15 which was called:
# once (13µs+17µs) by JSON::Schema::Modern::BEGIN@35 at line 15 # spent 30µs making 1 call to JSON::Schema::Modern::Document::BEGIN@15
# spent 0s making 1 call to if::unimport |
16 | 2 | 82µs | 2 | 38µs | # spent 37µs (19+18) within JSON::Schema::Modern::Document::BEGIN@16 which was called:
# once (19µs+18µs) by JSON::Schema::Modern::BEGIN@35 at line 16 # spent 37µs making 1 call to JSON::Schema::Modern::Document::BEGIN@16
# spent 1µs making 1 call to if::unimport |
17 | 2 | 20µs | 2 | 47µs | # spent 42µs (37+5) within JSON::Schema::Modern::Document::BEGIN@17 which was called:
# once (37µs+5µs) by JSON::Schema::Modern::BEGIN@35 at line 17 # spent 42µs making 1 call to JSON::Schema::Modern::Document::BEGIN@17
# spent 5µs making 1 call to Mojo::Base::import |
18 | 2 | 46µs | 2 | 56µs | # spent 31µs (6+25) within JSON::Schema::Modern::Document::BEGIN@18 which was called:
# once (6µs+25µs) by JSON::Schema::Modern::BEGIN@35 at line 18 # spent 31µs making 1 call to JSON::Schema::Modern::Document::BEGIN@18
# spent 25µs making 1 call to Exporter::import |
19 | 3 | 92µs | 3 | 87µs | # spent 72µs (45+27) within JSON::Schema::Modern::Document::BEGIN@19 which was called:
# once (45µs+27µs) by JSON::Schema::Modern::BEGIN@35 at line 19 # spent 72µs making 1 call to JSON::Schema::Modern::Document::BEGIN@19
# spent 8µs making 1 call to UNIVERSAL::VERSION
# spent 7µs making 1 call to List::Util::import |
20 | 3 | 22µs | 3 | 128µs | # spent 83µs (38+45) within JSON::Schema::Modern::Document::BEGIN@20 which was called:
# once (38µs+45µs) by JSON::Schema::Modern::BEGIN@35 at line 20 # spent 83µs making 1 call to JSON::Schema::Modern::Document::BEGIN@20
# spent 41µs making 1 call to Exporter::import
# spent 4µs making 1 call to UNIVERSAL::VERSION |
21 | 3 | 29µs | 3 | 338µs | # spent 174µs (10+164) within JSON::Schema::Modern::Document::BEGIN@21 which was called:
# once (10µs+164µs) by JSON::Schema::Modern::BEGIN@35 at line 21 # spent 174µs making 1 call to JSON::Schema::Modern::Document::BEGIN@21
# spent 158µs making 1 call to Exporter::import
# spent 6µs making 1 call to UNIVERSAL::VERSION |
22 | 2 | 17µs | 2 | 751µs | # spent 379µs (7+372) within JSON::Schema::Modern::Document::BEGIN@22 which was called:
# once (7µs+372µs) by JSON::Schema::Modern::BEGIN@35 at line 22 # spent 379µs making 1 call to JSON::Schema::Modern::Document::BEGIN@22
# spent 372µs making 1 call to MooX::TypeTiny::import |
23 | 2 | 22µs | 2 | 93µs | # spent 49µs (5+44) within JSON::Schema::Modern::Document::BEGIN@23 which was called:
# once (5µs+44µs) by JSON::Schema::Modern::BEGIN@35 at line 23 # spent 49µs making 1 call to JSON::Schema::Modern::Document::BEGIN@23
# spent 44µs making 1 call to MooX::HandlesVia::import |
24 | 3 | 34µs | 3 | 2.11ms | # spent 1.06ms (12µs+1.05) within JSON::Schema::Modern::Document::BEGIN@24 which was called:
# once (12µs+1.05ms) by JSON::Schema::Modern::BEGIN@35 at line 24 # spent 1.06ms making 1 call to JSON::Schema::Modern::Document::BEGIN@24
# spent 1.04ms making 1 call to Exporter::Tiny::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
25 | 2 | 927µs | 2 | 382µs | # spent 194µs (6+188) within JSON::Schema::Modern::Document::BEGIN@25 which was called:
# once (6µs+188µs) by JSON::Schema::Modern::BEGIN@35 at line 25 # spent 194µs making 1 call to JSON::Schema::Modern::Document::BEGIN@25
# spent 188µs making 1 call to namespace::clean::import |
26 | |||||
27 | 1 | 2µs | 1 | 2.51ms | extends 'Mojo::JSON::Pointer'; # spent 2.51ms making 1 call to JSON::Schema::Modern::Document::extends |
28 | |||||
29 | 1 | 3µs | 1 | 469µs | has schema => ( # spent 469µs making 1 call to MooX::HandlesVia::has |
30 | is => 'ro', | ||||
31 | required => 1, | ||||
32 | ); | ||||
33 | |||||
34 | has canonical_uri => ( | ||||
35 | is => 'rwp', | ||||
36 | isa => (InstanceOf['Mojo::URL'])->where(q{not defined $_->fragment}), | ||||
37 | lazy => 1, | ||||
38 | 8 | 37µs | 8 | 61µs | # spent 118µs (57+61) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:38] which was called 8 times, avg 15µs/call:
# 8 times (57µs+61µs) by JSON::Schema::Modern::Document::canonical_uri at line 33 of (eval 267)[Sub/Quote.pm:3], avg 15µs/call # spent 61µs making 8 calls to Mojo::URL::new, avg 8µs/call |
39 | 25 | 109µs | 26 | 551µs | # spent 656µs (105+551) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:39] which was called 25 times, avg 26µs/call:
# 10 times (43µs+98µs) by JSON::Schema::Modern::Document::_set_canonical_uri at line 28 of (eval 268)[Sub/Quote.pm:3], avg 14µs/call
# 8 times (28µs+130µs) by JSON::Schema::Modern::Document::canonical_uri at line 33 of (eval 267)[Sub/Quote.pm:3], avg 20µs/call
# 6 times (25µs+68µs) by JSON::Schema::Modern::Document::new at line 65 of (eval 428)[Sub/Quote.pm:3], avg 16µs/call
# once (9µs+255µs) by JSON::Schema::Modern::Document::OpenAPI::new at line 68 of (eval 421)[Sub/Quote.pm:3] # spent 308µs making 25 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 12µs/call
# spent 243µs making 1 call to Mojo::URL::new |
40 | 1 | 14µs | 3 | 3.05ms | ); # spent 2.69ms making 1 call to MooX::HandlesVia::has
# spent 285µs making 1 call to Type::Tiny::where
# spent 75µs making 1 call to Types::Standard::InstanceOf |
41 | |||||
42 | has metaschema_uri => ( | ||||
43 | is => 'rwp', | ||||
44 | isa => InstanceOf['Mojo::URL'], | ||||
45 | 15 | 102µs | 30 | 1.18ms | # spent 1.29ms (112µs+1.18) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:45] which was called 15 times, avg 86µs/call:
# 14 times (99µs+1.07ms) by JSON::Schema::Modern::Document::_set_metaschema_uri at line 28 of (eval 270)[Sub/Quote.pm:3], avg 84µs/call
# once (13µs+106µs) by JSON::Schema::Modern::Document::OpenAPI::new at line 128 of (eval 421)[Sub/Quote.pm:3] # spent 1.02ms making 15 calls to Mojo::URL::new, avg 68µs/call
# spent 157µs making 15 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 10µs/call |
46 | 1 | 9µs | 2 | 1.86ms | ); # spent 1.75ms making 1 call to MooX::HandlesVia::has
# spent 116µs making 1 call to Types::Standard::InstanceOf |
47 | |||||
48 | 1 | 5µs | 2 | 1.73ms | has evaluator => ( # spent 1.33ms making 1 call to MooX::HandlesVia::has
# spent 397µs making 1 call to Types::Standard::InstanceOf |
49 | is => 'rwp', | ||||
50 | isa => InstanceOf['JSON::Schema::Modern'], | ||||
51 | weak_ref => 1, | ||||
52 | ); | ||||
53 | |||||
54 | # "A JSON Schema resource is a schema which is canonically identified by an absolute URI." | ||||
55 | # https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.4.3.5 | ||||
56 | has resource_index => ( | ||||
57 | is => 'bare', | ||||
58 | isa => HashRef[my $resource_type = Dict[ | ||||
59 | canonical_uri => InstanceOf['Mojo::URL'], | ||||
60 | path => Str, # always a JSON pointer, relative to the document root | ||||
61 | specification_version => Str, # not an Enum due to module load ordering | ||||
62 | # the vocabularies used when evaluating instance data against schema | ||||
63 | vocabularies => ArrayRef[ClassName->where(q{$_->DOES('JSON::Schema::Modern::Vocabulary')})], | ||||
64 | configs => HashRef, | ||||
65 | Slurpy[HashRef[Undef]], # no other fields allowed | ||||
66 | ]], | ||||
67 | handles_via => 'Hash', | ||||
68 | handles => { | ||||
69 | resource_index => 'elements', | ||||
70 | resource_pairs => 'kv', | ||||
71 | _add_resources => 'set', | ||||
72 | _get_resource => 'get', | ||||
73 | _remove_resource => 'delete', | ||||
74 | _canonical_resources => 'values', | ||||
75 | }, | ||||
76 | init_arg => undef, | ||||
77 | lazy => 1, | ||||
78 | 15 | 62µs | # spent 34µs within JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:78] which was called 15 times, avg 2µs/call:
# 15 times (34µs+0s) by JSON::Schema::Modern::Document::_assert_resource_index at line 23 of (eval 301)[Sub/Quote.pm:3], avg 2µs/call | ||
79 | 1 | 48µs | 13 | 29.8ms | ); # spent 12.1ms making 1 call to MooX::HandlesVia::has
# spent 8.98ms making 1 call to Types::Standard::Dict
# spent 6.62ms making 3 calls to Types::Standard::HashRef, avg 2.21ms/call
# spent 1.30ms making 1 call to Types::Standard::Slurpy
# spent 588µs making 1 call to Types::Standard::ArrayRef
# spent 162µs making 1 call to Type::Tiny::where
# spent 90µs making 1 call to Types::Standard::InstanceOf
# spent 3µs making 1 call to Types::Standard::ClassName
# spent 2µs making 1 call to Types::Standard::Undef
# spent 1µs making 2 calls to Types::Standard::Str, avg 500ns/call |
80 | |||||
81 | has _path_to_resource => ( | ||||
82 | is => 'bare', | ||||
83 | isa => HashRef[$resource_type], | ||||
84 | handles_via => 'Hash', | ||||
85 | handles => { | ||||
86 | path_to_resource => 'get', | ||||
87 | }, | ||||
88 | init_arg => undef, | ||||
89 | lazy => 1, | ||||
90 | 12 | 100µs | 12 | 302µs | # spent 425µs (123+302) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:90] which was called 12 times, avg 35µs/call:
# 12 times (123µs+302µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 23 of (eval 303)[Sub/Quote.pm:3], avg 35µs/call # spent 302µs making 12 calls to JSON::Schema::Modern::Document::_canonical_resources, avg 25µs/call |
91 | 1 | 10µs | 2 | 3.88ms | ); # spent 3.81ms making 1 call to MooX::HandlesVia::has
# spent 65µs making 1 call to Types::Standard::HashRef |
92 | |||||
93 | # for internal use only | ||||
94 | 1 | 14µs | 2 | 1.19ms | has _serialized_schema => ( # spent 1.19ms making 1 call to MooX::HandlesVia::has
# spent 3µs making 1 call to Types::Standard::Str |
95 | is => 'rw', | ||||
96 | isa => Str, | ||||
97 | init_arg => undef, | ||||
98 | ); | ||||
99 | |||||
100 | has errors => ( | ||||
101 | is => 'bare', | ||||
102 | handles_via => 'Array', | ||||
103 | handles => { | ||||
104 | errors => 'elements', | ||||
105 | has_errors => 'count', | ||||
106 | }, | ||||
107 | writer => '_set_errors', | ||||
108 | isa => ArrayRef[InstanceOf['JSON::Schema::Modern::Error']], | ||||
109 | lazy => 1, | ||||
110 | 15 | 32µs | # spent 27µs within JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:110] which was called 15 times, avg 2µs/call:
# 15 times (27µs+0s) by JSON::Schema::Modern::Document::_assert_errors at line 23 of (eval 308)[Sub/Quote.pm:3], avg 2µs/call | ||
111 | 1 | 13µs | 3 | 3.28ms | ); # spent 3.15ms making 1 call to MooX::HandlesVia::has
# spent 86µs making 1 call to Types::Standard::InstanceOf
# spent 43µs making 1 call to Types::Standard::ArrayRef |
112 | |||||
113 | # spent 28.0ms (1.02+27.0) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:135] which was called 22 times, avg 1.27ms/call:
# 22 times (1.02ms+27.0ms) by JSON::Schema::Modern::Document::__ANON__[(eval 310)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 310)[Class/Method/Modifiers.pm:89], avg 1.27ms/call | ||||
114 | 22 | 7µs | my $orig = shift; | ||
115 | 22 | 8µs | my $self = shift; | ||
116 | |||||
117 | 22 | 377µs | 22 | 153µs | foreach my $pair (pairs @_) { # spent 153µs making 22 calls to List::Util::pairs, avg 7µs/call |
118 | 36 | 21µs | my ($key, $value) = @$pair; | ||
119 | |||||
120 | 36 | 267µs | 108 | 7.44ms | $resource_type->($value); # check type of hash value against Dict # spent 4.26ms making 36 calls to Sub::Defer::__ANON__[Sub/Defer.pm:178], avg 118µs/call
# spent 3.18ms making 72 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 44µs/call |
121 | |||||
122 | 36 | 135µs | 44 | 6.67ms | if (my $existing = $self->_get_resource($key)) { # spent 6.12ms making 36 calls to JSON::Schema::Modern::Document::_get_resource, avg 170µs/call
# spent 548µs making 8 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 68µs/call |
123 | croak 'uri "'.$key.'" conflicts with an existing schema resource' | ||||
124 | if $existing->{path} ne $value->{path} | ||||
125 | or $existing->{canonical_uri} ne $value->{canonical_uri} | ||||
126 | or $existing->{specification_version} ne $value->{specification_version}; | ||||
127 | } | ||||
128 | |||||
129 | # this will never happen, if we parsed $id correctly | ||||
130 | croak sprintf('a resource canonical uri cannot contain a plain-name fragment (%s)', $value->{canonical_uri}) | ||||
131 | 36 | 104µs | 72 | 37µs | if ($value->{canonical_uri}->fragment // '') =~ m{^[^/]}; # spent 19µs making 36 calls to Mojo::URL::fragment, avg 528ns/call
# spent 18µs making 36 calls to JSON::Schema::Modern::Document::CORE:match, avg 500ns/call |
132 | |||||
133 | 36 | 88µs | 36 | 9.33ms | $self->$orig($key, $value); # spent 9.33ms making 36 calls to JSON::Schema::Modern::Document::_add_resources, avg 259µs/call |
134 | } | ||||
135 | 1 | 6µs | 1 | 231µs | }; # spent 231µs making 1 call to Moo::around |
136 | |||||
137 | # shims for Mojo::JSON::Pointer | ||||
138 | 47846 | 152ms | 47846 | 100.0ms | # spent 261ms (161+100.0) within JSON::Schema::Modern::Document::data which was called 47846 times, avg 5µs/call:
# 47846 times (161ms+100.0ms) by Mojo::JSON::Pointer::_pointer at line 14 of Mojo/JSON/Pointer.pm, avg 5µs/call # spent 100.0ms making 47846 calls to JSON::Schema::Modern::Document::schema, avg 2µs/call |
139 | 15 | 43µs | # spent 52µs within JSON::Schema::Modern::Document::FOREIGNBUILDARGS which was called 15 times, avg 3µs/call:
# 14 times (51µs+0s) by JSON::Schema::Modern::Document::new at line 53 of (eval 428)[Sub/Quote.pm:3], avg 4µs/call
# once (1µs+0s) by JSON::Schema::Modern::Document::OpenAPI::new at line 56 of (eval 421)[Sub/Quote.pm:3] | ||
140 | |||||
141 | # for JSON serializers | ||||
142 | sub TO_JSON { shift->schema } | ||||
143 | |||||
144 | 45 | 17µs | # spent 94.3s (930µs+94.3) within JSON::Schema::Modern::Document::BUILD which was called 15 times, avg 6.28s/call:
# 14 times (781µs+-781µs) by JSON::Schema::Modern::Document::new at line 114 of (eval 428)[Sub/Quote.pm:3], avg 0s/call
# once (149µs+94.3s) by JSON::Schema::Modern::Document::OpenAPI::new at line 149 of (eval 421)[Sub/Quote.pm:3] | ||
145 | 15 | 64µs | 30 | 753µs | my $original_uri = $self->canonical_uri->clone; # spent 490µs making 15 calls to JSON::Schema::Modern::Document::canonical_uri, avg 33µs/call
# spent 263µs making 15 calls to Mojo::URL::clone, avg 18µs/call |
146 | 15 | 65µs | 30 | 94.4s | my $state = $self->traverse($self->evaluator // JSON::Schema::Modern->new); # spent 94.3s making 1 call to JSON::Schema::Modern::Document::OpenAPI::traverse
# spent 126ms making 14 calls to JSON::Schema::Modern::Document::traverse, avg 9.02ms/call
# spent 30µs making 14 calls to JSON::Schema::Modern::Document::evaluator, avg 2µs/call
# spent 3µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::evaluator |
147 | |||||
148 | # if the schema identified a canonical uri for itself, it overrides the initial value | ||||
149 | 15 | 125µs | 40 | 3.69ms | $self->_set_canonical_uri($state->{initial_schema_uri}) if $state->{initial_schema_uri} ne $original_uri; # spent 3.35ms making 30 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 112µs/call
# spent 337µs making 10 calls to JSON::Schema::Modern::Document::_set_canonical_uri, avg 34µs/call |
150 | |||||
151 | 15 | 12µs | if ($state->{errors}->@*) { | ||
152 | foreach my $error ($state->{errors}->@*) { | ||||
153 | $error->mode('traverse') if not defined $error->mode; | ||||
154 | } | ||||
155 | |||||
156 | $self->_set_errors($state->{errors}); | ||||
157 | return; | ||||
158 | } | ||||
159 | |||||
160 | # make sure the root schema is always indexed against *something*. | ||||
161 | $self->_add_resources($original_uri => { | ||||
162 | path => '', | ||||
163 | canonical_uri => $self->canonical_uri, | ||||
164 | specification_version => $state->{spec_version}, | ||||
165 | vocabularies => $state->{vocabularies}, | ||||
166 | configs => $state->{configs}, | ||||
167 | }) | ||||
168 | 15 | 250µs | 68 | 11.9ms | if (not "$original_uri" and $original_uri eq $self->canonical_uri) # spent 8.86ms making 7 calls to JSON::Schema::Modern::Document::_add_resources, avg 1.27ms/call
# spent 2.98ms making 46 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 65µs/call
# spent 39µs making 15 calls to JSON::Schema::Modern::Document::canonical_uri, avg 3µs/call |
169 | or "$original_uri"; | ||||
170 | |||||
171 | 15 | 209µs | 15 | 19.4ms | $self->_add_resources($state->{identifiers}->@*); # spent 19.4ms making 15 calls to JSON::Schema::Modern::Document::_add_resources, avg 1.29ms/call |
172 | } | ||||
173 | |||||
174 | 42 | 7µs | # spent 126ms (497µs+126) within JSON::Schema::Modern::Document::traverse which was called 14 times, avg 9.02ms/call:
# 14 times (497µs+126ms) by JSON::Schema::Modern::Document::BUILD at line 146, avg 9.02ms/call | ||
175 | die 'wrong class - use JSON::Schema::Modern::Document::OpenAPI instead' | ||||
176 | 14 | 44µs | 28 | 34µs | if is_plain_hashref($self->schema) and exists $self->schema->{openapi}; # spent 34µs making 28 calls to JSON::Schema::Modern::Document::schema, avg 1µs/call |
177 | |||||
178 | 14 | 158µs | 70 | 124ms | my $state = $evaluator->traverse($self->schema, # spent 124ms making 14 calls to JSON::Schema::Modern::traverse, avg 8.85ms/call
# spent 139µs making 14 calls to Mojo::URL::clone, avg 10µs/call
# spent 30µs making 14 calls to JSON::Schema::Modern::Document::metaschema_uri, avg 2µs/call
# spent 11µs making 14 calls to JSON::Schema::Modern::Document::schema, avg 786ns/call
# spent 7µs making 14 calls to JSON::Schema::Modern::Document::canonical_uri, avg 500ns/call |
179 | { | ||||
180 | initial_schema_uri => $self->canonical_uri->clone, | ||||
181 | $self->metaschema_uri ? ( metaschema_uri => $self->metaschema_uri) : (), | ||||
182 | } | ||||
183 | ); | ||||
184 | |||||
185 | 14 | 14µs | return $state if $state->{errors}->@*; | ||
186 | |||||
187 | # we don't store the metaschema_uri in $state nor in resource_index, but we can figure it out | ||||
188 | # easily enough. | ||||
189 | my $metaschema_uri = (is_plain_hashref($self->schema) ? $self->schema->{'$schema'} : undef) | ||||
190 | 14 | 85µs | 28 | 35µs | // $self->metaschema_uri // $evaluator->METASCHEMA_URIS->{$state->{spec_version}}; # spent 35µs making 28 calls to JSON::Schema::Modern::Document::schema, avg 1µs/call |
191 | |||||
192 | 14 | 64µs | 28 | 1.63ms | $self->_set_metaschema_uri($metaschema_uri) if $metaschema_uri ne ($self->metaschema_uri//''); # spent 1.60ms making 14 calls to JSON::Schema::Modern::Document::_set_metaschema_uri, avg 114µs/call
# spent 25µs making 14 calls to JSON::Schema::Modern::Document::metaschema_uri, avg 2µs/call |
193 | |||||
194 | 14 | 37µs | return $state; | ||
195 | } | ||||
196 | |||||
197 | sub validate ($self) { | ||||
198 | my $js = $self->$_call_if_can('evaluator') // JSON::Schema::Modern->new; | ||||
199 | |||||
200 | return $js->evaluate($self->schema, $self->metaschema_uri); | ||||
201 | } | ||||
202 | |||||
203 | 1 | 61µs | 1; | ||
204 | |||||
205 | 1 | 100µs | 1 | 596µs | __END__ # spent 596µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 18µs within JSON::Schema::Modern::Document::CORE:match which was called 36 times, avg 500ns/call:
# 36 times (18µs+0s) by JSON::Schema::Modern::Document::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm:135] at line 131, avg 500ns/call |