Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Tapper/Schema/TestrunDB/Result/Testrun.pm |
Statements | Executed 4502 statements in 63.9ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
147 | 1 | 1 | 69.7ms | 71.4s | rerun | Tapper::Schema::TestrunDB::Result::Testrun::
147 | 1 | 1 | 12.3ms | 15.4s | assign_preconditions | Tapper::Schema::TestrunDB::Result::Testrun::
1 | 1 | 1 | 49µs | 142µs | BEGIN@9 | Tapper::Schema::TestrunDB::Result::Testrun::
1 | 1 | 1 | 12µs | 51µs | BEGIN@14 | Tapper::Schema::TestrunDB::Result::Testrun::
1 | 1 | 1 | 11µs | 11µs | BEGIN@2 | Tapper::Schema::TestrunDB::Result::Testrun::
1 | 1 | 1 | 10µs | 93µs | BEGIN@9.21 | Tapper::Schema::TestrunDB::Result::Testrun::
1 | 1 | 1 | 9µs | 14µs | BEGIN@10 | Tapper::Schema::TestrunDB::Result::Testrun::
1 | 1 | 1 | 9µs | 48µs | BEGIN@13 | Tapper::Schema::TestrunDB::Result::Testrun::
1 | 1 | 1 | 9µs | 25µs | BEGIN@11 | Tapper::Schema::TestrunDB::Result::Testrun::
1 | 1 | 1 | 6µs | 6µs | CORE:subst (opcode) | Tapper::Schema::TestrunDB::Result::Testrun::
0 | 0 | 0 | 0s | 0s | disassign_preconditions | Tapper::Schema::TestrunDB::Result::Testrun::
0 | 0 | 0 | 0s | 0s | insert_preconditions | Tapper::Schema::TestrunDB::Result::Testrun::
0 | 0 | 0 | 0s | 0s | is_member | Tapper::Schema::TestrunDB::Result::Testrun::
0 | 0 | 0 | 0s | 0s | ordered_preconditions | Tapper::Schema::TestrunDB::Result::Testrun::
0 | 0 | 0 | 0s | 0s | to_string | Tapper::Schema::TestrunDB::Result::Testrun::
0 | 0 | 0 | 0s | 0s | update_content | Tapper::Schema::TestrunDB::Result::Testrun::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package 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 | ||||
3 | 1 | 5µs | $Tapper::Schema::TestrunDB::Result::Testrun::AUTHORITY = 'cpan:AMD'; | ||
4 | 1 | 27µs | 1 | 11µs | } # spent 11µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@2 |
5 | { | ||||
6 | 2 | 2µs | $Tapper::Schema::TestrunDB::Result::Testrun::VERSION = '0.001'; | ||
7 | } | ||||
8 | |||||
9 | 6 | 70µs | 3 | 320µ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 # 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 |
10 | 3 | 18µs | 2 | 18µ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 # spent 14µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@10
# spent 4µs making 1 call to strict::import |
11 | 3 | 21µs | 2 | 42µ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 # spent 25µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@11
# spent 16µs making 1 call to warnings::import |
12 | |||||
13 | 3 | 20µs | 2 | 86µ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 # spent 48µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@13
# spent 39µs making 1 call to parent::import |
14 | 3 | 1.23ms | 2 | 90µ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 # spent 51µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::BEGIN@14
# spent 39µs making 1 call to Exporter::import |
15 | |||||
16 | 1 | 14µs | 1 | 380µs | __PACKAGE__->load_components(qw/InflateColumn::DateTime Core/); # spent 380µs making 1 call to Class::C3::Componentised::load_components |
17 | 1 | 15µs | 1 | 455µs | __PACKAGE__->table("testrun"); # spent 455µs making 1 call to DBIx::Class::ResultSourceProxy::Table::table |
18 | 1 | 51µs | 1 | 3.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 | |||||
36 | 1 | 24µs | 1 | 54µs | __PACKAGE__->set_primary_key("id"); # spent 54µs making 1 call to DBIx::Class::ResultSourceProxy::set_primary_key |
37 | |||||
38 | 1 | 12µs | 1 | 6µs | (my $basepkg = __PACKAGE__) =~ s/::\w+$//; # spent 6µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::CORE:subst |
39 | |||||
40 | 1 | 9µs | 1 | 229µ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 |
41 | 1 | 3µs | 1 | 128µ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 | |||||
43 | 1 | 9µs | 1 | 109µ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 |
44 | 1 | 9µs | 1 | 146µs | __PACKAGE__->many_to_many ( preconditions => "testrun_precondition", 'precondition' ); # spent 146µs making 1 call to DBIx::Class::Relationship::ManyToMany::many_to_many |
45 | |||||
46 | 1 | 15µs | 1 | 182µ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 |
47 | 1 | 3µs | 1 | 150µ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 |
48 | 1 | 2µs | 1 | 175µ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 |
49 | 1 | 6µs | 1 | 100µ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 | |||||
55 | sub 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 | |||||
71 | sub is_member | ||||
72 | { | ||||
73 | my ($head, @tail) = @_; | ||||
74 | grep { $head->id eq $_->id } @tail; | ||||
75 | } | ||||
76 | |||||
77 | |||||
78 | sub 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 | |||||
105 | sub 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 | |||||
118 | sub 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 | ||||
120 | 147 | 112µs | my ($self, $args) = @_; | ||
121 | |||||
122 | 147 | 5.45ms | 1323 | 156ms | 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 | ||||
132 | 147 | 2.94ms | 882 | 339ms | 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 |
133 | 147 | 2.40ms | 147 | 5.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 | 147 | 628µs | if ($testrunscheduling) { | ||
135 | 147 | 477µs | 147 | 1.74ms | $queue_id = $testrunscheduling->queue_id; # spent 1.74ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::queue_id, avg 12µs/call |
136 | 147 | 382µs | 147 | 1.04ms | $host_id = $testrunscheduling->host_id; # spent 1.04ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::host_id, avg 7µs/call |
137 | 147 | 431µs | 147 | 1.02ms | $auto_rerun = $testrunscheduling->auto_rerun; # spent 1.02ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::auto_rerun, avg 7µs/call |
138 | 147 | 1.04ms | 147 | 99.8ms | $requested_features = $testrunscheduling->requested_features; # spent 99.8ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::requested_features, avg 679µs/call |
139 | 147 | 443µs | 147 | 71.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 | ||||
150 | 147 | 2.79ms | 294 | 17.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 |
151 | 147 | 8.67ms | 735 | 244ms | 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 | }); | ||||
159 | 147 | 680µs | 147 | 17.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 | ||||
162 | 147 | 8.45ms | 441 | 912ms | 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 | } | ||||
168 | 147 | 5.72ms | 441 | 583ms | 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 | ||||
176 | 147 | 1.49ms | 294 | 291ms | 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 | 147 | 70µs | my @preconditions; | ||
178 | 147 | 1.45ms | 405 | 482ms | 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 | } | ||||
181 | 147 | 542µs | 147 | 30.1ms | $testrunscheduling_new->status('schedule'); # spent 30.1ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::status, avg 205µs/call |
182 | 147 | 524µs | 147 | 17.4s | $testrunscheduling_new->update; # spent 17.4s making 147 calls to DBIx::Class::Relationship::CascadeActions::update, avg 118ms/call |
183 | 147 | 1.19ms | 147 | 15.4s | $testrun_new->assign_preconditions(@preconditions); # spent 15.4s making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::assign_preconditions, avg 105ms/call |
184 | 147 | 5.53ms | 147 | 4.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 | ||||
189 | 147 | 339µs | my ($self, @preconditions) = @_; | ||
190 | |||||
191 | 147 | 130µs | my $succession = 1; | ||
192 | 147 | 647µs | foreach my $precondition_id (@preconditions) { | ||
193 | 129 | 6.11ms | 645 | 153ms | 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 | 129 | 202µs | eval { | ||
200 | 129 | 924µs | 129 | 15.2s | $testrun_precondition->insert; # spent 15.2s making 129 calls to DBIx::Class::Row::insert, avg 118ms/call |
201 | }; | ||||
202 | 129 | 77µs | return "Can not assign $precondition_id: $@" if $@; | ||
203 | 129 | 1.11ms | $succession++; | ||
204 | } | ||||
205 | 147 | 1.32ms | return 0; | ||
206 | } | ||||
207 | |||||
208 | |||||
209 | sub 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 | |||||
241 | sub 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 | |||||
260 | 1 | 40µs | 1; | ||
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 |