← 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:22:37 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Tapper/Schema/TestrunDB/Result/Testrun.pm
StatementsExecuted 4502 statements in 63.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1471169.7ms71.4sTapper::Schema::TestrunDB::Result::Testrun::::rerunTapper::Schema::TestrunDB::Result::Testrun::rerun
1471112.3ms15.4sTapper::Schema::TestrunDB::Result::Testrun::::assign_preconditionsTapper::Schema::TestrunDB::Result::Testrun::assign_preconditions
11149µs142µsTapper::Schema::TestrunDB::Result::Testrun::::BEGIN@9Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@9
11112µs51µsTapper::Schema::TestrunDB::Result::Testrun::::BEGIN@14Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@14
11111µs11µsTapper::Schema::TestrunDB::Result::Testrun::::BEGIN@2Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@2
11110µs93µsTapper::Schema::TestrunDB::Result::Testrun::::BEGIN@9.21Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@9.21
1119µs14µsTapper::Schema::TestrunDB::Result::Testrun::::BEGIN@10Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@10
1119µs48µsTapper::Schema::TestrunDB::Result::Testrun::::BEGIN@13Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@13
1119µs25µsTapper::Schema::TestrunDB::Result::Testrun::::BEGIN@11Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@11
1116µs6µsTapper::Schema::TestrunDB::Result::Testrun::::CORE:substTapper::Schema::TestrunDB::Result::Testrun::CORE:subst (opcode)
0000s0sTapper::Schema::TestrunDB::Result::Testrun::::disassign_preconditionsTapper::Schema::TestrunDB::Result::Testrun::disassign_preconditions
0000s0sTapper::Schema::TestrunDB::Result::Testrun::::insert_preconditionsTapper::Schema::TestrunDB::Result::Testrun::insert_preconditions
0000s0sTapper::Schema::TestrunDB::Result::Testrun::::is_memberTapper::Schema::TestrunDB::Result::Testrun::is_member
0000s0sTapper::Schema::TestrunDB::Result::Testrun::::ordered_preconditionsTapper::Schema::TestrunDB::Result::Testrun::ordered_preconditions
0000s0sTapper::Schema::TestrunDB::Result::Testrun::::to_stringTapper::Schema::TestrunDB::Result::Testrun::to_string
0000s0sTapper::Schema::TestrunDB::Result::Testrun::::update_contentTapper::Schema::TestrunDB::Result::Testrun::update_content
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Tapper::Schema::TestrunDB::Result::Testrun;
2
# spent 11µs within Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@2 which was called: # once (11µs+0s) by Class::C3::Componentised::ensure_class_loaded at line 4
BEGIN {
315µs $Tapper::Schema::TestrunDB::Result::Testrun::AUTHORITY = 'cpan:AMD';
4127µs111µs}
5{
622µs $Tapper::Schema::TestrunDB::Result::Testrun::VERSION = '0.001';
7}
8
9670µs3320µs
# spent 142µs (49+93) within Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@9 which was called: # once (49µs+93µs) by Class::C3::Componentised::ensure_class_loaded at line 9 # spent 93µs (10+84) within Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@9.21 which was called: # once (10µs+84µs) by Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@9 at line 9
use 5.010;
# spent 142µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@9 # spent 93µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@9.21 # spent 84µs making 1 call to feature::import
10318µs218µs
# spent 14µs (9+4) within Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@10 which was called: # once (9µs+4µs) by Class::C3::Componentised::ensure_class_loaded at line 10
use strict;
# spent 14µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@10 # spent 4µs making 1 call to strict::import
11321µs242µs
# spent 25µs (9+16) within Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@11 which was called: # once (9µs+16µs) by Class::C3::Componentised::ensure_class_loaded at line 11
use warnings;
# spent 25µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@11 # spent 16µs making 1 call to warnings::import
12
13320µs286µs
# spent 48µs (9+39) within Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@13 which was called: # once (9µs+39µs) by Class::C3::Componentised::ensure_class_loaded at line 13
use parent 'DBIx::Class';
# spent 48µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@13 # spent 39µs making 1 call to parent::import
1431.23ms290µs
# spent 51µs (12+39) within Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@14 which was called: # once (12µs+39µs) by Class::C3::Componentised::ensure_class_loaded at line 14
use Data::Dumper;
# spent 51µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@14 # spent 39µs making 1 call to Exporter::import
15
16114µs1380µs__PACKAGE__->load_components(qw/InflateColumn::DateTime Core/);
# spent 380µs making 1 call to Class::C3::Componentised::load_components
17115µs1455µs__PACKAGE__->table("testrun");
# spent 455µs making 1 call to DBIx::Class::ResultSourceProxy::Table::table
18151µs13.36ms__PACKAGE__->add_columns
# spent 3.36ms making 1 call to DBIx::Class::ResultSourceProxy::add_columns
19 (
20 "id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_auto_increment => 1, },
21 "shortname", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, },
22 "notes", { data_type => "TEXT", default_value => "", is_nullable => 1, },
23 "topic_name", { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 255, is_foreign_key => 1, },
24 "starttime_earliest", { data_type => "DATETIME", default_value => undef, is_nullable => 1, },
25 "starttime_testrun", { data_type => "DATETIME", default_value => undef, is_nullable => 1, },
26 "starttime_test_program", { data_type => "DATETIME", default_value => undef, is_nullable => 1, },
27 "endtime_test_program", { data_type => "DATETIME", default_value => undef, is_nullable => 1, },
28 "owner_user_id", { data_type => "INT", default_value => undef, is_nullable => 1, size => 11, is_foreign_key => 1, },
29 "testplan_id", { data_type => "INT", default_value => undef, is_nullable => 1, size => 11, is_foreign_key => 1, },
30 "wait_after_tests", { data_type => "INT", default_value => 0, is_nullable => 1, size => 1, },
31 "rerun_on_error", { data_type => "INT", default_value => 0, is_nullable => 1, size => 11, }, # number of times to rerun this test on error
32 "created_at" , { data_type => "TIMESTAMP", default_value => \'CURRENT_TIMESTAMP', is_nullable => 0, set_on_create => 1, },
33 "updated_at", { data_type => "DATETIME", default_value => undef, is_nullable => 1, set_on_create => 1, set_on_update => 1, },
34 );
35
36124µs154µs__PACKAGE__->set_primary_key("id");
37
38112µs16µs(my $basepkg = __PACKAGE__) =~ s/::\w+$//;
39
4019µs1229µs__PACKAGE__->belongs_to ( owner => "${basepkg}::User", { 'foreign.id' => 'self.owner_user_id' });
# spent 229µs making 1 call to DBIx::Class::Relationship::BelongsTo::belongs_to
4113µs1128µs__PACKAGE__->belongs_to ( testplan_instance => "${basepkg}::TestplanInstance", { 'foreign.id' => 'self.testplan_id' });
# spent 128µs making 1 call to DBIx::Class::Relationship::BelongsTo::belongs_to
42
4319µs1109µs__PACKAGE__->has_many ( testrun_precondition => "${basepkg}::TestrunPrecondition", { 'foreign.testrun_id' => 'self.id' });
# spent 109µs making 1 call to DBIx::Class::Relationship::HasMany::has_many
4419µs1146µs__PACKAGE__->many_to_many ( preconditions => "testrun_precondition", 'precondition' );
45
46115µs1182µs__PACKAGE__->might_have ( testrun_scheduling => "${basepkg}::TestrunScheduling", { 'foreign.testrun_id' => 'self.id' });
# spent 182µs making 1 call to DBIx::Class::Relationship::HasOne::might_have
4713µs1150µs__PACKAGE__->might_have ( scenario_element => "${basepkg}::ScenarioElement", { 'foreign.testrun_id' => 'self.id' });
# spent 150µs making 1 call to DBIx::Class::Relationship::HasOne::might_have
4812µs1175µs__PACKAGE__->might_have ( state => "${basepkg}::State", { 'foreign.testrun_id' => 'self.id' });
# spent 175µs making 1 call to DBIx::Class::Relationship::HasOne::might_have
4916µs1100µs__PACKAGE__->has_many ( message => "${basepkg}::Message", { 'foreign.testrun_id' => 'self.id' });
# spent 100µs making 1 call to DBIx::Class::Relationship::HasMany::has_many
50
51
52# -------------------- methods on results --------------------
53
54
55sub to_string
56{
57 my ($self) = @_;
58
59 my $format = join( $Tapper::Schema::TestrunDB::DELIM, qw/%s %s %s %s %s %s %s %s %s %s %s %s %s %s /, '');
60 sprintf (
61 $format,
62 map {
63 defined $self->$_
64 ? $self->$_
65 : $Tapper::Schema::TestrunDB::NULL
66 } @{$self->result_source->{_ordered_columns} }
67 );
68}
69
70
71sub is_member
72{
73 my ($head, @tail) = @_;
74 grep { $head->id eq $_->id } @tail;
75}
76
77
78sub ordered_preconditions
79{
80 my ($self) = @_;
81
82 my @done = ();
83 my %seen = ();
84 my @todo = ();
85
86 @todo = $self->preconditions->search({}, {order_by => 'succession'})->all;
87
88 while (my $head = shift @todo)
89 {
90 if ($seen{$head->id})
91 {
92 push @done, $head unless is_member($head, @done);
93 }
94 else
95 {
96 $seen{$head->id} = 1;
97 my @pre_todo = $head->child_preconditions->search({}, { order_by => 'succession' } )->all;
98 unshift @todo, @pre_todo, $head;
99 }
100 }
101 return @done;
102}
103
104
105sub update_content {
106 my ($self, $args) =@_;
107
108 $self->notes ( $args->{notes} ) if $args->{notes};
109 $self->shortname ( $args->{shortname} ) if $args->{shortname};
110 $self->topic_name ( $args->{topic} ) if $args->{topic};
111 $self->starttime_earliest ( $args->{date} ) if $args->{date};
112 $self->owner_user_id ( $args->{owner_user_id} ) if $args->{owner_user_id};
113 $self->update;
114 return $self->id;
115}
116
117
118sub rerun
119
# spent 71.4s (69.7ms+71.4) within Tapper::Schema::TestrunDB::Result::Testrun::rerun which was called 147 times, avg 486ms/call: # 147 times (69.7ms+71.4s) by Tapper::MCP::Scheduler::Controller::get_next_job at line 96 of lib/Tapper/MCP/Scheduler/Controller.pm, avg 486ms/call
{
120323439.6ms my ($self, $args) = @_;
121
1221323156ms my $testrun_new = $self->result_source->schema->resultset('Testrun')->new
# spent 59.9ms making 147 calls to DBIx::Class::ResultSet::new, avg 407µs/call # spent 58.2ms making 147 calls to DateTime::now, avg 396µs/call # spent 32.3ms making 147 calls to DBIx::Class::Schema::resultset, avg 219µs/call # spent 1.25ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::owner_user_id, avg 9µs/call # spent 1.19ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::notes, avg 8µs/call # spent 1.08ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::shortname, avg 7µs/call # spent 975µs making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::topic_name, avg 7µs/call # spent 566µs making 147 calls to DBIx::Class::Row::result_source, avg 4µs/call # spent 502µs making 147 calls to DBIx::Class::ResultSource::schema, avg 3µs/call
123 ({
124 notes => $args->{notes} || $self->notes,
125 shortname => $args->{shortname} || $self->shortname,
126 topic_name => $args->{topic_name} || $self->topic_name,
127 starttime_earliest => $args->{earliest} || DateTime->now,
128 owner_user_id => $args->{owner_user_id} || $self->owner_user_id,
129 });
130
131 # prepare job scheduling infos
132882339ms my $testrunscheduling = $self->result_source->schema->resultset('TestrunScheduling')->search({ testrun_id => $self->id })->first;
# spent 286ms making 147 calls to DBIx::Class::ResultSet::first, avg 1.95ms/call # spent 34.1ms making 147 calls to DBIx::Class::Schema::resultset, avg 232µs/call # spent 16.1ms making 147 calls to DBIx::Class::ResultSet::search, avg 110µs/call # spent 1.25ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::id, avg 9µs/call # spent 360µs making 147 calls to DBIx::Class::ResultSource::schema, avg 2µs/call # spent 288µs making 147 calls to DBIx::Class::Row::result_source, avg 2µs/call
13312.27ms1475.14ms my ($queue_id, $host_id, $auto_rerun, $requested_features, $requested_hosts);
# spent 5.14ms making 147 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 35µs/call
134 if ($testrunscheduling) {
1351471.74ms $queue_id = $testrunscheduling->queue_id;
# spent 1.74ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::queue_id, avg 12µs/call
1361471.04ms $host_id = $testrunscheduling->host_id;
# spent 1.04ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::host_id, avg 7µs/call
1371471.02ms $auto_rerun = $testrunscheduling->auto_rerun;
# spent 1.02ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::auto_rerun, avg 7µs/call
13814799.8ms $requested_features = $testrunscheduling->requested_features;
# spent 99.8ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::requested_features, avg 679µs/call
13914771.9ms $requested_hosts = $testrunscheduling->requested_hosts;
# spent 71.9ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::requested_hosts, avg 489µs/call
140 } else {
141 my $queue = $self->result_source->schema->resultset('Queue')->search({ name => "AdHoc"} )->first;
142 if (not $queue) {
143 die "No default queue 'AdHoc' found.";
144 }
145 $queue_id = $queue->id;
146 $auto_rerun = 0;
147 }
148
149 # create testrun and job
15012.24ms29417.6s $testrun_new->insert;
# spent 17.6s making 147 calls to DBIx::Class::Row::insert, avg 120ms/call # spent 2.44ms making 147 calls to DBIx::Class::Storage::TxnScopeGuard::DESTROY, avg 17µs/call
151735244ms my $testrunscheduling_new = $self->result_source->schema->resultset('TestrunScheduling')->new
# spent 133ms making 147 calls to DBIx::Class::ResultSet::new, avg 908µs/call # spent 103ms making 147 calls to DBIx::Class::Schema::resultset, avg 701µs/call # spent 3.97ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::id, avg 27µs/call # spent 2.08ms making 147 calls to DBIx::Class::Row::result_source, avg 14µs/call # spent 1.31ms making 147 calls to DBIx::Class::ResultSource::schema, avg 9µs/call
152 ({
153 testrun_id => $testrun_new->id,
154 queue_id => $args->{queue_id} || $queue_id,
155 status => "prepare",
156 auto_rerun => $args->{host_id} // $auto_rerun,
157 host_id => undef,
158 });
15914717.8s $testrunscheduling_new->insert;
# spent 17.8s making 147 calls to DBIx::Class::Row::insert, avg 121ms/call
160
161 # assign requested host and features
16214.42ms441912ms if ($testrunscheduling and $testrunscheduling->requested_features->count) {
# spent 822ms making 147 calls to DBIx::Class::ResultSet::count, avg 5.59ms/call # spent 80.0ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::requested_features, avg 544µs/call # spent 10.0ms making 147 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 68µs/call
163 foreach my $feature (map {$_->feature}$testrunscheduling->requested_features->all) {
164 my $assigned_feature = $self->result_source->schema->resultset('TestrunRequestedFeature')->new({feature => $feature, testrun_id => $testrun_new->id});
165 $assigned_feature->insert;
166 }
167 }
16812.86ms441583ms if ($testrunscheduling and $testrunscheduling->requested_hosts->count) {
# spent 514ms making 147 calls to DBIx::Class::ResultSet::count, avg 3.49ms/call # spent 63.5ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::requested_hosts, avg 432µs/call # spent 5.91ms making 147 calls to DBIx::Class::Storage::DBI::Cursor::DESTROY, avg 40µs/call
169 foreach my $host_id (map {$_->host_id}$testrunscheduling->requested_hosts->all) {
170 my $assigned_host = $self->result_source->schema->resultset('TestrunRequestedHost')->new({host_id => $host_id, testrun_id => $testrun_new->id});
171 $assigned_host->insert;
172 }
173 }
174
175 # assign preconditions
176294291ms my $preconditions = $self->preconditions->search({}, {order_by => 'succession'});
# spent 272ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::preconditions, avg 1.85ms/call # spent 18.4ms making 147 calls to DBIx::Class::ResultSet::search, avg 125µs/call
177 my @preconditions;
178405482ms while (my $precond = $preconditions->next) {
# spent 480ms making 276 calls to DBIx::Class::ResultSet::next, avg 1.74ms/call # spent 1.52ms making 129 calls to Tapper::Schema::TestrunDB::Result::Precondition::id, avg 12µs/call
179 push @preconditions, $precond->id;
180 }
18114730.1ms $testrunscheduling_new->status('schedule');
# spent 30.1ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::status, avg 205µs/call
18214717.4s $testrunscheduling_new->update;
# spent 17.4s making 147 calls to DBIx::Class::Relationship::CascadeActions::update, avg 118ms/call
18314715.4s $testrun_new->assign_preconditions(@preconditions);
# spent 15.4s making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::assign_preconditions, avg 105ms/call
1841474.34ms return $testrun_new->id;
# spent 4.34ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::id, avg 29µs/call
185}
186
187
188
# spent 15.4s (12.3ms+15.4) within Tapper::Schema::TestrunDB::Result::Testrun::assign_preconditions which was called 147 times, avg 105ms/call: # 147 times (12.3ms+15.4s) by Tapper::Schema::TestrunDB::Result::Testrun::rerun at line 183, avg 105ms/call
sub assign_preconditions {
189123310.9ms my ($self, @preconditions) = @_;
190
191 my $succession = 1;
192 foreach my $precondition_id (@preconditions) {
193645153ms my $testrun_precondition = $self->result_source->schema->resultset('TestrunPrecondition')->new
# spent 77.4ms making 129 calls to DBIx::Class::ResultSet::new, avg 600µs/call # spent 69.4ms making 129 calls to DBIx::Class::Schema::resultset, avg 538µs/call # spent 3.35ms making 129 calls to Tapper::Schema::TestrunDB::Result::Testrun::id, avg 26µs/call # spent 1.38ms making 129 calls to DBIx::Class::Row::result_source, avg 11µs/call # spent 1.20ms making 129 calls to DBIx::Class::ResultSource::schema, avg 9µs/call
194 ({
195 testrun_id => $self->id,
196 precondition_id => $precondition_id,
197 succession => $succession,
198 });
199 eval {
20012915.2s $testrun_precondition->insert;
# spent 15.2s making 129 calls to DBIx::Class::Row::insert, avg 118ms/call
201 };
202 return "Can not assign $precondition_id: $@" if $@;
203 $succession++;
204 }
205 return 0;
206}
207
208
209sub insert_preconditions {
210 my ($self, $position, @preconditions) = @_;
211
212 my $succession = $position;
213 my $testrun_precondition = $self->result_source->schema->resultset('TestrunPrecondition');
214
215 # move existing preconditions
216 my $remaining_preconditions = $testrun_precondition->search({testrun_id => $self->id,
217 succession => { '>=' => $position }});
218 while (my $remain = $remaining_preconditions->next) {
219 $remain->succession($remain->succession + int @preconditions);
220 $remain->update;
221 }
222
223 # assign new ones
224 foreach my $precondition_id (@preconditions) {
225 my $testrun_precondition = $testrun_precondition->new
226 ({
227 testrun_id => $self->id,
228 precondition_id => $precondition_id,
229 succession => $succession,
230 });
231 eval {
232 $testrun_precondition->insert;
233 };
234 return "Can not assign $precondition_id: $@" if $@;
235 $succession++;
236 }
237 return 0;
238}
239
240
241sub disassign_preconditions {
242 my ($self, @preconditions) = @_;
243
244 my $table = $self->result_source->schema->resultset('TestrunPrecondition');
245 my $preconditions;
246 if (not @preconditions) {
247 $preconditions = $table->search({testrun_id => $self->id});
248 } else {
249 $preconditions = $table->search({testrun_id => $self->id,
250 precondition_id => [ -or => [ @preconditions ]]});
251 }
252
253
254 while( my $precondition = $preconditions->next) {
255 $precondition->delete();
256 }
257 return 0;
258}
259
260140µs1;
261
262__END__
 
# spent 6µs within Tapper::Schema::TestrunDB::Result::Testrun::CORE:subst which was called: # once (6µs+0s) by Class::C3::Componentised::ensure_class_loaded at line 38
sub Tapper::Schema::TestrunDB::Result::Testrun::CORE:subst; # opcode