← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Wed Dec 14 15:57:08 2022
Reported on Wed Dec 14 16:00:34 2022

Filename/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document.pm
StatementsExecuted 48513 statements in 143ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4784611147ms239msJSON::Schema::Modern::Document::::dataJSON::Schema::Modern::Document::data
1522998µs108sJSON::Schema::Modern::Document::::BUILDJSON::Schema::Modern::Document::BUILD (recurses: max depth 1, inclusive time 185ms)
2211824µs31.9msJSON::Schema::Modern::Document::::__ANON__[:135]JSON::Schema::Modern::Document::__ANON__[:135]
1411486µs146msJSON::Schema::Modern::Document::::traverseJSON::Schema::Modern::Document::traverse
2544125µs906µsJSON::Schema::Modern::Document::::__ANON__[:39]JSON::Schema::Modern::Document::__ANON__[:39]
1211121µs506µsJSON::Schema::Modern::Document::::__ANON__[:90]JSON::Schema::Modern::Document::__ANON__[:90]
1522113µs1.21msJSON::Schema::Modern::Document::::__ANON__[:45]JSON::Schema::Modern::Document::__ANON__[:45]
361176µs76µsJSON::Schema::Modern::Document::::CORE:matchJSON::Schema::Modern::Document::CORE:match (opcode)
81162µs96µsJSON::Schema::Modern::Document::::__ANON__[:38]JSON::Schema::Modern::Document::__ANON__[:38]
11150µs55µsJSON::Schema::Modern::::BEGIN@1.110 JSON::Schema::Modern::BEGIN@1.110
151150µs50µsJSON::Schema::Modern::Document::::__ANON__[:110]JSON::Schema::Modern::Document::__ANON__[:110]
11133µs1.26msJSON::Schema::Modern::Document::::BEGIN@24JSON::Schema::Modern::Document::BEGIN@24
151129µs29µsJSON::Schema::Modern::Document::::__ANON__[:78]JSON::Schema::Modern::Document::__ANON__[:78]
11127µs840µsJSON::Schema::Modern::Document::::BEGIN@11JSON::Schema::Modern::Document::BEGIN@11
11127µs72µsJSON::Schema::Modern::Document::::BEGIN@19JSON::Schema::Modern::Document::BEGIN@19
152221µs21µsJSON::Schema::Modern::Document::::FOREIGNBUILDARGSJSON::Schema::Modern::Document::FOREIGNBUILDARGS
11118µs422µsJSON::Schema::Modern::Document::::BEGIN@10JSON::Schema::Modern::Document::BEGIN@10
11114µs43µsJSON::Schema::Modern::Document::::BEGIN@13JSON::Schema::Modern::Document::BEGIN@13
11114µs14µsJSON::Schema::Modern::Document::::BEGIN@9JSON::Schema::Modern::Document::BEGIN@9
11113µs21µsJSON::Schema::Modern::Document::::BEGIN@17JSON::Schema::Modern::Document::BEGIN@17
11112µs148µsJSON::Schema::Modern::Document::::BEGIN@12JSON::Schema::Modern::Document::BEGIN@12
11112µs103µsJSON::Schema::Modern::Document::::BEGIN@23JSON::Schema::Modern::Document::BEGIN@23
11111µs50µsJSON::Schema::Modern::Document::::BEGIN@18JSON::Schema::Modern::Document::BEGIN@18
11110µs23µsJSON::Schema::Modern::Document::::BEGIN@14JSON::Schema::Modern::Document::BEGIN@14
11110µs600µsJSON::Schema::Modern::Document::::BEGIN@22JSON::Schema::Modern::Document::BEGIN@22
1119µs19µsJSON::Schema::Modern::Document::::BEGIN@16JSON::Schema::Modern::Document::BEGIN@16
1119µs25µsJSON::Schema::Modern::Document::::BEGIN@20JSON::Schema::Modern::Document::BEGIN@20
1119µs98µsJSON::Schema::Modern::Document::::BEGIN@21JSON::Schema::Modern::Document::BEGIN@21
1118µs21µsJSON::Schema::Modern::Document::::BEGIN@15JSON::Schema::Modern::Document::BEGIN@15
1117µs375µsJSON::Schema::Modern::Document::::BEGIN@25JSON::Schema::Modern::Document::BEGIN@25
1116µs41µsJSON::Schema::Modern::::BEGIN@2.111 JSON::Schema::Modern::BEGIN@2.111
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
1239µs260µs
# spent 55µs (50+5) within JSON::Schema::Modern::BEGIN@1.110 which was called: # once (50µs+5µs) by JSON::Schema::Modern::BEGIN@35 at line 1
use strict;
# spent 55µs making 1 call to JSON::Schema::Modern::BEGIN@1.110 # spent 5µs making 1 call to strict::import
2267µs276µs
# spent 41µs (6+35) within JSON::Schema::Modern::BEGIN@2.111 which was called: # once (6µs+35µs) by JSON::Schema::Modern::BEGIN@35 at line 2
use warnings;
# spent 41µs making 1 call to JSON::Schema::Modern::BEGIN@2.111 # spent 35µ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
711µsour $VERSION = '0.556';
8
9245µs114µs
# spent 14µs within JSON::Schema::Modern::Document::BEGIN@9 which was called: # once (14µs+0s) by JSON::Schema::Modern::BEGIN@35 at line 9
use 5.020;
# spent 14µs making 1 call to JSON::Schema::Modern::Document::BEGIN@9
10254µs2826µs
# spent 422µs (18+404) within JSON::Schema::Modern::Document::BEGIN@10 which was called: # once (18µs+404µs) by JSON::Schema::Modern::BEGIN@35 at line 10
use Moo;
# spent 422µs making 1 call to JSON::Schema::Modern::Document::BEGIN@10 # spent 404µs making 1 call to Moo::import
113117µs31.65ms
# spent 840µs (27+813) within JSON::Schema::Modern::Document::BEGIN@11 which was called: # once (27µs+813µs) by JSON::Schema::Modern::BEGIN@35 at line 11
use strictures 2;
# spent 840µs making 1 call to JSON::Schema::Modern::Document::BEGIN@11 # spent 791µs making 1 call to strictures::import # spent 21µs making 1 call to strictures::VERSION
12249µs2284µs
# spent 148µs (12+136) within JSON::Schema::Modern::Document::BEGIN@12 which was called: # once (12µs+136µs) by JSON::Schema::Modern::BEGIN@35 at line 12
use experimental qw(signatures postderef);
# spent 148µs making 1 call to JSON::Schema::Modern::Document::BEGIN@12 # spent 136µs making 1 call to experimental::import
13227µs246µs
# spent 43µs (14+29) within JSON::Schema::Modern::Document::BEGIN@13 which was called: # once (14µs+29µs) by JSON::Schema::Modern::BEGIN@35 at line 13
use if "$]" >= 5.022, experimental => 're_strict';
# spent 43µs making 1 call to JSON::Schema::Modern::Document::BEGIN@13 # spent 3µs making 1 call to if::import
14221µs224µs
# spent 23µs (10+13) within JSON::Schema::Modern::Document::BEGIN@14 which was called: # once (10µs+13µs) by JSON::Schema::Modern::BEGIN@35 at line 14
no if "$]" >= 5.031009, feature => 'indirect';
# spent 23µs making 1 call to JSON::Schema::Modern::Document::BEGIN@14 # spent 1µs making 1 call to if::unimport
15219µs223µs
# spent 21µs (8+13) within JSON::Schema::Modern::Document::BEGIN@15 which was called: # once (8µs+13µs) by JSON::Schema::Modern::BEGIN@35 at line 15
no if "$]" >= 5.033001, feature => 'multidimensional';
# spent 21µs making 1 call to JSON::Schema::Modern::Document::BEGIN@15 # spent 2µs making 1 call to if::unimport
16258µs220µs
# spent 19µs (9+10) within JSON::Schema::Modern::Document::BEGIN@16 which was called: # once (9µs+10µs) by JSON::Schema::Modern::BEGIN@35 at line 16
no if "$]" >= 5.033006, feature => 'bareword_filehandles';
# spent 19µs making 1 call to JSON::Schema::Modern::Document::BEGIN@16 # spent 1µs making 1 call to if::unimport
17246µs229µs
# spent 21µs (13+8) within JSON::Schema::Modern::Document::BEGIN@17 which was called: # once (13µs+8µs) by JSON::Schema::Modern::BEGIN@35 at line 17
use Mojo::URL;
# spent 21µs making 1 call to JSON::Schema::Modern::Document::BEGIN@17 # spent 8µs making 1 call to Mojo::Base::import
18232µs289µs
# spent 50µs (11+39) within JSON::Schema::Modern::Document::BEGIN@18 which was called: # once (11µs+39µs) by JSON::Schema::Modern::BEGIN@35 at line 18
use Carp 'croak';
# spent 50µs making 1 call to JSON::Schema::Modern::Document::BEGIN@18 # spent 39µs making 1 call to Exporter::import
19346µs395µs
# spent 72µs (27+45) within JSON::Schema::Modern::Document::BEGIN@19 which was called: # once (27µs+45µs) by JSON::Schema::Modern::BEGIN@35 at line 19
use List::Util 1.29 'pairs';
# spent 72µs making 1 call to JSON::Schema::Modern::Document::BEGIN@19 # spent 12µs making 1 call to UNIVERSAL::VERSION # spent 11µs making 1 call to List::Util::import
20325µs341µs
# spent 25µs (9+16) within JSON::Schema::Modern::Document::BEGIN@20 which was called: # once (9µs+16µs) by JSON::Schema::Modern::BEGIN@35 at line 20
use Ref::Util 0.100 'is_plain_hashref';
# spent 25µs making 1 call to JSON::Schema::Modern::Document::BEGIN@20 # spent 11µs making 1 call to Exporter::import # spent 5µs making 1 call to UNIVERSAL::VERSION
21330µs3187µs
# spent 98µs (9+89) within JSON::Schema::Modern::Document::BEGIN@21 which was called: # once (9µs+89µs) by JSON::Schema::Modern::BEGIN@35 at line 21
use Safe::Isa 1.000008;
# spent 98µs making 1 call to JSON::Schema::Modern::Document::BEGIN@21 # spent 86µs making 1 call to Exporter::import # spent 3µs making 1 call to UNIVERSAL::VERSION
22239µs21.19ms
# spent 600µs (10+590) within JSON::Schema::Modern::Document::BEGIN@22 which was called: # once (10µs+590µs) by JSON::Schema::Modern::BEGIN@35 at line 22
use MooX::TypeTiny;
# spent 600µs making 1 call to JSON::Schema::Modern::Document::BEGIN@22 # spent 590µs making 1 call to MooX::TypeTiny::import
23270µs2194µs
# spent 103µs (12+91) within JSON::Schema::Modern::Document::BEGIN@23 which was called: # once (12µs+91µs) by JSON::Schema::Modern::BEGIN@35 at line 23
use MooX::HandlesVia;
# spent 103µs making 1 call to JSON::Schema::Modern::Document::BEGIN@23 # spent 91µs making 1 call to MooX::HandlesVia::import
24372µs32.48ms
# spent 1.26ms (33µs+1.22) within JSON::Schema::Modern::Document::BEGIN@24 which was called: # once (33µs+1.22ms) by JSON::Schema::Modern::BEGIN@35 at line 24
use Types::Standard 1.016003 qw(InstanceOf HashRef Str Dict ArrayRef Enum ClassName Undef Slurpy);
# spent 1.26ms making 1 call to JSON::Schema::Modern::Document::BEGIN@24 # spent 1.21ms making 1 call to Exporter::Tiny::import # spent 12µs making 1 call to UNIVERSAL::VERSION
2521.36ms2743µs
# spent 375µs (7+368) within JSON::Schema::Modern::Document::BEGIN@25 which was called: # once (7µs+368µs) by JSON::Schema::Modern::BEGIN@35 at line 25
use namespace::clean;
# spent 375µs making 1 call to JSON::Schema::Modern::Document::BEGIN@25 # spent 368µs making 1 call to namespace::clean::import
26
2713µs12.45msextends 'Mojo::JSON::Pointer';
# spent 2.45ms making 1 call to JSON::Schema::Modern::Document::extends
28
2913µs1790µshas schema => (
# spent 790µ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,
38853µs834µs
# spent 96µs (62+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 12µs/call: # 8 times (62µs+34µs) by JSON::Schema::Modern::Document::canonical_uri at line 33 of (eval 263)[Sub/Quote.pm:3], avg 12µs/call
default => sub { Mojo::URL->new },
# spent 34µs making 8 calls to Mojo::URL::new, avg 4µs/call
3925104µs26781µs
# spent 906µs (125+781) 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 36µs/call: # 10 times (40µs+137µs) by JSON::Schema::Modern::Document::_set_canonical_uri at line 28 of (eval 264)[Sub/Quote.pm:3], avg 18µs/call # 8 times (38µs+147µs) by JSON::Schema::Modern::Document::canonical_uri at line 33 of (eval 263)[Sub/Quote.pm:3], avg 23µs/call # 6 times (24µs+78µs) by JSON::Schema::Modern::Document::new at line 65 of (eval 424)[Sub/Quote.pm:3], avg 17µs/call # once (23µs+419µ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 399µs making 1 call to Mojo::URL::new # spent 382µs making 25 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 15µs/call
40129µs34.50ms);
# spent 4.03ms making 1 call to MooX::HandlesVia::has # spent 278µs making 1 call to Type::Tiny::where # spent 196µs making 1 call to Types::Standard::InstanceOf
41
42has metaschema_uri => (
43 is => 'rwp',
44 isa => InstanceOf['Mojo::URL'],
451587µs301.09ms
# spent 1.21ms (113µs+1.09) 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 81µs/call: # 14 times (102µs+999µs) by JSON::Schema::Modern::Document::_set_metaschema_uri at line 28 of (eval 266)[Sub/Quote.pm:3], avg 79µs/call # once (11µs+96µ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 921µs making 15 calls to Mojo::URL::new, avg 61µs/call # spent 174µs making 15 calls to Safe::Isa::__ANON__[Safe/Isa.pm:23], avg 12µs/call
46112µs21.99ms);
# spent 1.80ms making 1 call to MooX::HandlesVia::has # spent 195µs making 1 call to Types::Standard::InstanceOf
47
4818µs22.91mshas evaluator => (
# spent 2.27ms making 1 call to MooX::HandlesVia::has # spent 640µ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,
781532µs
# spent 29µ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 (29µs+0s) by JSON::Schema::Modern::Document::_assert_resource_index at line 23 of (eval 297)[Sub/Quote.pm:3], avg 2µs/call
default => sub { {} },
79182µs1327.5ms);
# spent 10.2ms making 1 call to MooX::HandlesVia::has # spent 8.84ms making 1 call to Types::Standard::Dict # spent 5.79ms making 3 calls to Types::Standard::HashRef, avg 1.93ms/call # spent 1.31ms making 1 call to Types::Standard::Slurpy # spent 1.01ms making 1 call to Types::Standard::ArrayRef # spent 287µs making 1 call to Type::Tiny::where # spent 128µs making 1 call to Types::Standard::InstanceOf # spent 7µs making 1 call to Types::Standard::Undef # spent 3µs making 2 calls to Types::Standard::Str, avg 2µs/call # spent 1µs making 1 call to Types::Standard::ClassName
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,
9012142µs12385µs
# spent 506µs (121+385) 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 42µs/call: # 12 times (121µs+385µs) by JSON::Schema::Modern::Document::_assert__path_to_resource at line 23 of (eval 299)[Sub/Quote.pm:3], avg 42µs/call
default => sub { +{ map +($_->{path} => $_), shift->_canonical_resources } },
# spent 385µs making 12 calls to JSON::Schema::Modern::Document::_canonical_resources, avg 32µs/call
9118µs23.42ms);
# spent 3.36ms making 1 call to MooX::HandlesVia::has # spent 63µs making 1 call to Types::Standard::HashRef
92
93# for internal use only
9414µs2747µshas _serialized_schema => (
# spent 746µs making 1 call to MooX::HandlesVia::has # spent 1µ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,
1101583µs
# spent 50µ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 3µs/call: # 15 times (50µs+0s) by JSON::Schema::Modern::Document::_assert_errors at line 23 of (eval 304)[Sub/Quote.pm:3], avg 3µs/call
default => sub { [] },
111112µs32.66ms);
# spent 2.56ms making 1 call to MooX::HandlesVia::has # spent 66µs making 1 call to Types::Standard::InstanceOf # spent 38µs making 1 call to Types::Standard::ArrayRef
112
113
# spent 31.9ms (824µs+31.1) 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.45ms/call: # 22 times (824µs+31.1ms) 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.45ms/call
around _add_resources => sub {
114224µs my $orig = shift;
1152210µs my $self = shift;
116
11722290µs22154µs foreach my $pair (pairs @_) {
# spent 154µs making 22 calls to List::Util::pairs, avg 7µs/call
1183622µs my ($key, $value) = @$pair;
119
12036275µs1088.72ms $resource_type->($value); # check type of hash value against Dict
# spent 4.93ms making 36 calls to Sub::Defer::__ANON__[Sub/Defer.pm:178], avg 137µs/call # spent 3.79ms making 72 calls to Type::Tiny::__ANON__[Type/Tiny.pm:89], avg 53µs/call
121
12236115µs448.47ms if (my $existing = $self->_get_resource($key)) {
# spent 7.51ms making 36 calls to JSON::Schema::Modern::Document::_get_resource, avg 209µs/call # spent 958µs making 8 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 120µ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})
13136186µs72111µs if ($value->{canonical_uri}->fragment // '') =~ m{^[^/]};
# spent 76µs making 36 calls to JSON::Schema::Modern::Document::CORE:match, avg 2µs/call # spent 35µs making 36 calls to Mojo::URL::fragment, avg 972ns/call
132
13336125µs3610.2ms $self->$orig($key, $value);
# spent 10.2ms making 36 calls to JSON::Schema::Modern::Document::_add_resources, avg 284µs/call
134 }
135113µs1476µs};
# spent 476µs making 1 call to Moo::around
136
137# shims for Mojo::JSON::Pointer
13847846138ms4784691.7ms
# spent 239ms (147+91.7) within JSON::Schema::Modern::Document::data which was called 47846 times, avg 5µs/call: # 47846 times (147ms+91.7ms) by Mojo::JSON::Pointer::_pointer at line 14 of Mojo/JSON/Pointer.pm, avg 5µs/call
sub data { shift->schema(@_) }
# spent 91.7ms making 47846 calls to JSON::Schema::Modern::Document::schema, avg 2µs/call
1391551µs
# spent 21µs within JSON::Schema::Modern::Document::FOREIGNBUILDARGS which was called 15 times, avg 1µs/call: # 14 times (18µs+0s) by JSON::Schema::Modern::Document::new at line 53 of (eval 424)[Sub/Quote.pm:3], avg 1µs/call # once (3µ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
1444517µs
# spent 108s (998µs+108) within JSON::Schema::Modern::Document::BUILD which was called 15 times, avg 7.21s/call: # 14 times (853µs+-853µs) by JSON::Schema::Modern::Document::new at line 114 of (eval 424)[Sub/Quote.pm:3], avg 0s/call # once (145µs+108s) by JSON::Schema::Modern::Document::OpenAPI::new at line 149 of (eval 417)[Sub/Quote.pm:3]
sub BUILD ($self, $args) {
14515112µs30856µs my $original_uri = $self->canonical_uri->clone;
# spent 508µs making 15 calls to JSON::Schema::Modern::Document::canonical_uri, avg 34µs/call # spent 348µs making 15 calls to Mojo::URL::clone, avg 23µs/call
1461574µs30108s my $state = $self->traverse($self->evaluator // JSON::Schema::Modern->new);
# spent 108s making 1 call to JSON::Schema::Modern::Document::OpenAPI::traverse # spent 146ms making 14 calls to JSON::Schema::Modern::Document::traverse, avg 10.5ms/call # spent 31µ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
14915147µs403.59ms $self->_set_canonical_uri($state->{initial_schema_uri}) if $state->{initial_schema_uri} ne $original_uri;
# spent 3.21ms making 30 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 107µs/call # spent 380µs making 10 calls to JSON::Schema::Modern::Document::_set_canonical_uri, avg 38µ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 })
16815167µs6812.6ms if (not "$original_uri" and $original_uri eq $self->canonical_uri)
# spent 9.78ms making 7 calls to JSON::Schema::Modern::Document::_add_resources, avg 1.40ms/call # spent 2.80ms making 46 calls to Mojo::URL::__ANON__[Mojo/URL.pm:3], avg 61µs/call # spent 47µs making 15 calls to JSON::Schema::Modern::Document::canonical_uri, avg 3µs/call
169 or "$original_uri";
170
17115246µs1522.4ms $self->_add_resources($state->{identifiers}->@*);
# spent 22.4ms making 15 calls to JSON::Schema::Modern::Document::_add_resources, avg 1.49ms/call
172}
173
174426µs
# spent 146ms (486µs+146) within JSON::Schema::Modern::Document::traverse which was called 14 times, avg 10.5ms/call: # 14 times (486µs+146ms) by JSON::Schema::Modern::Document::BUILD at line 146, avg 10.5ms/call
sub traverse ($self, $evaluator) {
175 die 'wrong class - use JSON::Schema::Modern::Document::OpenAPI instead'
1761444µs2828µs if is_plain_hashref($self->schema) and exists $self->schema->{openapi};
# spent 28µs making 28 calls to JSON::Schema::Modern::Document::schema, avg 1µs/call
177
17814144µs70144ms my $state = $evaluator->traverse($self->schema,
# spent 144ms making 14 calls to JSON::Schema::Modern::traverse, avg 10.3ms/call # spent 184µs making 14 calls to Mojo::URL::clone, avg 13µs/call # spent 26µs making 14 calls to JSON::Schema::Modern::Document::metaschema_uri, avg 2µs/call # spent 12µs making 14 calls to JSON::Schema::Modern::Document::canonical_uri, avg 857ns/call # spent 5µs making 14 calls to JSON::Schema::Modern::Document::schema, avg 357ns/call
179 {
180 initial_schema_uri => $self->canonical_uri->clone,
181 $self->metaschema_uri ? ( metaschema_uri => $self->metaschema_uri) : (),
182 }
183 );
184
185149µ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)
1901456µs2835µ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
1921470µs281.42ms $self->_set_metaschema_uri($metaschema_uri) if $metaschema_uri ne ($self->metaschema_uri//'');
# spent 1.39ms making 14 calls to JSON::Schema::Modern::Document::_set_metaschema_uri, avg 99µs/call # spent 28µs making 14 calls to JSON::Schema::Modern::Document::metaschema_uri, avg 2µs/call
193
1941439µ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
203169µs1;
204
205169µs1467µs__END__
 
# spent 76µs within JSON::Schema::Modern::Document::CORE:match which was called 36 times, avg 2µs/call: # 36 times (76µ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 2µs/call
sub JSON::Schema::Modern::Document::CORE:match; # opcode