| File | /project/perl/lib/Class/DBI/Relationship/HasA.pm |
| Statements Executed | 1019 |
| Statement Execution Time | 17.5ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 462 | 1 | 1 | 15.4ms | 59.6ms | Class::DBI::Relationship::HasA::__ANON__[:77] |
| 3 | 1 | 1 | 637µs | 112ms | Class::DBI::Relationship::HasA::triggers |
| 3 | 1 | 1 | 466µs | 3.10ms | Class::DBI::Relationship::HasA::_set_up_class_data |
| 6 | 1 | 1 | 355µs | 427µs | Class::DBI::Relationship::HasA::_inflator |
| 3 | 1 | 1 | 269µs | 904µs | Class::DBI::Relationship::HasA::remap_arguments |
| 6 | 1 | 1 | 249µs | 326µs | Class::DBI::Relationship::HasA::_deflator |
| 1 | 1 | 1 | 45µs | 2.50ms | Class::DBI::Relationship::HasA::__ANON__[:50] |
| 0 | 0 | 0 | 0s | 0s | Class::DBI::Relationship::HasA::BEGIN |
| 0 | 0 | 0 | 0s | 0s | Class::DBI::Relationship::HasA::__ANON__[:88] |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Class::DBI::Relationship::HasA; | ||||
| 2 | |||||
| 3 | 3 | 90µs | 1 | 25µs | use strict; # spent 25µs making 1 call to strict::import |
| 4 | 3 | 88µs | 1 | 113µs | use warnings; # spent 113µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 3 | 1.23ms | 1 | 0s | use base 'Class::DBI::Relationship'; # spent 258µs making 1 call to base::import, recursion: max depth 3, time 258µs |
| 7 | |||||
| 8 | # spent 904µs (269+635) within Class::DBI::Relationship::HasA::remap_arguments which was called 3 times, avg 301µs/call:
# 3 times (269µs+635µs) by Class::DBI::Relationship::_init at line 22 of Class/DBI/Relationship.pm, avg 301µs/call | ||||
| 9 | 15 | 190µs | my ($proto, $class, $want_col, $a_class, %meths) = @_; | ||
| 10 | $class->_invalid_object_method("has_a") if ref $class; | ||||
| 11 | 1 | 17µs | 3 | 519µs | my $column = $class->find_column($want_col) # spent 519µs making 3 calls to Class::DBI::find_column, avg 173µs/call |
| 12 | or return $class->_croak("Column $want_col does not exist in $class"); | ||||
| 13 | $class->_croak("$class $column needs an associated class") unless $a_class; | ||||
| 14 | return ($class, $column, $a_class, \%meths); | ||||
| 15 | } | ||||
| 16 | |||||
| 17 | # spent 112ms (637µs+112) within Class::DBI::Relationship::HasA::triggers which was called 3 times, avg 37.4ms/call:
# 3 times (637µs+112ms) by Class::DBI::Relationship::_add_triggers at line 51 of Class/DBI/Relationship.pm, avg 37.4ms/call | ||||
| 18 | 12 | 461µs | my $self = shift; | ||
| 19 | $self->class->_require_class($self->foreign_class); # spent 111ms making 3 calls to Class::DBI::_require_class, avg 36.9ms/call, recursion: max depth 1, time 74µs
# spent 78µs making 6 calls to Class::Accessor::Fast::__ANON__[Class/Accessor/Fast.pm:41], avg 13µs/call | ||||
| 20 | my $column = $self->accessor; # spent 48µs making 3 calls to Class::Accessor::Fast::__ANON__[Class/Accessor/Fast.pm:41], avg 16µs/call | ||||
| 21 | return ( | ||||
| 22 | 1 | 43µs | 12 | 753µs | select => $self->_inflator, # spent 427µs making 6 calls to Class::DBI::Relationship::HasA::_inflator, avg 71µs/call
# spent 326µs making 6 calls to Class::DBI::Relationship::HasA::_deflator, avg 54µs/call |
| 23 | |||||
| 24 | # after_create => $self->_inflator, # see t/6 | ||||
| 25 | "after_set_$column" => $self->_inflator, | ||||
| 26 | deflate_for_create => $self->_deflator(1), | ||||
| 27 | deflate_for_update => $self->_deflator, | ||||
| 28 | ); | ||||
| 29 | } | ||||
| 30 | |||||
| 31 | # spent 427µs (355+72) within Class::DBI::Relationship::HasA::_inflator which was called 6 times, avg 71µs/call:
# 6 times (355µs+72µs) by Class::DBI::Relationship::HasA::triggers at line 22, avg 71µs/call | ||||
| 32 | 18 | 361µs | my $rel = shift; | ||
| 33 | my $col = $rel->accessor; # spent 72µs making 6 calls to Class::Accessor::Fast::__ANON__[Class/Accessor/Fast.pm:41], avg 12µs/call | ||||
| 34 | # spent 59.6ms (15.4+44.2) within Class::DBI::Relationship::HasA::__ANON__[/project/perl/lib/Class/DBI/Relationship/HasA.pm:77] which was called 462 times, avg 129µs/call:
# 462 times (15.4ms+44.2ms) by Class::Trigger::call_trigger at line 40 of Class/Trigger.pm, avg 129µs/call | ||||
| 35 | 930 | 14.2ms | my $self = shift; | ||
| 36 | defined(my $value = $self->_attrs($col)) or return; # spent 41.3ms making 462 calls to Class::DBI::_attrs, avg 89µs/call | ||||
| 37 | my $meta = $self->meta_info($rel->name => $col); # spent 213µs making 1 call to Class::DBI::meta_info
# spent 15µs making 1 call to Class::Accessor::Fast::__ANON__[Class/Accessor/Fast.pm:41] | ||||
| 38 | my ($a_class, %meths) = ($meta->foreign_class, %{ $meta->args }); # spent 25µs making 2 calls to Class::Accessor::Fast::__ANON__[Class/Accessor/Fast.pm:41], avg 12µs/call | ||||
| 39 | |||||
| 40 | return if ref $value and $value->isa($a_class); | ||||
| 41 | my $inflator; | ||||
| 42 | |||||
| 43 | # spent 2.50ms (45µs+2.45) within Class::DBI::Relationship::HasA::__ANON__[/project/perl/lib/Class/DBI/Relationship/HasA.pm:50] which was called
# once (45µs+2.45ms) by Class::DBI::Relationship::HasA::__ANON__[/project/perl/lib/Class/DBI/Relationship/HasA.pm:77] at line 54 | ||||
| 44 | 3 | 41µs | my ($inflator, $value, $want_class, $obj) = @_; | ||
| 45 | my $new_value = # spent 2.46ms making 1 call to K2::DB2::__ANON__[K2/DB2.pm:49] | ||||
| 46 | (ref $inflator eq 'CODE') | ||||
| 47 | ? $inflator->($value, $obj) | ||||
| 48 | : $want_class->$inflator($value); | ||||
| 49 | return $new_value; | ||||
| 50 | }; | ||||
| 51 | |||||
| 52 | # If we have a custom inflate ... | ||||
| 53 | 2 | 90µs | if (exists $meths{'inflate'}) { | ||
| 54 | $value = $get_new_value->($meths{'inflate'}, $value, $a_class, $self); # spent 2.50ms making 1 call to Class::DBI::Relationship::HasA::__ANON__[Class/DBI/Relationship/HasA.pm:50] | ||||
| 55 | return $self->_attribute_store($col, $value) # spent 121µs making 1 call to Class::DBI::_attribute_store
# spent 12µs making 1 call to UNIVERSAL::isa | ||||
| 56 | if ref $value | ||||
| 57 | and $value->isa($a_class); | ||||
| 58 | $self->_croak("Inflate method didn't inflate right") if ref $value; | ||||
| 59 | } | ||||
| 60 | |||||
| 61 | return $self->_croak("Can't inflate $col to $a_class using '$value': " | ||||
| 62 | . ref($value) | ||||
| 63 | . " is not a $a_class") | ||||
| 64 | if ref $value; | ||||
| 65 | |||||
| 66 | $inflator = $a_class->isa('Class::DBI') ? "_simple_bless" : "new"; | ||||
| 67 | $value = $get_new_value->($inflator, $value, $a_class); | ||||
| 68 | |||||
| 69 | return $self->_attribute_store($col, $value) | ||||
| 70 | if ref $value | ||||
| 71 | and $value->isa($a_class); | ||||
| 72 | |||||
| 73 | # use ref as $obj may be overloaded and appear 'false' | ||||
| 74 | return $self->_croak( | ||||
| 75 | "Can't inflate $col to $a_class " . "via $inflator using '$value'") | ||||
| 76 | unless ref $value; | ||||
| 77 | }; | ||||
| 78 | } | ||||
| 79 | |||||
| 80 | # spent 326µs (249+77) within Class::DBI::Relationship::HasA::_deflator which was called 6 times, avg 54µs/call:
# 6 times (249µs+77µs) by Class::DBI::Relationship::HasA::triggers at line 22, avg 54µs/call | ||||
| 81 | 18 | 240µs | my ($self, $always) = @_; | ||
| 82 | my $col = $self->accessor; # spent 77µs making 6 calls to Class::Accessor::Fast::__ANON__[Class/Accessor/Fast.pm:41], avg 13µs/call | ||||
| 83 | return sub { | ||||
| 84 | my $self = shift; | ||||
| 85 | return unless $self->_attribute_exists($col); | ||||
| 86 | $self->_attribute_store($col => $self->_deflated_column($col)) | ||||
| 87 | if ($always or $self->{__Changed}->{$col}); | ||||
| 88 | }; | ||||
| 89 | } | ||||
| 90 | |||||
| 91 | # spent 3.10ms (466µs+2.63) within Class::DBI::Relationship::HasA::_set_up_class_data which was called 3 times, avg 1.03ms/call:
# 3 times (466µs+2.63ms) by Class::DBI::Relationship::set_up at line 13 of Class/DBI/Relationship.pm, avg 1.03ms/call | ||||
| 92 | 9 | 439µs | my $self = shift; | ||
| 93 | $self->class->_extend_class_data(__hasa_rels => $self->accessor => | ||||
| 94 | [ $self->foreign_class, %{ $self->args } ]); # spent 846µs making 3 calls to Class::DBI::_extend_class_data, avg 282µs/call
# spent 155µs making 12 calls to Class::Accessor::Fast::__ANON__[Class/Accessor/Fast.pm:41], avg 13µs/call | ||||
| 95 | $self->SUPER::_set_up_class_data; # spent 1.63ms making 3 calls to Class::DBI::Relationship::_set_up_class_data, avg 544µs/call | ||||
| 96 | } | ||||
| 97 | |||||
| 98 | 1 | 12µs | 1; |