Filename | /home/mickey/git_tree/PONAPI/Server/lib/PONAPI/Builder/Relationship.pm |
Statements | Executed 7280439 statements in 21.7s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
542856 | 1 | 1 | 17.8s | 50.7s | build | PONAPI::Builder::Relationship::
345766 | 2 | 1 | 11.3s | 138s | _add_relationship_link | PONAPI::Builder::Relationship::
303470 | 1 | 1 | 3.07s | 4.30s | has_resources | PONAPI::Builder::Relationship::
172883 | 1 | 1 | 2.74s | 28.4s | add_resource | PONAPI::Builder::Relationship::
172883 | 1 | 1 | 1.08s | 86.0s | add_self_link | PONAPI::Builder::Relationship::
172883 | 1 | 1 | 1.01s | 53.9s | add_related_link | PONAPI::Builder::Relationship::
158776 | 1 | 1 | 330ms | 330ms | __ANON__[lib/PONAPI/Builder/Relationship.pm:24] | PONAPI::Builder::Relationship::
1 | 1 | 1 | 282µs | 104ms | BEGIN@6 | PONAPI::Builder::Relationship::
1 | 1 | 1 | 17µs | 4.11ms | BEGIN@4 | PONAPI::Builder::Relationship::
1 | 1 | 1 | 9µs | 85µs | BEGIN@96 | PONAPI::Builder::Relationship::
0 | 0 | 0 | 0s | 0s | has_resource | PONAPI::Builder::Relationship::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # ABSTRACT: document builder - relationship | ||||
2 | package PONAPI::Builder::Relationship; | ||||
3 | |||||
4 | 2 | 56µs | 2 | 8.20ms | # spent 4.11ms (17µs+4.09) within PONAPI::Builder::Relationship::BEGIN@4 which was called:
# once (17µs+4.09ms) by PONAPI::Builder::Resource::BEGIN@6 at line 4 # spent 4.11ms making 1 call to PONAPI::Builder::Relationship::BEGIN@4
# spent 4.09ms making 1 call to Moose::import |
5 | |||||
6 | 2 | 495µs | 1 | 104ms | # spent 104ms (282µs+104) within PONAPI::Builder::Relationship::BEGIN@6 which was called:
# once (282µs+104ms) by PONAPI::Builder::Resource::BEGIN@6 at line 6 # spent 104ms making 1 call to PONAPI::Builder::Relationship::BEGIN@6 |
7 | |||||
8 | 1 | 4µs | 1 | 141ms | with 'PONAPI::Builder', # spent 141ms making 1 call to Moose::with |
9 | 'PONAPI::Builder::Role::HasLinksBuilder', | ||||
10 | 'PONAPI::Builder::Role::HasMeta'; | ||||
11 | |||||
12 | 1 | 2µs | 1 | 1.41ms | has name => ( # spent 1.41ms making 1 call to Moose::has |
13 | is => 'ro', | ||||
14 | isa => 'Str', | ||||
15 | required => 1, | ||||
16 | ); | ||||
17 | |||||
18 | has _resource_id_builders => ( | ||||
19 | init_arg => undef, | ||||
20 | traits => [ 'Array' ], | ||||
21 | is => 'ro', | ||||
22 | isa => 'ArrayRef[ PONAPI::Builder::Resource::Identifier ]', | ||||
23 | lazy => 1, | ||||
24 | 158776 | 989ms | # spent 330ms within PONAPI::Builder::Relationship::__ANON__[lib/PONAPI/Builder/Relationship.pm:24] which was called 158776 times, avg 2µs/call:
# 158776 times (330ms+0s) by PONAPI::Builder::Relationship::_add_resource_id_builder at line 13 of (eval 45)[Eval/Closure.pm:144], avg 2µs/call | ||
25 | 1 | 10µs | 1 | 107ms | predicate => '_has_resource_id_builders', # spent 107ms making 1 call to Moose::has |
26 | handles => { | ||||
27 | '_num_resource_id_builders' => 'count', | ||||
28 | # private ... | ||||
29 | '_add_resource_id_builder' => 'push', | ||||
30 | '_get_resource_id_builder' => 'get', | ||||
31 | } | ||||
32 | ); | ||||
33 | |||||
34 | 1 | 4µs | 1 | 2.49ms | has collection => ( # spent 2.49ms making 1 call to Moose::has |
35 | is => 'ro', | ||||
36 | isa => 'Bool', | ||||
37 | ); | ||||
38 | |||||
39 | sub has_resource { | ||||
40 | my $self = $_[0]; | ||||
41 | $self->_has_resource_id_builders && $self->_num_resource_id_builders > 0; | ||||
42 | } | ||||
43 | |||||
44 | # spent 4.30s (3.07+1.23) within PONAPI::Builder::Relationship::has_resources which was called 303470 times, avg 14µs/call:
# 303470 times (3.07s+1.23s) by PONAPI::Builder::Relationship::build at line 78, avg 14µs/call | ||||
45 | 303470 | 83.2ms | my $self = $_[0]; | ||
46 | 303470 | 2.04s | 606940 | 1.23s | $self->_has_resource_id_builders && $self->_num_resource_id_builders > 1; # spent 739ms making 303470 calls to PONAPI::Builder::Relationship::_num_resource_id_builders, avg 2µs/call
# spent 489ms making 303470 calls to PONAPI::Builder::Relationship::_has_resource_id_builders, avg 2µs/call |
47 | } | ||||
48 | |||||
49 | # spent 28.4s (2.74+25.6) within PONAPI::Builder::Relationship::add_resource which was called 172883 times, avg 164µs/call:
# 172883 times (2.74s+25.6s) by PONAPI::Builder::Resource::add_relationship at line 87 of lib/PONAPI/Builder/Resource.pm, avg 164µs/call | ||||
50 | 172883 | 79.4ms | my ( $self, $resource ) = @_; | ||
51 | 172883 | 878ms | 172883 | 19.8s | my $b = PONAPI::Builder::Resource::Identifier->new( parent => $self, %$resource ); # spent 19.8s making 172883 calls to PONAPI::Builder::Resource::Identifier::new, avg 114µs/call |
52 | 172883 | 91.8ms | $b->add_meta( %{ $resource->{meta} } ) if $resource->{meta}; | ||
53 | 172883 | 1.09s | 172883 | 5.86s | $self->_add_resource_id_builder( $b ); # spent 5.86s making 172883 calls to PONAPI::Builder::Relationship::_add_resource_id_builder, avg 34µs/call |
54 | } | ||||
55 | |||||
56 | 172883 | 1.15s | 172883 | 84.9s | # spent 86.0s (1.08+84.9) within PONAPI::Builder::Relationship::add_self_link which was called 172883 times, avg 498µs/call:
# 172883 times (1.08s+84.9s) by Test::PONAPI::Repository::MockDB::_add_resource_relationships at line 653 of lib/Test/PONAPI/Repository/MockDB.pm, avg 498µs/call # spent 84.9s making 172883 calls to PONAPI::Builder::Relationship::_add_relationship_link, avg 491µs/call |
57 | 172883 | 981ms | 172883 | 52.9s | # spent 53.9s (1.01+52.9) within PONAPI::Builder::Relationship::add_related_link which was called 172883 times, avg 312µs/call:
# 172883 times (1.01s+52.9s) by Test::PONAPI::Repository::MockDB::_add_resource_relationships at line 653 of lib/Test/PONAPI/Repository/MockDB.pm, avg 312µs/call # spent 52.9s making 172883 calls to PONAPI::Builder::Relationship::_add_relationship_link, avg 306µs/call |
58 | |||||
59 | # spent 138s (11.3+127) within PONAPI::Builder::Relationship::_add_relationship_link which was called 345766 times, avg 399µs/call:
# 172883 times (6.20s+78.7s) by PONAPI::Builder::Relationship::add_self_link at line 56, avg 491µs/call
# 172883 times (5.10s+47.8s) by PONAPI::Builder::Relationship::add_related_link at line 57, avg 306µs/call | ||||
60 | 345766 | 138ms | my ( $self, $key ) = @_; | ||
61 | 345766 | 912ms | 691532 | 82.2s | my $rec = $self->parent->build; # spent 81.7s making 345766 calls to PONAPI::Builder::Resource::build, avg 236µs/call
# spent 529ms making 345766 calls to PONAPI::Builder::Relationship::parent, avg 2µs/call |
62 | |||||
63 | 345766 | 2.76s | 1728830 | 44.3s | $self->links_builder->add_link( # spent 23.0s making 345766 calls to PONAPI::Builder::Relationship::links_builder, avg 67µs/call
# spent 13.5s making 345766 calls to PONAPI::Builder::find_root, avg 39µs/call
# spent 6.58s making 345766 calls to PONAPI::Builder::Links::add_link, avg 19µs/call
# spent 588ms making 345766 calls to PONAPI::Builder::Document::req_base, avg 2µs/call
# spent 587ms making 345766 calls to PONAPI::Builder::Relationship::name, avg 2µs/call |
64 | $key => $self->find_root->req_base | ||||
65 | . $rec->{type} | ||||
66 | . '/' . $rec->{id} | ||||
67 | . ( $key eq 'self' ? '/relationships' : '' ) | ||||
68 | . '/' . $self->name | ||||
69 | ); | ||||
70 | |||||
71 | 345766 | 2.20s | return $self; | ||
72 | } | ||||
73 | |||||
74 | # spent 50.7s (17.8+32.8) within PONAPI::Builder::Relationship::build which was called 542856 times, avg 93µs/call:
# 542856 times (17.8s+32.8s) by PONAPI::Builder::Resource::build at line 123 of lib/PONAPI/Builder/Resource.pm, avg 93µs/call | ||||
75 | 542856 | 109ms | my $self = $_[0]; | ||
76 | 542856 | 178ms | my $result = {}; | ||
77 | |||||
78 | 542856 | 1.36s | 846326 | 5.24s | if ( $self->collection || $self->has_resources ) { # spent 4.30s making 303470 calls to PONAPI::Builder::Relationship::has_resources, avg 14µs/call
# spent 941ms making 542856 calls to PONAPI::Builder::Relationship::collection, avg 2µs/call |
79 | # if it is a collection, then | ||||
80 | # call build on each one ... | ||||
81 | 533743 | 1.20s | 533743 | 6.39s | $result->{data} = [ map { $_->build } @{ $self->_resource_id_builders } ]; # spent 5.81s making 294357 calls to PONAPI::Builder::Resource::Identifier::build, avg 20µs/call
# spent 584ms making 239386 calls to PONAPI::Builder::Relationship::_resource_id_builders, avg 2µs/call |
82 | } | ||||
83 | else { | ||||
84 | # if it is a single resource, | ||||
85 | # just use that one | ||||
86 | 303470 | 1.13s | 606940 | 9.75s | $result->{data} = $self->_get_resource_id_builder(0)->build; # spent 6.72s making 303470 calls to PONAPI::Builder::Resource::Identifier::build, avg 22µs/call
# spent 3.03s making 303470 calls to PONAPI::Builder::Relationship::_get_resource_id_builder, avg 10µs/call |
87 | } | ||||
88 | |||||
89 | 542856 | 1.68s | 1311016 | 10.4s | $result->{links} = $self->links_builder->build if $self->has_links_builder; # spent 8.85s making 384080 calls to PONAPI::Builder::Links::build, avg 23µs/call
# spent 879ms making 542856 calls to PONAPI::Builder::Relationship::has_links_builder, avg 2µs/call
# spent 648ms making 384080 calls to PONAPI::Builder::Relationship::links_builder, avg 2µs/call |
90 | 542856 | 712ms | 542856 | 1.09s | $result->{meta} = $self->_meta if $self->has_meta; # spent 1.09s making 542856 calls to PONAPI::Builder::Relationship::has_meta, avg 2µs/call |
91 | |||||
92 | 542856 | 1.93s | return $result; | ||
93 | } | ||||
94 | |||||
95 | 1 | 4µs | 2 | 8.76ms | __PACKAGE__->meta->make_immutable; # spent 8.75ms making 1 call to Class::MOP::Class::make_immutable
# spent 14µs making 1 call to PONAPI::Builder::Relationship::meta |
96 | 3 | 71µs | 2 | 160µs | # spent 85µs (9+75) within PONAPI::Builder::Relationship::BEGIN@96 which was called:
# once (9µs+75µs) by PONAPI::Builder::Resource::BEGIN@6 at line 96 # spent 85µs making 1 call to PONAPI::Builder::Relationship::BEGIN@96
# spent 75µs making 1 call to Moose::unimport |
97 | |||||
98 | __END__ |