| Filename | /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Annotation.pm |
| Statements | Executed 36 statements in 658µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 50µs | 52µs | JSON::Schema::Modern::Result::BEGIN@1 |
| 1 | 1 | 1 | 15µs | 830µs | JSON::Schema::Modern::Annotation::BEGIN@11 |
| 1 | 1 | 1 | 14µs | 29µs | JSON::Schema::Modern::Annotation::BEGIN@14 |
| 1 | 1 | 1 | 11µs | 34µs | JSON::Schema::Modern::Annotation::BEGIN@13 |
| 1 | 1 | 1 | 8µs | 17µs | JSON::Schema::Modern::Annotation::BEGIN@16 |
| 1 | 1 | 1 | 7µs | 174µs | JSON::Schema::Modern::Annotation::BEGIN@20 |
| 1 | 1 | 1 | 7µs | 7µs | JSON::Schema::Modern::Annotation::BEGIN@9 |
| 1 | 1 | 1 | 6µs | 82µs | JSON::Schema::Modern::Annotation::BEGIN@12 |
| 1 | 1 | 1 | 5µs | 169µs | JSON::Schema::Modern::Annotation::BEGIN@10 |
| 1 | 1 | 1 | 5µs | 17µs | JSON::Schema::Modern::Annotation::BEGIN@15 |
| 1 | 1 | 1 | 5µs | 102µs | JSON::Schema::Modern::Annotation::BEGIN@17 |
| 1 | 1 | 1 | 5µs | 23µs | JSON::Schema::Modern::Result::BEGIN@2 |
| 1 | 1 | 1 | 4µs | 404µs | JSON::Schema::Modern::Annotation::BEGIN@18 |
| 1 | 1 | 1 | 4µs | 328µs | JSON::Schema::Modern::Annotation::BEGIN@19 |
| 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 | 27µs | 2 | 54µs | # spent 52µs (50+2) within JSON::Schema::Modern::Result::BEGIN@1 which was called:
# once (50µs+2µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 1 # spent 52µs making 1 call to JSON::Schema::Modern::Result::BEGIN@1
# spent 2µs making 1 call to strict::import |
| 2 | 2 | 31µs | 2 | 41µs | # spent 23µs (5+18) within JSON::Schema::Modern::Result::BEGIN@2 which was called:
# once (5µs+18µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 2 # spent 23µs making 1 call to JSON::Schema::Modern::Result::BEGIN@2
# spent 18µ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.559'; | ||
| 8 | |||||
| 9 | 2 | 22µs | 1 | 7µs | # spent 7µs within JSON::Schema::Modern::Annotation::BEGIN@9 which was called:
# once (7µs+0s) by JSON::Schema::Modern::Result::BEGIN@20 at line 9 # spent 7µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@9 |
| 10 | 2 | 19µs | 2 | 333µs | # spent 169µs (5+164) within JSON::Schema::Modern::Annotation::BEGIN@10 which was called:
# once (5µs+164µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 10 # spent 169µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@10
# spent 164µs making 1 call to Moo::import |
| 11 | 3 | 36µs | 3 | 1.65ms | # spent 830µs (15+815) within JSON::Schema::Modern::Annotation::BEGIN@11 which was called:
# once (15µs+815µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 11 # spent 830µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@11
# spent 803µs making 1 call to strictures::import
# spent 12µs making 1 call to strictures::VERSION |
| 12 | 2 | 62µs | 2 | 158µs | # spent 82µs (6+76) within JSON::Schema::Modern::Annotation::BEGIN@12 which was called:
# once (6µs+76µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 12 # spent 82µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@12
# spent 76µs making 1 call to experimental::import |
| 13 | 2 | 21µs | 2 | 37µs | # spent 34µs (11+23) within JSON::Schema::Modern::Annotation::BEGIN@13 which was called:
# once (11µs+23µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 13 # spent 34µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@13
# spent 3µs making 1 call to if::import |
| 14 | 2 | 20µs | 2 | 31µs | # spent 29µs (14+15) within JSON::Schema::Modern::Annotation::BEGIN@14 which was called:
# once (14µs+15µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 14 # spent 29µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@14
# spent 2µs making 1 call to if::unimport |
| 15 | 2 | 17µs | 2 | 19µs | # spent 17µs (5+12) within JSON::Schema::Modern::Annotation::BEGIN@15 which was called:
# once (5µs+12µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 15 # spent 17µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@15
# spent 2µs making 1 call to if::unimport |
| 16 | 2 | 13µs | 2 | 17µs | # spent 17µs (8+9) within JSON::Schema::Modern::Annotation::BEGIN@16 which was called:
# once (8µs+9µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 16 # spent 17µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@16
# spent 0s making 1 call to if::unimport |
| 17 | 2 | 16µs | 2 | 199µs | # spent 102µs (5+97) within JSON::Schema::Modern::Annotation::BEGIN@17 which was called:
# once (5µs+97µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 17 # spent 102µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@17
# spent 97µs making 1 call to Exporter::import |
| 18 | 2 | 19µs | 2 | 804µs | # spent 404µs (4+400) within JSON::Schema::Modern::Annotation::BEGIN@18 which was called:
# once (4µs+400µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 18 # spent 404µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@18
# spent 400µs making 1 call to MooX::TypeTiny::import |
| 19 | 2 | 18µs | 2 | 652µs | # spent 328µs (4+324) within JSON::Schema::Modern::Annotation::BEGIN@19 which was called:
# once (4µs+324µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 19 # spent 328µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@19
# spent 324µs making 1 call to Exporter::Tiny::import |
| 20 | 2 | 300µs | 2 | 341µs | # spent 174µs (7+167) within JSON::Schema::Modern::Annotation::BEGIN@20 which was called:
# once (7µs+167µs) by JSON::Schema::Modern::Result::BEGIN@20 at line 20 # spent 174µs making 1 call to JSON::Schema::Modern::Annotation::BEGIN@20
# spent 167µs making 1 call to namespace::clean::import |
| 21 | |||||
| 22 | 1 | 1µs | 2 | 1.28ms | has [qw( # spent 1.28ms making 1 call to JSON::Schema::Modern::Annotation::has
# spent 1µ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 | 3µs | 2 | 468µs | ); # spent 370µs making 1 call to JSON::Schema::Modern::Annotation::has
# spent 98µ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 | 1µs | 1 | 307µs | has annotation => ( # spent 307µs making 1 call to JSON::Schema::Modern::Annotation::has |
| 40 | is => 'ro', | ||||
| 41 | required => 1, | ||||
| 42 | ); | ||||
| 43 | |||||
| 44 | 1 | 1µs | 2 | 692µs | has unknown => ( # spent 691µs making 1 call to JSON::Schema::Modern::Annotation::has
# spent 1µ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 | 2µs | 1 | 180µs | }; # spent 180µ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 | 12µs | 1; | ||
| 82 | 1 | 17µs | 1 | 216µs | __END__ # spent 216µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |