← 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/DAO/Request/Role/HasFields.pm
StatementsExecuted 672758 statements in 1.94s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
100001111.72s3.89sPONAPI::DAO::Request::Role::HasFields::::_validate_fieldsPONAPI::DAO::Request::Role::HasFields::_validate_fields
6913211228ms228msPONAPI::DAO::Request::Role::HasFields::::__ANON__[lib/PONAPI/DAO/Request/Role/HasFields.pm:10]PONAPI::DAO::Request::Role::HasFields::__ANON__[lib/PONAPI/DAO/Request/Role/HasFields.pm:10]
11121µs6.65msPONAPI::DAO::Request::Role::HasFields::::BEGIN@4PONAPI::DAO::Request::Role::HasFields::BEGIN@4
1118µs86µsPONAPI::DAO::Request::Role::HasFields::::BEGIN@64PONAPI::DAO::Request::Role::HasFields::BEGIN@64
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# ABSTRACT: DAO request role - `fields`
2package PONAPI::DAO::Request::Role::HasFields;
3
42257µs213.3ms
# spent 6.65ms (21µs+6.63) within PONAPI::DAO::Request::Role::HasFields::BEGIN@4 which was called: # once (21µs+6.63ms) by Module::Runtime::require_module at line 4
use Moose::Role;
# spent 6.65ms making 1 call to PONAPI::DAO::Request::Role::HasFields::BEGIN@4 # spent 6.63ms making 1 call to Moose::Role::import
5
6has fields => (
7 traits => [ 'Hash' ],
8 is => 'ro',
9 isa => 'HashRef',
1069132573ms
# spent 228ms within PONAPI::DAO::Request::Role::HasFields::__ANON__[lib/PONAPI/DAO/Request/Role/HasFields.pm:10] which was called 69132 times, avg 3µs/call: # 69132 times (228ms+0s) by PONAPI::DAO::Request::Retrieve::new or PONAPI::DAO::Request::RetrieveAll::new at line 37 of (eval 45)[Eval/Closure.pm:144], avg 3µs/call
default => sub { +{} },
11113µs1139µs handles => {
# spent 139µs making 1 call to Moose::Role::has
12 "has_fields" => 'count',
13 },
14);
15
16
# spent 3.89s (1.72+2.17) within PONAPI::DAO::Request::Role::HasFields::_validate_fields which was called 100001 times, avg 39µs/call: # 100001 times (1.72s+2.17s) by PONAPI::DAO::Request::BUILD at line 117 of lib/PONAPI/DAO/Request.pm, avg 39µs/call
sub _validate_fields {
1710000156.7ms my ( $self, $args ) = @_;
18
19100001445ms return unless defined $args->{fields};
203086990.5ms30869134ms return unless $self->has_fields;
# spent 67.4ms making 15437 calls to PONAPI::DAO::Request::RetrieveAll::has_fields, avg 4µs/call # spent 66.7ms making 15432 calls to PONAPI::DAO::Request::Retrieve::has_fields, avg 4µs/call
21
223086984.4ms3086996.9ms my $fields = $self->fields;
# spent 48.4ms making 15437 calls to PONAPI::DAO::Request::RetrieveAll::fields, avg 3µs/call # spent 48.4ms making 15432 calls to PONAPI::DAO::Request::Retrieve::fields, avg 3µs/call
233086946.1ms3086932.0ms my $repo = $self->repository;
# spent 32.0ms making 30869 calls to PONAPI::DAO::Request::repository, avg 1µs/call
24
2530869206ms foreach my $fields_type ( keys %$fields ) {
263086966.8ms30869199ms if ( !$repo->has_type( $fields_type ) ) {
# spent 199ms making 30869 calls to Test::PONAPI::Repository::MockDB::has_type, avg 6µs/call
27 $self->_bad_request( "Type `$fields_type` doesn't exist.", 404 );
28 }
29 else {
303086924.8ms my $fields_array = $fields->{$fields_type};
313086957.8ms my @fields = @$fields_array;
32
3330869103ms30869939ms my $ok = $repo->type_has_fields( $fields_type, \@fields );
# spent 939ms making 30869 calls to Test::PONAPI::Repository::MockDB::type_has_fields, avg 30µs/call
343086930.4ms next if $ok;
35
36 # Sigh... let's test for this:
37 # fields => { articles => [qw/ title authors /] }
38 # where authors is a *relationship*
39 # There can't be clashes, so yes, this is fine. Somehow.
40 # http://jsonapi.org/format/#document-resource-object-fields
41133865.50ms my (@real_fields, @relationships);
421338615.4ms foreach my $maybe_rel ( @fields ) {
434383678.4ms43836531ms if ( $repo->has_relationship($fields_type, $maybe_rel) ) {
# spent 531ms making 43836 calls to Test::PONAPI::Repository::MockDB::has_relationship, avg 12µs/call
44 push @relationships, $maybe_rel;
45 }
46 else {
472841716.9ms push @real_fields, $maybe_rel;
48 }
49 }
50
51 $ok = @real_fields
521338626.4ms13386233ms ? $repo->type_has_fields($fields_type, \@real_fields)
# spent 233ms making 13386 calls to Test::PONAPI::Repository::MockDB::type_has_fields, avg 17µs/call
53 : 1;
54
551338615.6ms if (!$ok) {
56 $self->_bad_request(
57 "Type `$fields_type` does not have at least one of the requested fields"
58 );
59 }
60 }
61 }
62}
63
64340µs2165µs
# spent 86µs (8+78) within PONAPI::DAO::Request::Role::HasFields::BEGIN@64 which was called: # once (8µs+78µs) by Module::Runtime::require_module at line 64
no Moose::Role; 1;
# spent 86µs making 1 call to PONAPI::DAO::Request::Role::HasFields::BEGIN@64 # spent 78µs making 1 call to Moose::Role::unimport
65
66__END__