← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:11 2016

Filename/home/mickey/git_tree/PONAPI/Server/lib/PONAPI/Builder/Relationship.pm
StatementsExecuted 7280439 statements in 21.7s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
5428561117.8s50.7sPONAPI::Builder::Relationship::::buildPONAPI::Builder::Relationship::build
3457662111.3s138sPONAPI::Builder::Relationship::::_add_relationship_linkPONAPI::Builder::Relationship::_add_relationship_link
303470113.07s4.30sPONAPI::Builder::Relationship::::has_resourcesPONAPI::Builder::Relationship::has_resources
172883112.74s28.4sPONAPI::Builder::Relationship::::add_resourcePONAPI::Builder::Relationship::add_resource
172883111.08s86.0sPONAPI::Builder::Relationship::::add_self_linkPONAPI::Builder::Relationship::add_self_link
172883111.01s53.9sPONAPI::Builder::Relationship::::add_related_linkPONAPI::Builder::Relationship::add_related_link
15877611330ms330msPONAPI::Builder::Relationship::::__ANON__[lib/PONAPI/Builder/Relationship.pm:24]PONAPI::Builder::Relationship::__ANON__[lib/PONAPI/Builder/Relationship.pm:24]
111282µs104msPONAPI::Builder::Relationship::::BEGIN@6PONAPI::Builder::Relationship::BEGIN@6
11117µs4.11msPONAPI::Builder::Relationship::::BEGIN@4PONAPI::Builder::Relationship::BEGIN@4
1119µs85µsPONAPI::Builder::Relationship::::BEGIN@96PONAPI::Builder::Relationship::BEGIN@96
0000s0sPONAPI::Builder::Relationship::::has_resourcePONAPI::Builder::Relationship::has_resource
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# ABSTRACT: document builder - relationship
2package PONAPI::Builder::Relationship;
3
4256µs28.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
use Moose;
# spent 4.11ms making 1 call to PONAPI::Builder::Relationship::BEGIN@4 # spent 4.09ms making 1 call to Moose::import
5
62495µs1104ms
# 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
use PONAPI::Builder::Resource::Identifier;
# spent 104ms making 1 call to PONAPI::Builder::Relationship::BEGIN@6
7
814µs1141mswith 'PONAPI::Builder',
# spent 141ms making 1 call to Moose::with
9 'PONAPI::Builder::Role::HasLinksBuilder',
10 'PONAPI::Builder::Role::HasMeta';
11
1212µs11.41mshas name => (
# spent 1.41ms making 1 call to Moose::has
13 is => 'ro',
14 isa => 'Str',
15 required => 1,
16);
17
18has _resource_id_builders => (
19 init_arg => undef,
20 traits => [ 'Array' ],
21 is => 'ro',
22 isa => 'ArrayRef[ PONAPI::Builder::Resource::Identifier ]',
23 lazy => 1,
24158776989ms
# 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
default => sub { +[] },
25110µs1107ms 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
3414µs12.49mshas collection => (
# spent 2.49ms making 1 call to Moose::has
35 is => 'ro',
36 isa => 'Bool',
37);
38
39sub 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
sub has_resources {
4530347083.2ms my $self = $_[0];
463034702.04s6069401.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
sub add_resource {
5017288379.4ms my ( $self, $resource ) = @_;
51172883878ms17288319.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
5217288391.8ms $b->add_meta( %{ $resource->{meta} } ) if $resource->{meta};
531728831.09s1728835.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
561728831.15s17288384.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
sub add_self_link { $_[0]->_add_relationship_link('self') }
# spent 84.9s making 172883 calls to PONAPI::Builder::Relationship::_add_relationship_link, avg 491µs/call
57172883981ms17288352.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
sub add_related_link { $_[0]->_add_relationship_link('related') }
# 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
sub _add_relationship_link {
60345766138ms my ( $self, $key ) = @_;
61345766912ms69153282.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
633457662.76s172883044.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
713457662.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
sub build {
75542856109ms my $self = $_[0];
76542856178ms my $result = {};
77
785428561.36s8463265.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 ...
815337431.20s5337436.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
863034701.13s6069409.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
895428561.68s131101610.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
90542856712ms5428561.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
925428561.93s return $result;
93}
94
9514µs28.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
96371µs2160µ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
no Moose; 1;
# spent 85µs making 1 call to PONAPI::Builder::Relationship::BEGIN@96 # spent 75µs making 1 call to Moose::unimport
97
98__END__