← 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.pm
StatementsExecuted 4344113 statements in 14.7s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
7996683312.1s25.9sPONAPI::Builder::::find_rootPONAPI::Builder::find_root
1945102119.60s12.2sPONAPI::Builder::::is_rootPONAPI::Builder::is_root
111931µs5.65msPONAPI::Builder::::BEGIN@4PONAPI::Builder::BEGIN@4
1118µs76µsPONAPI::Builder::::BEGIN@55PONAPI::Builder::BEGIN@55
0000s0sPONAPI::Builder::::raise_errorPONAPI::Builder::raise_error
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 role
2package PONAPI::Builder;
3
42241µs28.16ms
# spent 5.65ms (931µs+4.72) within PONAPI::Builder::BEGIN@4 which was called: # once (931µs+4.72ms) by Module::Runtime::require_module at line 4
use Moose::Role;
# spent 5.65ms making 1 call to PONAPI::Builder::BEGIN@4 # spent 2.51ms making 1 call to Moose::Role::import
5
611µs1115µsrequires 'build';
# spent 115µs making 1 call to Moose::Role::requires
7
811µs1154µshas parent => (
# spent 154µs making 1 call to Moose::Role::has
9 is => 'ro',
10 does => 'PONAPI::Builder',
11 predicate => 'has_parent',
12 weak_ref => 1,
13);
14
1519451028.05s19451022.61s
# spent 12.2s (9.60+2.61) within PONAPI::Builder::is_root which was called 1945102 times, avg 6µs/call: # 1945102 times (9.60s+2.61s) by PONAPI::Builder::find_root at line 19, avg 6µs/call
sub is_root { ! $_[0]->has_parent }
# spent 1.08s making 799668 calls to PONAPI::Builder::Resource::has_parent, avg 1µs/call # spent 1.02s making 799668 calls to PONAPI::Builder::Document::has_parent, avg 1µs/call # spent 515ms making 345766 calls to PONAPI::Builder::Relationship::has_parent, avg 1µs/call
16
17
# spent 25.9s (12.1+13.8) within PONAPI::Builder::find_root which was called 799668 times, avg 32µs/call: # 345766 times (6.45s+7.07s) by PONAPI::Builder::Relationship::_add_relationship_link at line 63 of lib/PONAPI/Builder/Relationship.pm, avg 39µs/call # 270247 times (3.44s+4.42s) by PONAPI::Builder::Resource::add_self_link at line 94 of lib/PONAPI/Builder/Resource.pm, avg 29µs/call # 183655 times (2.21s+2.32s) by Test::PONAPI::Repository::MockDB::_add_resource_relationships at line 627 of lib/Test/PONAPI/Repository/MockDB.pm, avg 25µs/call
sub find_root {
18799668161ms my $current = $_[0];
197996683.79s309053613.8s $current = $current->parent until $current->is_root;
# spent 12.2s making 1945102 calls to PONAPI::Builder::is_root, avg 6µs/call # spent 1.22s making 799668 calls to PONAPI::Builder::Resource::parent, avg 2µs/call # spent 374ms making 345766 calls to PONAPI::Builder::Relationship::parent, avg 1µs/call
207996682.71s return $current;
21}
22
23sub raise_error {
24 my $self = shift;
25 my $status = shift;
26
27 # XXX:
28 # we could check the args here and look for
29 # a `level` key which would tell us if we
30 # should throw an exception (immediate, fatal error)
31 # or we should just stash the error and continue.
32 # It might get funky, but it would be nice to
33 # unify some error handling, maybe, perhaps
34 # I am not sure.
35 # - SL
36
37 $self->find_root->errors_builder->add_error( @_, status => $status );
38
39 # set given status, on multiple errors use 500/400
40 my $st = $status;
41 if ( $self->has_errors > 1 ) {
42 if ( $self->status >= 500 or $status >= 500 ) {
43 $st = 500;
44 } elsif ( $self->status >= 400 or $status >= 400 ) {
45 $st = 400;
46 }
47 }
48 $self->set_status($st);
49
50 # we don't return value to allow condition
51 # check when returned from validation methods
52 return;
53}
54
55345µs2144µs
# spent 76µs (8+68) within PONAPI::Builder::BEGIN@55 which was called: # once (8µs+68µs) by Module::Runtime::require_module at line 55
no Moose::Role; 1;
# spent 76µs making 1 call to PONAPI::Builder::BEGIN@55 # spent 68µs making 1 call to Moose::Role::unimport
56
57__END__