← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:47 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Relationship/ManyToMany.pm
StatementsExecuted 1298 statements in 7.64ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
442245µs571µsDBIx::Class::Relationship::ManyToMany::::many_to_manyDBIx::Class::Relationship::ManyToMany::many_to_many
11114µs16µsDBIx::Class::Relationship::ManyToMany::::BEGIN@4DBIx::Class::Relationship::ManyToMany::BEGIN@4
11110µs37µsDBIx::Class::Relationship::ManyToMany::::BEGIN@8DBIx::Class::Relationship::ManyToMany::BEGIN@8
1118µs30µsDBIx::Class::Relationship::ManyToMany::::BEGIN@9DBIx::Class::Relationship::ManyToMany::BEGIN@9
1117µs17µsDBIx::Class::Relationship::ManyToMany::::BEGIN@5DBIx::Class::Relationship::ManyToMany::BEGIN@5
1117µs67µsDBIx::Class::Relationship::ManyToMany::::BEGIN@7DBIx::Class::Relationship::ManyToMany::BEGIN@7
1117µs148µsDBIx::Class::Relationship::ManyToMany::::BEGIN@11DBIx::Class::Relationship::ManyToMany::BEGIN@11
1117µs22µsDBIx::Class::Relationship::ManyToMany::::BEGIN@31DBIx::Class::Relationship::ManyToMany::BEGIN@31
1117µs20µsDBIx::Class::Relationship::ManyToMany::::BEGIN@30DBIx::Class::Relationship::ManyToMany::BEGIN@30
0000s0sDBIx::Class::Relationship::ManyToMany::::__ANON__[:109]DBIx::Class::Relationship::ManyToMany::__ANON__[:109]
0000s0sDBIx::Class::Relationship::ManyToMany::::__ANON__[:127]DBIx::Class::Relationship::ManyToMany::__ANON__[:127]
0000s0sDBIx::Class::Relationship::ManyToMany::::__ANON__[:146]DBIx::Class::Relationship::ManyToMany::__ANON__[:146]
0000s0sDBIx::Class::Relationship::ManyToMany::::__ANON__[:71]DBIx::Class::Relationship::ManyToMany::__ANON__[:71]
0000s0sDBIx::Class::Relationship::ManyToMany::::__ANON__[:78]DBIx::Class::Relationship::ManyToMany::__ANON__[:78]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package # hide from PAUSE
2 DBIx::Class::Relationship::ManyToMany;
3
4319µs218µs
# spent 16µs (14+2) within DBIx::Class::Relationship::ManyToMany::BEGIN@4 which was called: # once (14µs+2µs) by Class::C3::Componentised::ensure_class_loaded at line 4
use strict;
# spent 16µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@4 # spent 2µs making 1 call to strict::import
5319µs227µs
# spent 17µs (7+10) within DBIx::Class::Relationship::ManyToMany::BEGIN@5 which was called: # once (7µs+10µs) by Class::C3::Componentised::ensure_class_loaded at line 5
use warnings;
# spent 17µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@5 # spent 10µs making 1 call to warnings::import
6
7323µs2127µs
# spent 67µs (7+60) within DBIx::Class::Relationship::ManyToMany::BEGIN@7 which was called: # once (7µs+60µs) by Class::C3::Componentised::ensure_class_loaded at line 7
use DBIx::Class::Carp;
# spent 67µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@7 # spent 60µs making 1 call to DBIx::Class::Carp::import
8322µs265µs
# spent 37µs (10+28) within DBIx::Class::Relationship::ManyToMany::BEGIN@8 which was called: # once (10µs+28µs) by Class::C3::Componentised::ensure_class_loaded at line 8
use Sub::Name qw/subname/;
# spent 37µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@8 # spent 28µs making 1 call to Exporter::import
9324µs252µs
# spent 30µs (8+22) within DBIx::Class::Relationship::ManyToMany::BEGIN@9 which was called: # once (8µs+22µs) by Class::C3::Componentised::ensure_class_loaded at line 9
use Scalar::Util qw/blessed/;
# spent 30µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@9 # spent 22µs making 1 call to Exporter::import
10
11365µs2289µs
# spent 148µs (7+141) within DBIx::Class::Relationship::ManyToMany::BEGIN@11 which was called: # once (7µs+141µs) by Class::C3::Componentised::ensure_class_loaded at line 11
use namespace::clean;
# spent 148µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@11 # spent 141µs making 1 call to namespace::clean::import
12
1312µsour %_pod_inherit_config =
14 (
15 class_map => { 'DBIx::Class::Relationship::ManyToMany' => 'DBIx::Class::Relationship' }
16 );
17
18
# spent 571µs (245+326) within DBIx::Class::Relationship::ManyToMany::many_to_many which was called 4 times, avg 143µs/call: # once (83µs+82µs) by Class::C3::Componentised::ensure_class_loaded at line 28 of Tapper/Schema/TestrunDB/Result/Precondition.pm # once (62µs+84µs) by Class::C3::Componentised::ensure_class_loaded at line 44 of Tapper/Schema/TestrunDB/Result/Testrun.pm # once (52µs+82µs) by Class::C3::Componentised::ensure_class_loaded at line 31 of Tapper/Schema/TestrunDB/Result/Precondition.pm # once (48µs+79µs) by Class::C3::Componentised::ensure_class_loaded at line 34 of Tapper/Schema/TestrunDB/Result/Precondition.pm
sub many_to_many {
1945µs my ($class, $meth, $rel, $f_rel, $rel_attrs) = @_;
20
2141µs $class->throw_exception(
22 "missing relation in many-to-many"
23 ) unless $rel;
24
254700ns $class->throw_exception(
26 "missing foreign relation in many-to-many"
27 ) unless $f_rel;
28
29 {
30737µs234µs
# spent 20µs (7+13) within DBIx::Class::Relationship::ManyToMany::BEGIN@30 which was called: # once (7µs+13µs) by Class::C3::Componentised::ensure_class_loaded at line 30
no strict 'refs';
# spent 20µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@30 # spent 13µs making 1 call to strict::unimport
313665µs236µs
# spent 22µs (7+15) within DBIx::Class::Relationship::ManyToMany::BEGIN@31 which was called: # once (7µs+15µs) by Class::C3::Componentised::ensure_class_loaded at line 31
no warnings 'redefine';
# spent 22µs making 1 call to DBIx::Class::Relationship::ManyToMany::BEGIN@31 # spent 15µs making 1 call to warnings::unimport
32
3343µs my $add_meth = "add_to_${meth}";
3443µs my $remove_meth = "remove_from_${meth}";
3542µs my $set_meth = "set_${meth}";
3642µs my $rs_meth = "${meth}_rs";
37
3844µs for ($add_meth, $remove_meth, $set_meth, $rs_meth) {
3916314µs16277µs if ( $class->can ($_) ) {
# spent 277µs making 16 calls to UNIVERSAL::can, avg 17µs/call
40 carp (<<"EOW") unless $ENV{DBIC_OVERWRITE_HELPER_METHODS_OK};
41
42***************************************************************************
43The many-to-many relationship '$meth' is trying to create a utility method
44called $_.
45This will completely overwrite one such already existing method on class
46$class.
47
48You almost certainly want to rename your method or the many-to-many
49relationship, as the functionality of the original method will not be
50accessible anymore.
51
52To disable this warning set to a true value the environment variable
53DBIC_OVERWRITE_HELPER_METHODS_OK
54
55***************************************************************************
56EOW
57 }
58 }
59
6044µs $rel_attrs->{alias} ||= $f_rel;
61
6244µs my $rs_meth_name = join '::', $class, $rs_meth;
63 *$rs_meth_name = subname $rs_meth_name, sub {
6414788µs my $self = shift;
65147194µs my $attrs = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {};
66147764µs my @args = ($f_rel, @_ > 0 ? @_ : undef, { %{$rel_attrs||{}}, %$attrs });
67 my $rs = $self->search_related($rel)->search_related(
681473.26ms294266ms $f_rel, @_ > 0 ? @_ : undef, { %{$rel_attrs||{}}, %$attrs }
# spent 146ms making 147 calls to DBIx::Class::ResultSet::search_related, avg 992µs/call # spent 120ms making 147 calls to DBIx::Class::Relationship::Base::search_related, avg 818µs/call
69 );
70147741µs return $rs;
71443µs411µs };
# spent 11µs making 4 calls to Sub::Name::subname, avg 3µs/call
72
7343µs my $meth_name = join '::', $class, $meth;
74 *$meth_name = subname $meth_name, sub {
7514794µs my $self = shift;
76147511µs147271ms my $rs = $self->$rs_meth( @_ );
# spent 271ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::preconditions_rs, avg 1.84ms/call
77147532µs return (wantarray ? $rs->all : $rs);
78441µs410µs };
# spent 10µs making 4 calls to Sub::Name::subname, avg 3µs/call
79
8043µs my $add_meth_name = join '::', $class, $add_meth;
81 *$add_meth_name = subname $add_meth_name, sub {
82 my $self = shift;
83 @_ > 0 or $self->throw_exception(
84 "${add_meth} needs an object or hashref"
85 );
86 my $source = $self->result_source;
87 my $schema = $source->schema;
88 my $rel_source_name = $source->relationship_info($rel)->{source};
89 my $rel_source = $schema->resultset($rel_source_name)->result_source;
90 my $f_rel_source_name = $rel_source->relationship_info($f_rel)->{source};
91 my $f_rel_rs = $schema->resultset($f_rel_source_name)->search({}, $rel_attrs||{});
92
93 my $obj;
94 if (ref $_[0]) {
95 if (ref $_[0] eq 'HASH') {
96 $obj = $f_rel_rs->find_or_create($_[0]);
97 } else {
98 $obj = $_[0];
99 }
100 } else {
101 $obj = $f_rel_rs->find_or_create({@_});
102 }
103
104 my $link_vals = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {};
105 my $link = $self->search_related($rel)->new_result($link_vals);
106 $link->set_from_related($f_rel, $obj);
107 $link->insert();
108 return $obj;
109444µs410µs };
# spent 10µs making 4 calls to Sub::Name::subname, avg 2µs/call
110
11143µs my $set_meth_name = join '::', $class, $set_meth;
112 *$set_meth_name = subname $set_meth_name, sub {
113 my $self = shift;
114 @_ > 0 or $self->throw_exception(
115 "{$set_meth} needs a list of objects or hashrefs"
116 );
117 my @to_set = (ref($_[0]) eq 'ARRAY' ? @{ $_[0] } : @_);
118 # if there is a where clause in the attributes, ensure we only delete
119 # rows that are within the where restriction
120 if ($rel_attrs && $rel_attrs->{where}) {
121 $self->search_related( $rel, $rel_attrs->{where},{join => $f_rel})->delete;
122 } else {
123 $self->search_related( $rel, {} )->delete;
124 }
125 # add in the set rel objects
126 $self->$add_meth($_, ref($_[1]) ? $_[1] : {}) for (@to_set);
127435µs49µs };
# spent 9µs making 4 calls to Sub::Name::subname, avg 2µs/call
128
12943µs my $remove_meth_name = join '::', $class, $remove_meth;
130 *$remove_meth_name = subname $remove_meth_name, sub {
131 my ($self, $obj) = @_;
132 $self->throw_exception("${remove_meth} needs an object")
133 unless blessed ($obj);
134 my $rel_source = $self->search_related($rel)->result_source;
135 my $cond = $rel_source->relationship_info($f_rel)->{cond};
136 my ($link_cond, $crosstable) = $rel_source->_resolve_condition(
137 $cond, $obj, $f_rel, $f_rel
138 );
139
140 $self->throw_exception(
141 "Custom relationship '$rel' does not resolve to a join-free condition, "
142 ."unable to use with the ManyToMany helper '$f_rel'"
143 ) if $crosstable;
144
145 $self->search_related($rel, $link_cond)->delete;
146443µs49µs };
# spent 9µs making 4 calls to Sub::Name::subname, avg 2µs/call
147
148 }
149}
150
151114µs1353µs1;