← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:33:55 2022
Reported on Wed Dec 14 15:40:04 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm
StatementsExecuted 48512 statements in 150ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4784611132ms223msJSON::Schema::Modern::Document::::dataJSON::Schema::Modern::Document::data
1522803µs104sJSON::Schema::Modern::Document::::BUILDJSON::Schema::Modern::Document::BUILD (recurses: max depth 1, inclusive time 168ms)
2211759µs22.8msJSON::Schema::Modern::Document::::__ANON__[:135]JSON::Schema::Modern::Document::__ANON__[:135]
1411442µs139msJSON::Schema::Modern::Document::::traverseJSON::Schema::Modern::Document::traverse
2544121µs763µsJSON::Schema::Modern::Document::::__ANON__[:39]JSON::Schema::Modern::Document::__ANON__[:39]
1522111µs1.04msJSON::Schema::Modern::Document::::__ANON__[:45]JSON::Schema::Modern::Document::__ANON__[:45]
121190µs272µsJSON::Schema::Modern::Document::::__ANON__[:90]JSON::Schema::Modern::Document::__ANON__[:90]
81168µs102µsJSON::Schema::Modern::Document::::__ANON__[:38]JSON::Schema::Modern::Document::__ANON__[:38]
151152µs52µsJSON::Schema::Modern::Document::::__ANON__[:78]JSON::Schema::Modern::Document::__ANON__[:78]
11128µs31µsJSON::Schema::Modern::::BEGIN@1.110 JSON::Schema::Modern::BEGIN@1.110
151125µs25µsJSON::Schema::Modern::Document::::__ANON__[:110]JSON::Schema::Modern::Document::__ANON__[:110]
152221µs21µsJSON::Schema::Modern::Document::::FOREIGNBUILDARGSJSON::Schema::Modern::Document::FOREIGNBUILDARGS
11117µs17µsJSON::Schema::Modern::Document::::BEGIN@9JSON::Schema::Modern::Document::BEGIN@9
361117µs17µsJSON::Schema::Modern::Document::::CORE:matchJSON::Schema::Modern::Document::CORE:match (opcode)
11115µs606µsJSON::Schema::Modern::Document::::BEGIN@11JSON::Schema::Modern::Document::BEGIN@11
11115µs41µsJSON::Schema::Modern::Document::::BEGIN@13JSON::Schema::Modern::Document::BEGIN@13
11112µs36µsJSON::Schema::Modern::Document::::BEGIN@19JSON::Schema::Modern::Document::BEGIN@19
1119µs21µsJSON::Schema::Modern::Document::::BEGIN@14JSON::Schema::Modern::Document::BEGIN@14
1119µs76µsJSON::Schema::Modern::Document::::BEGIN@21JSON::Schema::Modern::Document::BEGIN@21
1118µs40µsJSON::Schema::Modern::::BEGIN@2.111 JSON::Schema::Modern::BEGIN@2.111
1118µs1.03msJSON::Schema::Modern::Document::::BEGIN@24JSON::Schema::Modern::Document::BEGIN@24
1117µs90µsJSON::Schema::Modern::Document::::BEGIN@12JSON::Schema::Modern::Document::BEGIN@12
1117µs202µsJSON::Schema::Modern::Document::::BEGIN@25JSON::Schema::Modern::Document::BEGIN@25
1116µs284µsJSON::Schema::Modern::Document::::BEGIN@10JSON::Schema::Modern::Document::BEGIN@10
1116µs20µsJSON::Schema::Modern::Document::::BEGIN@15JSON::Schema::Modern::Document::BEGIN@15
1116µs16µsJSON::Schema::Modern::Document::::BEGIN@16JSON::Schema::Modern::Document::BEGIN@16
1116µs10µsJSON::Schema::Modern::Document::::BEGIN@17JSON::Schema::Modern::Document::BEGIN@17
1116µs18µsJSON::Schema::Modern::Document::::BEGIN@20JSON::Schema::Modern::Document::BEGIN@20
1114µs29µsJSON::Schema::Modern::Document::::BEGIN@18JSON::Schema::Modern::Document::BEGIN@18
1114µs310µsJSON::Schema::Modern::Document::::BEGIN@22JSON::Schema::Modern::Document::BEGIN@22
1114µs48µsJSON::Schema::Modern::Document::::BEGIN@23JSON::Schema::Modern::Document::BEGIN@23
0000s0sJSON::Schema::Modern::Document::::TO_JSONJSON::Schema::Modern::Document::TO_JSON
0000s0sJSON::Schema::Modern::Document::::validateJSON::Schema::Modern::Document::validate
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1236µs234µs
# spent 31µs (28+3) within JSON::Schema::Modern::BEGIN@1.110 which was called: # once (28µs+3µs) by JSON::Schema::Modern::BEGIN@35 at line 1
use strict;
# spent 31µs making 1 call to JSON::Schema::Modern::BEGIN@1.110 # spent 3µs making 1 call to strict::import
2243µs272µs
# spent 40µs (8+32) within JSON::Schema::Modern::BEGIN@2.111 which was called: # once (8µs+32µs) by JSON::Schema::Modern::BEGIN@35 at line 2
use warnings;
# spent 40µs making 1 call to JSON::Schema::Modern::BEGIN@2.111 # spent 32µs making 1 call to warnings::import
3package JSON::Schema::Modern::Document;
4# vim: set ts=8 sts=2 sw=2 tw=100 et :
5# ABSTRACT: One JSON Schema document
6
710sour $VERSION = '0.552';
8
9249µs117µs
# spent 17µs within JSON::Schema::Modern::Document::BEGIN@9 which was called: # once (17µs+0s) by JSON::Schema::Modern::BEGIN@35 at line 9
use 5.020;
# spent 17µs making 1 call to JSON::Schema::Modern::Document::BEGIN@9
10228µs2562µs
# spent 284µs (6+278) within JSON::Schema::Modern::Document::BEGIN@10 which was called: # once (6µs+278µs) by JSON::Schema::Modern::BEGIN@35 at line 10
use Moo;
# spent 284µs making 1 call to JSON::Schema::Modern::Document::BEGIN@10 # spent 278µs making 1 call to Moo::import
11330µs31.20ms
# spent 606µs (15+591) within JSON::Schema::Modern::Document::BEGIN@11 which was called: # once (15µs+591µs) by JSON::Schema::Modern::BEGIN@35 at line 11
use strictures 2;
# spent 606µs making 1 call to JSON::Schema::Modern::Document::BEGIN@11 # spent 570µs making 1 call to strictures::import # spent 20µs making 1 call to strictures::VERSION
12232µs2173µs
# spent 90µs (7+83) within JSON::Schema::Modern::Document::BEGIN@12 which was called: # once (7µs+83µs) by JSON::Schema::Modern::BEGIN@35 at line 12
use experimental qw(signatures postderef);
# spent 90µs making 1 call to JSON::Schema::Modern::Document::BEGIN@12 # spent 83µs making 1 call to experimental::import
13226µs244µs
# spent 41µs (15+26) within JSON::Schema::Modern::Document::BEGIN@13 which was called: # once (15µs+26µs) by JSON::Schema::Modern::BEGIN@35 at line 13
use if "$]" >= 5.022, experimental => 're_strict';
# spent 41µs making 1 call to JSON::Schema::Modern::Document::BEGIN@13 # spent 3µs making 1 call to if::import
14223µs223µs
# spent 21µs (9+12) within JSON::Schema::Modern::Document::BEGIN@14 which was called: # once (9µs+12µs) by JSON::Schema::Modern::BEGIN@35 at line 14
no if "$]" >= 5.031009, feature => 'indirect';
# spent 21µs making 1 call to JSON::Schema::Modern::Document::BEGIN@14 # spent 2µs making 1 call to if::unimport
15217µs222µs
# spent 20µs (6+14) within JSON::Schema::Modern::Document::BEGIN@15 which was called: # once (6µs+14µs) by JSON::Schema::Modern::BEGIN@35 at line 15
no if "$]" >= 5.033001, feature => 'multidimensional';
# spent 20µs making 1 call to JSON::Schema::Modern::Document::BEGIN@15 # spent 2µs making 1 call to if::unimport
16213µs218µs
# spent 16µs (6+10) within JSON::Schema::Modern::Document::BEGIN@16 which was called: # once (6µs+10µs) by JSON::Schema::Modern::BEGIN@35 at line 16
no if "$]" >= 5.033006, feature => 'bareword_filehandles';
# spent 16µs making 1 call to JSON::Schema::Modern::Document::BEGIN@16 # spent 2µs making 1 call to if::unimport
17215µs214µs
# spent 10µs (6+4) within JSON::Schema::Modern::Document::BEGIN@17 which was called: # once (6µs+4µs) by JSON::Schema::Modern::BEGIN@35 at line 17
use Mojo::URL;
# spent 10µs making 1 call to JSON::Schema::Modern::Document::BEGIN@17 # spent 4µs making 1 call to Mojo::Base::import
18220µs254µs
# spent 29µs (4+25) within JSON::Schema::Modern::Document::BEGIN@18 which was called: # once (4µs+25µs) by JSON::Schema::Modern::BEGIN@35 at line 18
use Carp 'croak';
# spent 29µs making 1 call to JSON::Schema::Modern::Document::BEGIN@18 # spent 25µs making 1 call to Exporter::import
19328µs349µs
# spent 36µs (12+24) within JSON::Schema::Modern::Document::BEGIN@19 which was called: # once (12µs+24µs) by JSON::Schema::Modern::BEGIN@35 at line 19
use List::Util 1.29 'pairs';
# spent 36µs making 1 call to JSON::Schema::Modern::Document::BEGIN@19 # spent 8µs making 1 call to List::Util::import # spent 5µs making 1 call to UNIVERSAL::VERSION
20321µs330µs
# spent 18µs (6+12) within JSON::Schema::Modern::Document::BEGIN@20 which was called: # once (6µs+12µs) by JSON::Schema::Modern::BEGIN@35 at line 20
use Ref::Util 0.100 'is_plain_hashref';
# spent 18µs making 1 call to JSON::Schema::Modern::Document::BEGIN@20 # spent 8µs making 1 call to Exporter::import # spent 4µs making 1 call to UNIVERSAL::VERSION
21323µs3143µs
# spent 76µs (9+67) within JSON::Schema::Modern::Document::BEGIN@21 which was called: # once (9µs+67µs) by JSON::Schema::Modern::BEGIN@35 at line 21
use Safe::Isa 1.000008;
# spent 76µs making 1 call to JSON::Schema::Modern::Document::BEGIN@21 # spent 64µs making 1 call to Exporter::import # spent 3µs making 1 call to UNIVERSAL::VERSION
22218µs2616µs
# spent 310µs (4+306) within JSON::Schema::Modern::Document::BEGIN@22 which was called: # once (4µs+306µs) by JSON::Schema::Modern::BEGIN@35 at line 22
use MooX::TypeTiny;
# spent 310µs making 1 call to JSON::Schema::Modern::Document::BEGIN@22 # spent 306µs making 1 call to MooX::TypeTiny::import
23218µs292µs
# spent 48µs (4+44) within JSON::Schema::Modern::Document::BEGIN@23 which was called: # once (4µs+44µs) by JSON::Schema::Modern::BEGIN@35 at line 23
use MooX::HandlesVia;
# spent 48µs making 1 call to JSON::Schema::Modern::Document::BEGIN@23 # spent 44µs making 1 call to MooX::HandlesVia::import
24225µs22.05ms
# spent 1.03ms (8µs+1.02) within JSON::Schema::Modern::Document::BEGIN@24 which was called: # once (8µs+1.02ms) by JSON::Schema::Modern::BEGIN@35 at line 24
use Types::Standard qw(InstanceOf HashRef Str Dict ArrayRef Enum ClassName Undef slurpy);
# spent 1.03ms making 1 call to JSON::Schema::Modern::Document::BEGIN@24 # spent 1.02ms making 1 call to Exporter::Tiny::import
252825µs2397µs
# spent 202µs (7+195) within JSON::Schema::Modern::Document::BEGIN@25 which was called: # once (7µs+195µs) by JSON::Schema::Modern::BEGIN@35 at line 25
use namespace::clean;
# spent 202µs making 1 call to JSON::Schema::Modern::Document::BEGIN@25 # spent 195µs making 1 call to namespace::clean::import
26
2710s12.20msextends 'Mojo::JSON::Pointer';
# spent 2.20ms making 1 call to JSON::Schema::Modern::Document::extends
28
2911µs1422µshas schema => (
# spent 422µs making 1 call to MooX::HandlesVia::has
30 is => 'ro',
31 required => 1,
32);
33
34has canonical_uri => (
35 is => 'rwp',
36 isa => (InstanceOf['Mojo::URL'])->where(q{not defined $_->fragment}),
37 lazy => 1,
38843µs834µs
# spent 102µs (68+34) 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 13µs/call: # 8 times (68µs+34µs) by JSON::Schema::Modern::Document::canonical_uri at line 33 of (eval 263)[Sub/Quote.pm:3], avg 13µs/call
default => sub { Mojo::URL->new },
# spent 34µs making 8 calls to Mojo::URL::new, avg 4µs/call
3925135µs26642µs
# spent 763µs (121+642) 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 31µs/call: # 10 times (44µs+119µs) by JSON::Schema::Modern::Document::_set_canonical_uri at line 28 of (eval 264)[Sub/Quote.pm:3], avg 16µs/call # 8 times (36µs+104µs) by JSON::Schema::Modern::Document::canonical_uri at line 33 of (eval 263)[Sub/Quote.pm:3], avg 18µs/call # 6 times (22µs+89µs) by JSON::Schema::Modern::Document::new at line 65 of (eval 424)[Sub/Quote.pm:3], avg 18µs/call # once (19µs+330µs) by JSON::Schema::Modern::Document::OpenAPI::new at line 68 of (eval 417)[Sub/Quote.pm:3]
coerce => sub { $_[0]->$_isa('Mojo::URL') ? $_[0] : Mojo::URL->new($_[0]) },
# spent 325µs making 25 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 13µs/call # spent 317µs making 1 call to Mojo::URL::new
40111µs32.85ms);
# spent 2.62ms making 1 call to MooX::HandlesVia::has # spent 160µs making 1 call to Type::Tiny::where # spent 68µs making 1 call to Types::Standard::InstanceOf
41
42has metaschema_uri => (
43 is => 'rwp',
44 isa => InstanceOf['Mojo::URL'],
451582µs30933µs
# spent 1.04ms (111µs+933µs) 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 70µs/call: # 14 times (101µs+840µs) by JSON::Schema::Modern::Document::_set_metaschema_uri at line 28 of (eval 266)[Sub/Quote.pm:3], avg 67µs/call # once (10µs+93µs) by JSON::Schema::Modern::Document::OpenAPI::new at line 128 of (eval 417)[Sub/Quote.pm:3]
coerce => sub { $_[0]->$_isa('Mojo::URL') ? $_[0] : Mojo::URL->new($_[0]) },
# spent 791µs making 15 calls to Mojo::URL::new, avg 53µs/call # spent 142µs making 15 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 9µs/call
4617µs21.60ms);
# spent 1.52ms making 1 call to MooX::HandlesVia::has # spent 86µs making 1 call to Types::Standard::InstanceOf
47
4814µs21.29mshas evaluator => (
# spent 919µs making 1 call to MooX::HandlesVia::has # spent 375µ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
56has 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,
781522µs
# spent 52µ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 3µs/call: # 15 times (52µs+0s) by JSON::Schema::Modern::Document::_assert_resource_index at line 23 of (eval 297)[Sub/Quote.pm:3], avg 3µs/call
default => sub { {} },
79139µs1327.5ms);
# spent 13.1ms making 1 call to MooX::HandlesVia::has # spent 8.11ms making 1 call to Types::Standard::Dict # spent 4.79ms making 3 calls to Types::Standard::HashRef, avg 1.60ms/call # spent 685µs making 1 call to Types::Standard::slurpy # spent 541µs making 1 call to Types::Standard::ArrayRef # spent 147µs making 1 call to Type::Tiny::where # spent 76µ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
81has _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,
901268µs12182µs
# spent 272µs (90+182) 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 23µs/call: # 12 times (90µs+182µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 23 of (eval 299)[Sub/Quote.pm:3], avg 23µs/call
default => sub { +{ map +($_->{path} => $_), shift->_canonical_resources } },
# spent 182µs making 12 calls to JSON::Schema::Modern::Document::_canonical_resources, avg 15µs/call
91116µs24.68ms);
# spent 4.59ms making 1 call to MooX::HandlesVia::has # spent 91µs making 1 call to Types::Standard::HashRef
92
93# for internal use only
9416µs21.05mshas _serialized_schema => (
# spent 1.05ms 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
100has 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,
1101531µs
# spent 25µ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 (25µs+0s) by JSON::Schema::Modern::Document::_assert_errors at line 23 of (eval 304)[Sub/Quote.pm:3], avg 2µs/call
default => sub { [] },
111113µs32.81ms);
# spent 2.65ms making 1 call to MooX::HandlesVia::has # spent 88µs making 1 call to Types::Standard::InstanceOf # spent 68µs making 1 call to Types::Standard::ArrayRef
112
113
# spent 22.8ms (759µs+22.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.03ms/call: # 22 times (759µs+22.0ms) by JSON::Schema::Modern::Document::__ANON__[(eval 306)[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/Class/Method/Modifiers.pm:89]:1] at line 1 of (eval 306)[Class/Method/Modifiers.pm:89], avg 1.03ms/call
around _add_resources => sub {
1142256µs my $orig = shift;
115228µs my $self = shift;
116
11722239µs2291µs foreach my $pair (pairs @_) {
# spent 91µs making 22 calls to List::Util::pairs, avg 4µs/call
1183627µs my ($key, $value) = @$pair;
119
12036220µs1084.63ms $resource_type->($value); # check type of hash value against Dict
# spent 2.67ms making 36 calls to Sub::Defer::__ANON__[Sub/Defer.pm:178], avg 74µs/call # spent 1.97ms making 72 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 27µs/call
121
12236105µs445.70ms if (my $existing = $self->_get_resource($key)) {
# spent 5.17ms making 36 calls to JSON::Schema::Modern::Document::_get_resource, avg 144µs/call # spent 529µs making 8 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 66µ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})
13136119µs7238µs if ($value->{canonical_uri}->fragment // '') =~ m{^[^/]};
# spent 21µs making 36 calls to Mojo::URL::fragment, avg 583ns/call # spent 17µs making 36 calls to JSON::Schema::Modern::Document::CORE:match, avg 472ns/call
132
1333682µs367.59ms $self->$orig($key, $value);
# spent 7.59ms making 36 calls to JSON::Schema::Modern::Document::_add_resources, avg 211µs/call
134 }
13515µs1270µs};
# spent 270µs making 1 call to Moo::around
136
137# shims for Mojo::JSON::Pointer
13847846146ms4784691.9ms
# spent 223ms (132+91.9) within JSON::Schema::Modern::Document::data which was called 47846 times, avg 5µs/call: # 47846 times (132ms+91.9ms) by Mojo::JSON::Pointer::_pointer at line 14 of Mojo/JSON/Pointer.pm, avg 5µs/call
sub data { shift->schema(@_) }
# spent 91.9ms making 47846 calls to JSON::Schema::Modern::Document::schema, avg 2µs/call
1391546µs
# spent 21µs within JSON::Schema::Modern::Document::FOREIGNBUILDARGS which was called 15 times, avg 1µs/call: # 14 times (20µs+0s) by JSON::Schema::Modern::Document::new at line 53 of (eval 424)[Sub/Quote.pm:3], avg 1µs/call # once (1µs+0s) by JSON::Schema::Modern::Document::OpenAPI::new at line 56 of (eval 417)[Sub/Quote.pm:3]
sub FOREIGNBUILDARGS { () }
140
141# for JSON serializers
142sub TO_JSON { shift->schema }
143
1444515µs
# spent 104s (803µs+104) within JSON::Schema::Modern::Document::BUILD which was called 15 times, avg 6.92s/call: # 14 times (649µs+-649µs) by JSON::Schema::Modern::Document::new at line 114 of (eval 424)[Sub/Quote.pm:3], avg 0s/call # once (154µs+104s) by JSON::Schema::Modern::Document::OpenAPI::new at line 149 of (eval 417)[Sub/Quote.pm:3]
sub BUILD ($self, $args) {
1451557µs30740µs my $original_uri = $self->canonical_uri->clone;
# spent 486µs making 15 calls to JSON::Schema::Modern::Document::canonical_uri, avg 32µs/call # spent 254µs making 15 calls to Mojo::URL::clone, avg 17µs/call
1461561µs30104s my $state = $self->traverse($self->evaluator // JSON::Schema::Modern->new);
# spent 104s making 1 call to JSON::Schema::Modern::Document::OpenAPI::traverse # spent 139ms making 14 calls to JSON::Schema::Modern::Document::traverse, avg 9.94ms/call # spent 56µs making 14 calls to JSON::Schema::Modern::Document::evaluator, avg 4µ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
14915120µs403.25ms $self->_set_canonical_uri($state->{initial_schema_uri}) if $state->{initial_schema_uri} ne $original_uri;
# spent 2.91ms making 30 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 97µs/call # spent 347µs making 10 calls to JSON::Schema::Modern::Document::_set_canonical_uri, avg 35µs/call
150
1511511µ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 })
16815208µs689.16ms if (not "$original_uri" and $original_uri eq $self->canonical_uri)
# spent 6.09ms making 7 calls to JSON::Schema::Modern::Document::_add_resources, avg 870µs/call # spent 3.00ms making 46 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 65µs/call # spent 71µs making 15 calls to JSON::Schema::Modern::Document::canonical_uri, avg 5µs/call
169 or "$original_uri";
170
17115206µs1517.0ms $self->_add_resources($state->{identifiers}->@*);
# spent 17.0ms making 15 calls to JSON::Schema::Modern::Document::_add_resources, avg 1.13ms/call
172}
173
174429µs
# spent 139ms (442µs+139) within JSON::Schema::Modern::Document::traverse which was called 14 times, avg 9.94ms/call: # 14 times (442µs+139ms) by JSON::Schema::Modern::Document::BUILD at line 146, avg 9.94ms/call
sub traverse ($self, $evaluator) {
175 die 'wrong class - use JSON::Schema::Modern::Document::OpenAPI instead'
1761447µs2836µs if is_plain_hashref($self->schema) and exists $self->schema->{openapi};
# spent 36µs making 28 calls to JSON::Schema::Modern::Document::schema, avg 1µs/call
177
17814133µs70137ms my $state = $evaluator->traverse($self->schema,
# spent 137ms making 14 calls to JSON::Schema::Modern::traverse, avg 9.80ms/call # spent 130µs making 14 calls to Mojo::URL::clone, avg 9µs/call # spent 34µ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 10µs making 14 calls to JSON::Schema::Modern::Document::canonical_uri, avg 714ns/call
179 {
180 initial_schema_uri => $self->canonical_uri->clone,
181 $self->metaschema_uri ? ( metaschema_uri => $self->metaschema_uri) : (),
182 }
183 );
184
185146µ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)
1901458µs2843µs // $self->metaschema_uri // $evaluator->METASCHEMA_URIS->{$state->{spec_version}};
# spent 43µs making 28 calls to JSON::Schema::Modern::Document::schema, avg 2µs/call
191
1921471µs281.24ms $self->_set_metaschema_uri($metaschema_uri) if $metaschema_uri ne ($self->metaschema_uri//'');
# spent 1.21ms making 14 calls to JSON::Schema::Modern::Document::_set_metaschema_uri, avg 87µs/call # spent 30µs making 14 calls to JSON::Schema::Modern::Document::metaschema_uri, avg 2µs/call
193
1941433µs return $state;
195}
196
197sub 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
203145µs1;
204
205135µs1358µs__END__
 
# spent 17µs within JSON::Schema::Modern::Document::CORE:match which was called 36 times, avg 472ns/call: # 36 times (17µ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 472ns/call
sub JSON::Schema::Modern::Document::CORE:match; # opcode