| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Annotation.pm |
| Statements | Executed 36 statements in 982µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 19µs | 22µs | JSON::Schema::Modern::Result::BEGIN@1 |
| 1 | 1 | 1 | 13µs | 637µs | JSON::Schema::Modern::Annotation::BEGIN@11 |
| 1 | 1 | 1 | 11µs | 32µs | JSON::Schema::Modern::Annotation::BEGIN@13 |
| 1 | 1 | 1 | 10µs | 10µs | JSON::Schema::Modern::Annotation::BEGIN@9 |
| 1 | 1 | 1 | 9µs | 12µs | JSON::Schema::Modern::Annotation::BEGIN@16 |
| 1 | 1 | 1 | 8µs | 21µs | JSON::Schema::Modern::Annotation::BEGIN@14 |
| 1 | 1 | 1 | 8µs | 14µs | JSON::Schema::Modern::Annotation::BEGIN@15 |
| 1 | 1 | 1 | 7µs | 213µs | JSON::Schema::Modern::Annotation::BEGIN@10 |
| 1 | 1 | 1 | 7µs | 80µs | JSON::Schema::Modern::Annotation::BEGIN@12 |
| 1 | 1 | 1 | 7µs | 387µs | JSON::Schema::Modern::Annotation::BEGIN@19 |
| 1 | 1 | 1 | 7µs | 200µs | JSON::Schema::Modern::Annotation::BEGIN@20 |
| 1 | 1 | 1 | 6µs | 300µs | JSON::Schema::Modern::Annotation::BEGIN@18 |
| 1 | 1 | 1 | 5µs | 86µs | JSON::Schema::Modern::Annotation::BEGIN@17 |
| 1 | 1 | 1 | 4µs | 28µs | JSON::Schema::Modern::Result::BEGIN@2 |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Annotation::TO_JSON |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Annotation::__ANON__[:35] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Annotation::__ANON__[:62] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Annotation::dump |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 22µs | 2 | 25µs | # spent 22µs (19+3) within JSON::Schema::Modern::Result::BEGIN@1 which was called:
# once (19µs+3µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 1 # spent 22µs making 1 call to JSON::Schema::Modern::Result::BEGIN@1
# spent 3µs making 1 call to strict::import |
| 2 | 2 | 35µs | 2 | 52µs | # spent 28µs (4+24) within JSON::Schema::Modern::Result::BEGIN@2 which was called:
# once (4µs+24µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 2 # spent 28µs making 1 call to JSON::Schema::Modern::Result::BEGIN@2
# spent 24µs making 1 call to warnings::import |
| 3 | package JSON::Schema::Modern::Annotation; | ||||
| 4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||
| 5 | # ABSTRACT: Contains a single annotation from a JSON Schema evaluation | ||||
| 6 | |||||
| 7 | 1 | 0s | our $VERSION = '0.558'; | ||
| 8 | |||||
| 9 | 2 | 31µs | 1 | 10µs | # spent 10µs within JSON::Schema::Modern::Annotation::BEGIN@9 which was called:
# once (10µs+0s) by JSON::Schema::Modern::Result::BEGIN@20 at line 9 # spent 10µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@9 |
| 10 | 2 | 24µs | 2 | 419µs | # spent 213µs (7+206) within JSON::Schema::Modern::Annotation::BEGIN@10 which was called:
# once (7µs+206µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 10 # spent 213µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@10
# spent 206µs making 1 call to Moo::import |
| 11 | 3 | 26µs | 3 | 1.26ms | # spent 637µs (13+624) within JSON::Schema::Modern::Annotation::BEGIN@11 which was called:
# once (13µs+624µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 11 # spent 637µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@11
# spent 609µs making 1 call to strictures::import
# spent 15µs making 1 call to strictures::VERSION |
| 12 | 2 | 31µs | 2 | 153µs | # spent 80µs (7+73) within JSON::Schema::Modern::Annotation::BEGIN@12 which was called:
# once (7µs+73µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 12 # spent 80µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@12
# spent 73µs making 1 call to experimental::import |
| 13 | 2 | 26µs | 2 | 34µs | # spent 32µs (11+21) within JSON::Schema::Modern::Annotation::BEGIN@13 which was called:
# once (11µs+21µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 13 # spent 32µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@13
# spent 2µs making 1 call to if::import |
| 14 | 2 | 18µs | 2 | 23µs | # spent 21µs (8+13) within JSON::Schema::Modern::Annotation::BEGIN@14 which was called:
# once (8µs+13µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 14 # spent 21µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@14
# spent 2µs making 1 call to if::unimport |
| 15 | 2 | 16µs | 2 | 14µs | # spent 14µs (8+6) within JSON::Schema::Modern::Annotation::BEGIN@15 which was called:
# once (8µs+6µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 15 # spent 14µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@15
# spent 0s making 1 call to if::unimport |
| 16 | 2 | 12µs | 2 | 12µs | # spent 12µs (9+3) within JSON::Schema::Modern::Annotation::BEGIN@16 which was called:
# once (9µs+3µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 16 # spent 12µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@16
# spent 0s making 1 call to if::unimport |
| 17 | 2 | 16µs | 2 | 167µs | # spent 86µs (5+81) within JSON::Schema::Modern::Annotation::BEGIN@17 which was called:
# once (5µs+81µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 17 # spent 86µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@17
# spent 81µs making 1 call to Exporter::import |
| 18 | 2 | 21µs | 2 | 594µs | # spent 300µs (6+294) within JSON::Schema::Modern::Annotation::BEGIN@18 which was called:
# once (6µs+294µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 18 # spent 300µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@18
# spent 294µs making 1 call to MooX::TypeTiny::import |
| 19 | 2 | 23µs | 2 | 767µs | # spent 387µs (7+380) within JSON::Schema::Modern::Annotation::BEGIN@19 which was called:
# once (7µs+380µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 19 # spent 387µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@19
# spent 380µs making 1 call to Exporter::Tiny::import |
| 20 | 2 | 621µs | 2 | 393µs | # spent 200µs (7+193) within JSON::Schema::Modern::Annotation::BEGIN@20 which was called:
# once (7µs+193µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 20 # spent 200µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@20
# spent 193µs making 1 call to namespace::clean::import |
| 21 | |||||
| 22 | 1 | 4µs | 2 | 1.74ms | has [qw( # spent 1.74ms making 1 call to JSON::Schema::Modern::Annotation::has
# spent 3µs making 1 call to Types::Standard::Str |
| 23 | keyword | ||||
| 24 | instance_location | ||||
| 25 | keyword_location | ||||
| 26 | )] => ( | ||||
| 27 | is => 'ro', | ||||
| 28 | isa => Str, | ||||
| 29 | required => 1, | ||||
| 30 | ); | ||||
| 31 | |||||
| 32 | has absolute_keyword_location => ( | ||||
| 33 | is => 'ro', | ||||
| 34 | isa => InstanceOf['Mojo::URL'], | ||||
| 35 | coerce => sub { $_[0]->$_isa('Mojo::URL') ? $_[0] : Mojo::URL->new($_[0]) }, | ||||
| 36 | 1 | 5µs | 2 | 357µs | ); # spent 286µs making 1 call to JSON::Schema::Modern::Annotation::has
# spent 71µs making 1 call to Types::Standard::InstanceOf |
| 37 | |||||
| 38 | # https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.7.7.1 | ||||
| 39 | 1 | 2µs | 1 | 506µs | has annotation => ( # spent 506µs making 1 call to JSON::Schema::Modern::Annotation::has |
| 40 | is => 'ro', | ||||
| 41 | required => 1, | ||||
| 42 | ); | ||||
| 43 | |||||
| 44 | 1 | 3µs | 2 | 758µs | has unknown => ( # spent 756µs making 1 call to JSON::Schema::Modern::Annotation::has
# spent 2µs making 1 call to Types::Standard::Bool |
| 45 | is => 'ro', | ||||
| 46 | isa => Bool, | ||||
| 47 | default => 0, | ||||
| 48 | ); | ||||
| 49 | |||||
| 50 | around BUILDARGS => sub ($orig, $class, @args) { | ||||
| 51 | my $args = $class->$orig(@args); | ||||
| 52 | |||||
| 53 | if (my $uri = delete $args->{_uri}) { | ||||
| 54 | # as if we did canonical_uri(..)->to_abs($state->{effective_base_uri} in A(..) | ||||
| 55 | $uri = $uri->[0]->to_abs($uri->[1]); | ||||
| 56 | undef $uri if $uri eq '' and $args->{keyword_location} eq '' | ||||
| 57 | or ($uri->fragment // '') eq $args->{keyword_location} and $uri->clone->fragment(undef) eq ''; | ||||
| 58 | $args->{absolute_keyword_location} = $uri if defined $uri; | ||||
| 59 | } | ||||
| 60 | |||||
| 61 | return $args; | ||||
| 62 | 1 | 4µs | 1 | 263µs | }; # spent 263µs making 1 call to Moo::around |
| 63 | |||||
| 64 | sub TO_JSON ($self) { | ||||
| 65 | return +{ | ||||
| 66 | # note that locations are JSON pointers, not uri fragments! | ||||
| 67 | instanceLocation => $self->instance_location, | ||||
| 68 | keywordLocation => $self->keyword_location, | ||||
| 69 | !defined($self->absolute_keyword_location) ? () | ||||
| 70 | : ( absoluteKeywordLocation => $self->absolute_keyword_location->to_string ), | ||||
| 71 | annotation => $self->annotation, | ||||
| 72 | }; | ||||
| 73 | } | ||||
| 74 | |||||
| 75 | sub dump ($self) { | ||||
| 76 | my $encoder = JSON::MaybeXS->new(utf8 => 0, convert_blessed => 1, canonical => 1, pretty => 1); | ||||
| 77 | $encoder->indent_length(2) if $encoder->can('indent_length'); | ||||
| 78 | $encoder->encode($self); | ||||
| 79 | } | ||||
| 80 | |||||
| 81 | 1 | 16µs | 1; | ||
| 82 | |||||
| 83 | 1 | 26µs | 1 | 405µs | __END__ # spent 405µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |