← Index
NYTProf Performance Profile   « block view • line view • sub view »
For ddd2.pl
  Run on Tue May 25 16:52:24 2010
Reported on Tue May 25 16:56:53 2010

File /project/perl/lib/Class/DBI/Relationship/HasA.pm
Statements Executed 1019
Statement Execution Time 17.5ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4621115.4ms59.6msClass::DBI::Relationship::HasA::::__ANON__[:77]Class::DBI::Relationship::HasA::__ANON__[:77]
311637µs112msClass::DBI::Relationship::HasA::::triggersClass::DBI::Relationship::HasA::triggers
311466µs3.10msClass::DBI::Relationship::HasA::::_set_up_class_dataClass::DBI::Relationship::HasA::_set_up_class_data
611355µs427µsClass::DBI::Relationship::HasA::::_inflatorClass::DBI::Relationship::HasA::_inflator
311269µs904µsClass::DBI::Relationship::HasA::::remap_argumentsClass::DBI::Relationship::HasA::remap_arguments
611249µs326µsClass::DBI::Relationship::HasA::::_deflatorClass::DBI::Relationship::HasA::_deflator
11145µs2.50msClass::DBI::Relationship::HasA::::__ANON__[:50]Class::DBI::Relationship::HasA::__ANON__[:50]
0000s0sClass::DBI::Relationship::HasA::::BEGINClass::DBI::Relationship::HasA::BEGIN
0000s0sClass::DBI::Relationship::HasA::::__ANON__[:88]Class::DBI::Relationship::HasA::__ANON__[:88]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Class::DBI::Relationship::HasA;
2
3390µs125µsuse strict;
# spent 25µs making 1 call to strict::import
4388µs1113µsuse warnings;
# spent 113µs making 1 call to warnings::import
5
631.23ms10suse 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
sub remap_arguments {
915190µs my ($proto, $class, $want_col, $a_class, %meths) = @_;
10 $class->_invalid_object_method("has_a") if ref $class;
11117µs3519µ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
sub triggers {
1812461µ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 (
22143µs12753µ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
sub _inflator {
3218361µ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
return sub {
3593014.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
my $get_new_value = sub {
44341µ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 ...
53290µs if (exists $meths{'inflate'}) {
54 $value = $get_new_value->($meths{'inflate'}, $value, $a_class, $self);
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
sub _deflator {
8118240µ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
sub _set_up_class_data {
929439µ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
98112µs1;