Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Tapper/Schema/TestrunDB/Result/Queue.pm |
Statements | Executed 4134 statements in 24.0ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
477 | 1 | 1 | 25.9ms | 8.31s | get_first_fitting | Tapper::Schema::TestrunDB::Result::Queue::
807 | 2 | 2 | 8.50ms | 542ms | queued_testruns | Tapper::Schema::TestrunDB::Result::Queue::
1 | 1 | 1 | 10µs | 25µs | BEGIN@10 | Tapper::Schema::TestrunDB::Result::Queue::
1 | 1 | 1 | 10µs | 10µs | BEGIN@2 | Tapper::Schema::TestrunDB::Result::Queue::
1 | 1 | 1 | 10µs | 44µs | BEGIN@12 | Tapper::Schema::TestrunDB::Result::Queue::
1 | 1 | 1 | 8µs | 13µs | BEGIN@9 | Tapper::Schema::TestrunDB::Result::Queue::
1 | 1 | 1 | 6µs | 6µs | CORE:subst (opcode) | Tapper::Schema::TestrunDB::Result::Queue::
0 | 0 | 0 | 0s | 0s | is_member | Tapper::Schema::TestrunDB::Result::Queue::
0 | 0 | 0 | 0s | 0s | ordered_preconditions | Tapper::Schema::TestrunDB::Result::Queue::
0 | 0 | 0 | 0s | 0s | produce | Tapper::Schema::TestrunDB::Result::Queue::
0 | 0 | 0 | 0s | 0s | producer | Tapper::Schema::TestrunDB::Result::Queue::
0 | 0 | 0 | 0s | 0s | to_string | Tapper::Schema::TestrunDB::Result::Queue::
0 | 0 | 0 | 0s | 0s | update_content | Tapper::Schema::TestrunDB::Result::Queue::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Tapper::Schema::TestrunDB::Result::Queue; | ||||
2 | # spent 10µs within Tapper::Schema::TestrunDB::Result::Queue::BEGIN@2 which was called:
# once (10µs+0s) by Class::C3::Componentised::ensure_class_loaded at line 4 | ||||
3 | 1 | 4µs | $Tapper::Schema::TestrunDB::Result::Queue::AUTHORITY = 'cpan:AMD'; | ||
4 | 1 | 24µs | 1 | 10µs | } # spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::BEGIN@2 |
5 | { | ||||
6 | 2 | 1µs | $Tapper::Schema::TestrunDB::Result::Queue::VERSION = '0.001'; | ||
7 | } | ||||
8 | |||||
9 | 3 | 20µs | 2 | 18µs | # spent 13µs (8+5) within Tapper::Schema::TestrunDB::Result::Queue::BEGIN@9 which was called:
# once (8µs+5µs) by Class::C3::Componentised::ensure_class_loaded at line 9 # spent 13µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::BEGIN@9
# spent 5µs making 1 call to strict::import |
10 | 3 | 25µs | 2 | 40µs | # spent 25µs (10+15) within Tapper::Schema::TestrunDB::Result::Queue::BEGIN@10 which was called:
# once (10µs+15µs) by Class::C3::Componentised::ensure_class_loaded at line 10 # spent 25µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::BEGIN@10
# spent 15µs making 1 call to warnings::import |
11 | |||||
12 | 3 | 640µs | 2 | 78µs | # spent 44µs (10+34) within Tapper::Schema::TestrunDB::Result::Queue::BEGIN@12 which was called:
# once (10µs+34µs) by Class::C3::Componentised::ensure_class_loaded at line 12 # spent 44µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::BEGIN@12
# spent 34µs making 1 call to parent::import |
13 | |||||
14 | 1 | 11µs | 1 | 2.27ms | __PACKAGE__->load_components(qw/InflateColumn::DateTime Core/); # spent 2.27ms making 1 call to Class::C3::Componentised::load_components |
15 | 1 | 16µs | 1 | 451µs | __PACKAGE__->table("queue"); # spent 451µs making 1 call to DBIx::Class::ResultSourceProxy::Table::table |
16 | 1 | 33µs | 1 | 1.75ms | __PACKAGE__->add_columns # spent 1.75ms making 1 call to DBIx::Class::ResultSourceProxy::add_columns |
17 | ( | ||||
18 | "id", { data_type => "INT", default_value => undef, is_nullable => 0, size => 11, is_auto_increment => 1, }, | ||||
19 | "name", { data_type => "VARCHAR", default_value => "", is_nullable => 1, size => 255, }, | ||||
20 | "priority", { data_type => "INT", default_value => 0, is_nullable => 0, size => 10, }, | ||||
21 | "runcount", { data_type => "INT", default_value => 0, is_nullable => 0, size => 10, }, # aux for algorithm | ||||
22 | "active", { data_type => "INT", default_value => 0, is_nullable => 1, size => 1, }, | ||||
23 | "is_deleted", { data_type => "TINYINT", default_value => "0", is_nullable => 1, }, # deleted queues need to be kept in db to show old testruns correctly | ||||
24 | "created_at", { data_type => "TIMESTAMP", default_value => \'CURRENT_TIMESTAMP', is_nullable => 1, }, #' emacs highlight bug | ||||
25 | "updated_at", { data_type => "DATETIME", default_value => undef, is_nullable => 1, }, | ||||
26 | ); | ||||
27 | |||||
28 | 1 | 12µs | 1 | 6µs | (my $basepkg = __PACKAGE__) =~ s/::\w+$//; # spent 6µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::CORE:subst |
29 | |||||
30 | 1 | 16µs | 1 | 54µs | __PACKAGE__->set_primary_key("id"); # spent 54µs making 1 call to DBIx::Class::ResultSourceProxy::set_primary_key |
31 | 1 | 16µs | 1 | 32µs | __PACKAGE__->add_unique_constraint( unique_queue_name => [ qw/name/ ], ); # spent 32µs making 1 call to DBIx::Class::ResultSourceProxy::add_unique_constraint |
32 | 1 | 8µs | 1 | 173µs | __PACKAGE__->has_many ( testrunschedulings => 'Tapper::Schema::TestrunDB::Result::TestrunScheduling', { 'foreign.queue_id' => 'self.id' }); # spent 173µs making 1 call to DBIx::Class::Relationship::HasMany::has_many |
33 | 1 | 3µs | 1 | 100µs | __PACKAGE__->has_many ( queuehosts => "${basepkg}::QueueHost", { 'foreign.queue_id' => 'self.id' }); # spent 100µs making 1 call to DBIx::Class::Relationship::HasMany::has_many |
34 | |||||
35 | # -------------------- methods on results -------------------- | ||||
36 | |||||
37 | |||||
38 | sub queued_testruns | ||||
39 | # spent 542ms (8.50+534) within Tapper::Schema::TestrunDB::Result::Queue::queued_testruns which was called 807 times, avg 672µs/call:
# 477 times (5.07ms+405ms) by Tapper::Schema::TestrunDB::Result::Queue::get_first_fitting at line 54, avg 860µs/call
# 330 times (3.43ms+129ms) by Tapper::MCP::Scheduler::Controller::toggle_bandwith_color at line 42 of lib/Tapper/MCP/Scheduler/Controller.pm, avg 400µs/call | ||||
40 | 1614 | 7.71ms | my ($self) = @_; | ||
41 | |||||
42 | 1614 | 534ms | $self->testrunschedulings->search({ # spent 418ms making 807 calls to Tapper::Schema::TestrunDB::Result::Queue::testrunschedulings, avg 518µs/call
# spent 116ms making 807 calls to DBIx::Class::ResultSet::search, avg 143µs/call | ||
43 | status => 'schedule' | ||||
44 | }, | ||||
45 | { | ||||
46 | ordered_by => 'testrun_id' | ||||
47 | }); | ||||
48 | } | ||||
49 | |||||
50 | |||||
51 | sub get_first_fitting | ||||
52 | # spent 8.31s (25.9ms+8.29) within Tapper::Schema::TestrunDB::Result::Queue::get_first_fitting which was called 477 times, avg 17.4ms/call:
# 477 times (25.9ms+8.29s) by Tapper::MCP::Scheduler::Controller::get_next_job at line 95 of lib/Tapper/MCP/Scheduler/Controller.pm, avg 17.4ms/call | ||||
53 | 1761 | 10.5ms | my ($self, $free_hosts) = @_; | ||
54 | 477 | 410ms | my $jobs = $self->queued_testruns; # spent 410ms making 477 calls to Tapper::Schema::TestrunDB::Result::Queue::queued_testruns, avg 860µs/call | ||
55 | 477 | 1.07s | foreach my $job ($jobs->all()) { # spent 1.07s making 477 calls to DBIx::Class::ResultSet::all, avg 2.25ms/call | ||
56 | 738 | 4.91ms | 297 | 6.01s | if (my $host = $job->fits($free_hosts)) { # spent 6.01s making 297 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::fits, avg 20.2ms/call |
57 | 294 | 22.3ms | $job->host_id ($host->id); # spent 20.8ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::host_id, avg 141µs/call
# spent 1.57ms making 147 calls to Tapper::Schema::TestrunDB::Result::Host::id, avg 11µs/call | ||
58 | |||||
59 | 294 | 771ms | if ($job->testrun->scenario_element) { # spent 438ms making 147 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::testrun, avg 2.98ms/call
# spent 333ms making 147 calls to Tapper::Schema::TestrunDB::Result::Testrun::scenario_element, avg 2.27ms/call | ||
60 | $job->testrun->scenario_element->is_fitted(1); | ||||
61 | $job->testrun->scenario_element->update(); | ||||
62 | } | ||||
63 | return $job; | ||||
64 | } | ||||
65 | } | ||||
66 | return; | ||||
67 | } | ||||
68 | |||||
69 | |||||
70 | sub to_string | ||||
71 | { | ||||
72 | my ($self) = @_; | ||||
73 | |||||
74 | my $format = join( $Tapper::Schema::TestrunDB::DELIM, qw/%s %s %s %s %s %s %s %s %s %s %s %s %s %s /, ''); | ||||
75 | sprintf ( | ||||
76 | $format, | ||||
77 | map { | ||||
78 | defined $self->$_ | ||||
79 | ? $self->$_ | ||||
80 | : $Tapper::Schema::TestrunDB::NULL | ||||
81 | } @{$self->result_source->{_ordered_columns} } | ||||
82 | ); | ||||
83 | } | ||||
84 | |||||
85 | |||||
86 | sub is_member | ||||
87 | { | ||||
88 | my ($head, @tail) = @_; | ||||
89 | grep { $head->id eq $_->id } @tail; | ||||
90 | } | ||||
91 | |||||
92 | |||||
93 | sub ordered_preconditions | ||||
94 | { | ||||
95 | my ($self) = @_; | ||||
96 | |||||
97 | my @done = (); | ||||
98 | my %seen = (); | ||||
99 | my @todo = (); | ||||
100 | |||||
101 | @todo = $self->preconditions->search({}, {order_by => 'succession'})->all; | ||||
102 | |||||
103 | while (my $head = shift @todo) | ||||
104 | { | ||||
105 | if ($seen{$head->id}) | ||||
106 | { | ||||
107 | push @done, $head unless is_member($head, @done); | ||||
108 | } | ||||
109 | else | ||||
110 | { | ||||
111 | $seen{$head->id} = 1; | ||||
112 | my @pre_todo = $head->child_preconditions->search({}, { order_by => 'succession' } )->all; | ||||
113 | unshift @todo, @pre_todo, $head; | ||||
114 | } | ||||
115 | } | ||||
116 | return @done; | ||||
117 | } | ||||
118 | |||||
119 | |||||
120 | sub producer | ||||
121 | { | ||||
122 | my ($self) = @_; | ||||
123 | |||||
124 | my $producer_class = "Tapper::MCP::Scheduler::PreconditionProducer::".$self->producer; | ||||
125 | eval "use $producer_class"; ## no critic (ProhibitStringyEval) | ||||
126 | return $producer_class->new unless $@; | ||||
127 | return; | ||||
128 | } | ||||
129 | |||||
130 | |||||
131 | sub produce | ||||
132 | { | ||||
133 | my ($self, $request) = @_; | ||||
134 | |||||
135 | my $producer = $self->producer; | ||||
136 | |||||
137 | if (not $producer) { | ||||
138 | warn "Queue ".$self->name." does not have an associated producer"; | ||||
139 | } else { | ||||
140 | print STDERR "Queue.producer: ", Dumper($producer); | ||||
141 | return $producer->produce($request); | ||||
142 | } | ||||
143 | } | ||||
144 | |||||
145 | |||||
146 | sub update_content { | ||||
147 | my ($self, $args) =@_; | ||||
148 | |||||
149 | $self->priority( $args->{priority} ) if exists($args->{priority}); | ||||
150 | $self->active( $args->{active} ) if exists($args->{active}); | ||||
151 | $self->update; | ||||
152 | return $self->id; | ||||
153 | } | ||||
154 | |||||
155 | 1 | 25µs | 1; | ||
156 | |||||
157 | __END__ | ||||
# spent 6µs within Tapper::Schema::TestrunDB::Result::Queue::CORE:subst which was called:
# once (6µs+0s) by Class::C3::Componentised::ensure_class_loaded at line 28 |