Profile of lib/PONAPI/Builder.pm

← 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
Statements | Executed 4344113 statements in 14.7s

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
799668 | 3 | 3 | 12.1s | 25.9s | PONAPI::Builder::::find_rootPONAPI::Builder::find_root
1945102 | 1 | 1 | 9.60s | 12.2s | PONAPI::Builder::::is_rootPONAPI::Builder::is_root
1 | 1 | 1 | 931µs | 5.65ms | PONAPI::Builder::::BEGIN@4PONAPI::Builder::BEGIN@4
1 | 1 | 1 | 8µs | 76µs | PONAPI::Builder::::BEGIN@55PONAPI::Builder::BEGIN@55
0 | 0 | 0 | 0s | 0s | PONAPI::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
2 |  |  |  |  | package PONAPI::Builder;
3 |  |  |  |  |
4 | 2 | 241µs | 2 | 8.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 |  |  |  |  |
6 | 1 | 1µs | 1 | 115µs | requires 'build'; # spent 115µs making 1 call to Moose::Role::requires
7 |  |  |  |  |
8 | 1 | 1µs | 1 | 154µs | has 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 |  |  |  |  |
15 | 1945102 | 8.05s | 1945102 | 2.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 {
18 | 799668 | 161ms |  |  | my $current = $_[0];
19 | 799668 | 3.79s | 3090536 | 13.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
20 | 799668 | 2.71s |  |  | return $current;
21 |  |  |  |  | }
22 |  |  |  |  |
23 |  |  |  |  | sub 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 |  |  |  |  |
55 | 3 | 45µs | 2 | 144µ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__