Filename | /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm |
Statements | Executed 48081 statements in 118ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
47414 | 1 | 1 | 117ms | 192ms | data | JSON::Schema::Modern::Document::
15 | 2 | 2 | 780µs | 70.6s | BUILD (recurses: max depth 1, inclusive time 197ms) | JSON::Schema::Modern::Document::
22 | 1 | 1 | 744µs | 23.4ms | __ANON__[:135] | JSON::Schema::Modern::Document::
14 | 1 | 1 | 390µs | 169ms | traverse | JSON::Schema::Modern::Document::
12 | 1 | 1 | 122µs | 341µs | __ANON__[:90] | JSON::Schema::Modern::Document::
25 | 4 | 4 | 94µs | 573µs | __ANON__[:39] | JSON::Schema::Modern::Document::
15 | 2 | 2 | 87µs | 882µs | __ANON__[:45] | JSON::Schema::Modern::Document::
15 | 1 | 1 | 85µs | 85µs | __ANON__[:78] | JSON::Schema::Modern::Document::
8 | 1 | 1 | 50µs | 84µs | __ANON__[:38] | JSON::Schema::Modern::Document::
15 | 1 | 1 | 23µs | 23µs | __ANON__[:110] | JSON::Schema::Modern::Document::
15 | 2 | 2 | 20µs | 20µs | FOREIGNBUILDARGS | JSON::Schema::Modern::Document::
1 | 1 | 1 | 18µs | 21µs | BEGIN@1.113 | JSON::Schema::Modern::
1 | 1 | 1 | 17µs | 578µs | BEGIN@11 | JSON::Schema::Modern::Document::
36 | 1 | 1 | 13µs | 13µs | CORE:match (opcode) | JSON::Schema::Modern::Document::
1 | 1 | 1 | 10µs | 32µs | BEGIN@13 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 10µs | 33µs | BEGIN@19 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 10µs | 10µs | BEGIN@9 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 9µs | 21µs | BEGIN@16 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 8µs | 18µs | BEGIN@14 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 8µs | 1.02ms | BEGIN@24 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 7µs | 9µs | BEGIN@17 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 7µs | 24µs | BEGIN@20 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 7µs | 76µs | BEGIN@21 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 6µs | 209µs | BEGIN@10 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 6µs | 92µs | BEGIN@12 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 6µs | 12µs | BEGIN@15 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 6µs | 31µs | BEGIN@18 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 5µs | 327µs | BEGIN@22 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 5µs | 202µs | BEGIN@25 | JSON::Schema::Modern::Document::
1 | 1 | 1 | 4µs | 25µs | BEGIN@2.114 | JSON::Schema::Modern::
1 | 1 | 1 | 3µs | 45µ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 | 20µs | 2 | 24µs | # spent 21µs (18+3) within JSON::Schema::Modern::BEGIN@1.113 which was called:
# once (18µs+3µs) by JSON::Schema::Modern::BEGIN@35 at line 1 # spent 21µs making 1 call to JSON::Schema::Modern::BEGIN@1.113
# spent 3µs making 1 call to strict::import |
2 | 2 | 31µs | 2 | 46µs | # spent 25µs (4+21) within JSON::Schema::Modern::BEGIN@2.114 which was called:
# once (4µs+21µs) by JSON::Schema::Modern::BEGIN@35 at line 2 # spent 25µs making 1 call to JSON::Schema::Modern::BEGIN@2.114
# spent 21µ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.559'; | ||
8 | |||||
9 | 2 | 30µs | 1 | 10µs | # spent 10µs within JSON::Schema::Modern::Document::BEGIN@9 which was called:
# once (10µs+0s) by JSON::Schema::Modern::BEGIN@35 at line 9 # spent 10µs making 1 call to JSON::Schema::Modern::Document::BEGIN@9 |
10 | 2 | 21µs | 2 | 412µs | # spent 209µs (6+203) within JSON::Schema::Modern::Document::BEGIN@10 which was called:
# once (6µs+203µs) by JSON::Schema::Modern::BEGIN@35 at line 10 # spent 209µs making 1 call to JSON::Schema::Modern::Document::BEGIN@10
# spent 203µs making 1 call to Moo::import |
11 | 3 | 28µs | 3 | 1.14ms | # spent 578µs (17+561) within JSON::Schema::Modern::Document::BEGIN@11 which was called:
# once (17µs+561µs) by JSON::Schema::Modern::BEGIN@35 at line 11 # spent 578µs making 1 call to JSON::Schema::Modern::Document::BEGIN@11
# spent 548µs making 1 call to strictures::import
# spent 13µs making 1 call to strictures::VERSION |
12 | 2 | 30µs | 2 | 178µs | # spent 92µs (6+86) within JSON::Schema::Modern::Document::BEGIN@12 which was called:
# once (6µs+86µs) by JSON::Schema::Modern::BEGIN@35 at line 12 # spent 92µs making 1 call to JSON::Schema::Modern::Document::BEGIN@12
# spent 86µs making 1 call to experimental::import |
13 | 2 | 20µs | 2 | 35µs | # spent 32µs (10+22) within JSON::Schema::Modern::Document::BEGIN@13 which was called:
# once (10µs+22µs) by JSON::Schema::Modern::BEGIN@35 at line 13 # spent 32µs making 1 call to JSON::Schema::Modern::Document::BEGIN@13
# spent 3µs making 1 call to if::import |
14 | 2 | 17µs | 2 | 19µs | # spent 18µs (8+10) within JSON::Schema::Modern::Document::BEGIN@14 which was called:
# once (8µs+10µs) by JSON::Schema::Modern::BEGIN@35 at line 14 # spent 18µs making 1 call to JSON::Schema::Modern::Document::BEGIN@14
# spent 1µs making 1 call to if::unimport |
15 | 2 | 19µs | 2 | 12µs | # spent 12µs (6+6) within JSON::Schema::Modern::Document::BEGIN@15 which was called:
# once (6µs+6µs) by JSON::Schema::Modern::BEGIN@35 at line 15 # spent 12µs making 1 call to JSON::Schema::Modern::Document::BEGIN@15
# spent 0s making 1 call to if::unimport |
16 | 2 | 17µs | 2 | 22µs | # spent 21µs (9+12) within JSON::Schema::Modern::Document::BEGIN@16 which was called:
# once (9µs+12µs) by JSON::Schema::Modern::BEGIN@35 at line 16 # spent 21µs making 1 call to JSON::Schema::Modern::Document::BEGIN@16
# spent 1µs making 1 call to if::unimport |
17 | 2 | 18µs | 2 | 11µs | # spent 9µs (7+2) within JSON::Schema::Modern::Document::BEGIN@17 which was called:
# once (7µs+2µs) by JSON::Schema::Modern::BEGIN@35 at line 17 # spent 9µs making 1 call to JSON::Schema::Modern::Document::BEGIN@17
# spent 2µs making 1 call to Mojo::Base::import |
18 | 2 | 17µ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 | 29µs | 3 | 45µs | # spent 33µs (10+23) within JSON::Schema::Modern::Document::BEGIN@19 which was called:
# once (10µs+23µs) by JSON::Schema::Modern::BEGIN@35 at line 19 # spent 33µs making 1 call to JSON::Schema::Modern::Document::BEGIN@19
# spent 7µs making 1 call to List::Util::import
# spent 5µs making 1 call to UNIVERSAL::VERSION |
20 | 3 | 25µs | 3 | 41µs | # spent 24µs (7+17) within JSON::Schema::Modern::Document::BEGIN@20 which was called:
# once (7µs+17µs) by JSON::Schema::Modern::BEGIN@35 at line 20 # spent 24µs making 1 call to JSON::Schema::Modern::Document::BEGIN@20
# spent 11µs making 1 call to Exporter::import
# spent 6µs making 1 call to UNIVERSAL::VERSION |
21 | 3 | 21µs | 3 | 145µs | # spent 76µs (7+69) within JSON::Schema::Modern::Document::BEGIN@21 which was called:
# once (7µs+69µs) by JSON::Schema::Modern::BEGIN@35 at line 21 # spent 76µs making 1 call to JSON::Schema::Modern::Document::BEGIN@21
# spent 65µs making 1 call to Exporter::import
# spent 4µs making 1 call to UNIVERSAL::VERSION |
22 | 2 | 18µs | 2 | 649µs | # spent 327µs (5+322) within JSON::Schema::Modern::Document::BEGIN@22 which was called:
# once (5µs+322µs) by JSON::Schema::Modern::BEGIN@35 at line 22 # spent 327µs making 1 call to JSON::Schema::Modern::Document::BEGIN@22
# spent 322µs making 1 call to MooX::TypeTiny::import |
23 | 2 | 26µs | 2 | 87µs | # spent 45µs (3+42) within JSON::Schema::Modern::Document::BEGIN@23 which was called:
# once (3µs+42µs) by JSON::Schema::Modern::BEGIN@35 at line 23 # spent 45µs making 1 call to JSON::Schema::Modern::Document::BEGIN@23
# spent 42µs making 1 call to MooX::HandlesVia::import |
24 | 3 | 34µs | 3 | 2.02ms | # spent 1.02ms (8µs+1.01) within JSON::Schema::Modern::Document::BEGIN@24 which was called:
# once (8µs+1.01ms) by JSON::Schema::Modern::BEGIN@35 at line 24 # spent 1.02ms making 1 call to JSON::Schema::Modern::Document::BEGIN@24
# spent 1.00ms making 1 call to Exporter::Tiny::import
# spent 4µs making 1 call to UNIVERSAL::VERSION |
25 | 2 | 713µs | 2 | 399µs | # spent 202µs (5+197) within JSON::Schema::Modern::Document::BEGIN@25 which was called:
# once (5µs+197µs) by JSON::Schema::Modern::BEGIN@35 at line 25 # spent 202µs making 1 call to JSON::Schema::Modern::Document::BEGIN@25
# spent 197µs making 1 call to namespace::clean::import |
26 | |||||
27 | 1 | 1µs | 1 | 2.42ms | extends 'Mojo::JSON::Pointer'; # spent 2.42ms making 1 call to JSON::Schema::Modern::Document::extends |
28 | |||||
29 | 1 | 3µs | 1 | 512µs | has schema => ( # spent 512µ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 | 44µs | 8 | 34µs | # spent 84µs (50+34) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm:38] which was called 8 times, avg 10µs/call:
# 8 times (50µs+34µs) by JSON::Schema::Modern::Document::canonical_uri at line 33 of (eval 267)[Sub/Quote.pm:3], avg 10µs/call # spent 34µs making 8 calls to Mojo::URL::new, avg 4µs/call |
39 | 25 | 140µs | 26 | 479µs | # spent 573µs (94+479) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm:39] which was called 25 times, avg 23µs/call:
# 10 times (38µs+71µs) by JSON::Schema::Modern::Document::_set_canonical_uri at line 28 of (eval 268)[Sub/Quote.pm:3], avg 11µs/call
# 8 times (27µs+116µs) by JSON::Schema::Modern::Document::canonical_uri at line 33 of (eval 267)[Sub/Quote.pm:3], avg 18µs/call
# 6 times (22µs+56µs) by JSON::Schema::Modern::Document::new at line 65 of (eval 428)[Sub/Quote.pm:3], avg 13µs/call
# once (7µs+236µs) by JSON::Schema::Modern::Document::OpenAPI::new at line 68 of (eval 421)[Sub/Quote.pm:3] # spent 254µs making 25 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 10µs/call
# spent 225µs making 1 call to Mojo::URL::new |
40 | 1 | 12µs | 3 | 2.26ms | ); # spent 1.88ms making 1 call to MooX::HandlesVia::has
# spent 275µs making 1 call to Type::Tiny::where
# spent 108µs making 1 call to Types::Standard::InstanceOf |
41 | |||||
42 | has metaschema_uri => ( | ||||
43 | is => 'rwp', | ||||
44 | isa => InstanceOf['Mojo::URL'], | ||||
45 | 15 | 118µs | 30 | 795µs | # spent 882µs (87+795) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm:45] which was called 15 times, avg 59µs/call:
# 14 times (81µs+740µs) by JSON::Schema::Modern::Document::_set_metaschema_uri at line 28 of (eval 270)[Sub/Quote.pm:3], avg 59µs/call
# once (6µs+55µs) by JSON::Schema::Modern::Document::OpenAPI::new at line 128 of (eval 421)[Sub/Quote.pm:3] # spent 674µs making 15 calls to Mojo::URL::new, avg 45µs/call
# spent 121µs making 15 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 8µs/call |
46 | 1 | 6µs | 2 | 980µs | ); # spent 913µs making 1 call to MooX::HandlesVia::has
# spent 67µs making 1 call to Types::Standard::InstanceOf |
47 | |||||
48 | 1 | 4µs | 2 | 1.21ms | has evaluator => ( # spent 890µs making 1 call to MooX::HandlesVia::has
# spent 317µ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 | 32µs | # spent 85µs within JSON::Schema::Modern::Document::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm:78] which was called 15 times, avg 6µs/call:
# 15 times (85µs+0s) by JSON::Schema::Modern::Document::_assert_resource_index at line 23 of (eval 301)[Sub/Quote.pm:3], avg 6µs/call | ||
79 | 1 | 61µs | 13 | 20.1ms | ); # spent 9.87ms making 1 call to MooX::HandlesVia::has
# spent 5.47ms making 1 call to Types::Standard::Dict
# spent 3.53ms making 3 calls to Types::Standard::HashRef, avg 1.18ms/call
# spent 665µs making 1 call to Types::Standard::Slurpy
# spent 339µs making 1 call to Types::Standard::ArrayRef
# spent 153µs making 1 call to Type::Tiny::where
# spent 45µs making 1 call to Types::Standard::InstanceOf
# spent 1µs making 1 call to Types::Standard::ClassName
# spent 1µs making 2 calls to Types::Standard::Str, avg 500ns/call
# spent 1µs making 1 call to Types::Standard::Undef |
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 | 61µs | 12 | 219µs | # spent 341µs (122+219) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm:90] which was called 12 times, avg 28µs/call:
# 12 times (122µs+219µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 23 of (eval 303)[Sub/Quote.pm:3], avg 28µs/call # spent 219µs making 12 calls to JSON::Schema::Modern::Document::_canonical_resources, avg 18µs/call |
91 | 1 | 7µs | 2 | 2.75ms | ); # spent 2.69ms making 1 call to MooX::HandlesVia::has
# spent 62µs making 1 call to Types::Standard::HashRef |
92 | |||||
93 | # for internal use only | ||||
94 | 1 | 5µs | 2 | 707µs | has _serialized_schema => ( # spent 705µs making 1 call to MooX::HandlesVia::has
# spent 2µ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 | 47µs | # spent 23µs within JSON::Schema::Modern::Document::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm:110] which was called 15 times, avg 2µs/call:
# 15 times (23µ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 | 9µs | 3 | 2.21ms | ); # spent 2.10ms making 1 call to MooX::HandlesVia::has
# spent 60µs making 1 call to Types::Standard::InstanceOf
# spent 41µs making 1 call to Types::Standard::ArrayRef |
112 | |||||
113 | # spent 23.4ms (744µs+22.6) within JSON::Schema::Modern::Document::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm:135] which was called 22 times, avg 1.06ms/call:
# 22 times (744µs+22.6ms) 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.06ms/call | ||||
114 | 22 | 22µs | my $orig = shift; | ||
115 | 22 | 7µs | my $self = shift; | ||
116 | |||||
117 | 22 | 224µs | 22 | 84µs | foreach my $pair (pairs @_) { # spent 84µs making 22 calls to List::Util::pairs, avg 4µs/call |
118 | 36 | 16µs | my ($key, $value) = @$pair; | ||
119 | |||||
120 | 36 | 229µs | 108 | 5.11ms | $resource_type->($value); # check type of hash value against Dict # spent 3.10ms making 36 calls to Sub::Defer::__ANON__[Sub/Defer.pm:178], avg 86µs/call
# spent 2.01ms making 72 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 28µs/call |
121 | |||||
122 | 36 | 108µs | 44 | 6.14ms | if (my $existing = $self->_get_resource($key)) { # spent 5.60ms making 36 calls to JSON::Schema::Modern::Document::_get_resource, avg 155µs/call
# spent 545µ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 | 138µs | 72 | 35µs | if ($value->{canonical_uri}->fragment // '') =~ m{^[^/]}; # spent 22µs making 36 calls to Mojo::URL::fragment, avg 611ns/call
# spent 13µs making 36 calls to JSON::Schema::Modern::Document::CORE:match, avg 361ns/call |
132 | |||||
133 | 36 | 72µs | 36 | 7.57ms | $self->$orig($key, $value); # spent 7.57ms making 36 calls to JSON::Schema::Modern::Document::_add_resources, avg 210µs/call |
134 | } | ||||
135 | 1 | 4µs | 1 | 181µs | }; # spent 181µs making 1 call to Moo::around |
136 | |||||
137 | # shims for Mojo::JSON::Pointer | ||||
138 | 47414 | 114ms | 47414 | 75.2ms | # spent 192ms (117+75.2) within JSON::Schema::Modern::Document::data which was called 47414 times, avg 4µs/call:
# 47414 times (117ms+75.2ms) by Mojo::JSON::Pointer::_pointer at line 14 of Mojo/JSON/Pointer.pm, avg 4µs/call # spent 75.2ms making 47414 calls to JSON::Schema::Modern::Document::schema, avg 2µs/call |
139 | 15 | 34µs | # spent 20µs within JSON::Schema::Modern::Document::FOREIGNBUILDARGS which was called 15 times, avg 1µs/call:
# 14 times (19µs+0s) by JSON::Schema::Modern::Document::new at line 53 of (eval 428)[Sub/Quote.pm:3], avg 1µ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 | 10µs | # spent 70.6s (780µs+70.6) within JSON::Schema::Modern::Document::BUILD which was called 15 times, avg 4.71s/call:
# 14 times (688µs+-688µs) by JSON::Schema::Modern::Document::new at line 114 of (eval 428)[Sub/Quote.pm:3], avg 0s/call
# once (92µs+70.6s) by JSON::Schema::Modern::Document::OpenAPI::new at line 149 of (eval 421)[Sub/Quote.pm:3] | ||
145 | 15 | 57µs | 30 | 689µs | my $original_uri = $self->canonical_uri->clone; # spent 447µs making 15 calls to JSON::Schema::Modern::Document::canonical_uri, avg 30µs/call
# spent 242µs making 15 calls to Mojo::URL::clone, avg 16µs/call |
146 | 15 | 67µs | 30 | 70.8s | my $state = $self->traverse($self->evaluator // JSON::Schema::Modern->new); # spent 70.6s making 1 call to JSON::Schema::Modern::Document::OpenAPI::traverse
# spent 169ms making 14 calls to JSON::Schema::Modern::Document::traverse, avg 12.1ms/call
# spent 22µ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 | 144µs | 40 | 2.65ms | $self->_set_canonical_uri($state->{initial_schema_uri}) if $state->{initial_schema_uri} ne $original_uri; # spent 2.35ms making 30 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 78µs/call
# spent 301µs making 10 calls to JSON::Schema::Modern::Document::_set_canonical_uri, avg 30µs/call |
150 | |||||
151 | 15 | 18µ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 | 215µs | 68 | 9.58ms | if (not "$original_uri" and $original_uri eq $self->canonical_uri) # spent 7.23ms making 7 calls to JSON::Schema::Modern::Document::_add_resources, avg 1.03ms/call
# spent 2.30ms making 46 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 50µs/call
# spent 57µs making 15 calls to JSON::Schema::Modern::Document::canonical_uri, avg 4µs/call |
169 | or "$original_uri"; | ||||
170 | |||||
171 | 15 | 240µs | 15 | 16.3ms | $self->_add_resources($state->{identifiers}->@*); # spent 16.3ms making 15 calls to JSON::Schema::Modern::Document::_add_resources, avg 1.09ms/call |
172 | } | ||||
173 | |||||
174 | 42 | 8µs | # spent 169ms (390µs+169) within JSON::Schema::Modern::Document::traverse which was called 14 times, avg 12.1ms/call:
# 14 times (390µs+169ms) by JSON::Schema::Modern::Document::BUILD at line 146, avg 12.1ms/call | ||
175 | die 'wrong class - use JSON::Schema::Modern::Document::OpenAPI instead' | ||||
176 | 14 | 42µs | 28 | 30µs | if is_plain_hashref($self->schema) and exists $self->schema->{openapi}; # spent 30µs making 28 calls to JSON::Schema::Modern::Document::schema, avg 1µs/call |
177 | |||||
178 | 14 | 101µs | 70 | 168ms | my $state = $evaluator->traverse($self->schema, # spent 167ms making 14 calls to JSON::Schema::Modern::traverse, avg 12.0ms/call
# spent 107µs making 14 calls to Mojo::URL::clone, avg 8µs/call
# spent 26µs making 14 calls to JSON::Schema::Modern::Document::metaschema_uri, avg 2µs/call
# spent 7µs making 14 calls to JSON::Schema::Modern::Document::canonical_uri, avg 500ns/call
# spent 6µs making 14 calls to JSON::Schema::Modern::Document::schema, avg 429ns/call |
179 | { | ||||
180 | initial_schema_uri => $self->canonical_uri->clone, | ||||
181 | $self->metaschema_uri ? ( metaschema_uri => $self->metaschema_uri) : (), | ||||
182 | } | ||||
183 | ); | ||||
184 | |||||
185 | 14 | 6µ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 | 83µs | 28 | 29µs | // $self->metaschema_uri // $evaluator->METASCHEMA_URIS->{$state->{spec_version}}; # spent 29µs making 28 calls to JSON::Schema::Modern::Document::schema, avg 1µs/call |
191 | |||||
192 | 14 | 58µs | 28 | 1.11ms | $self->_set_metaschema_uri($metaschema_uri) if $metaschema_uri ne ($self->metaschema_uri//''); # spent 1.08ms making 14 calls to JSON::Schema::Modern::Document::_set_metaschema_uri, avg 78µs/call
# spent 25µs making 14 calls to JSON::Schema::Modern::Document::metaschema_uri, avg 2µs/call |
193 | |||||
194 | 14 | 27µ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 | 31µs | 1; | ||
204 | 1 | 37µs | 1 | 453µs | __END__ # spent 453µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 13µs within JSON::Schema::Modern::Document::CORE:match which was called 36 times, avg 361ns/call:
# 36 times (13µs+0s) by JSON::Schema::Modern::Document::__ANON__[/Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Document.pm:135] at line 131, avg 361ns/call |