← 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:54 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Tapper/Schema/TestrunDB/Result/Queue.pm
StatementsExecuted 4134 statements in 24.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
4771125.9ms8.31sTapper::Schema::TestrunDB::Result::Queue::::get_first_fittingTapper::Schema::TestrunDB::Result::Queue::get_first_fitting
807228.50ms542msTapper::Schema::TestrunDB::Result::Queue::::queued_testrunsTapper::Schema::TestrunDB::Result::Queue::queued_testruns
11110µs25µsTapper::Schema::TestrunDB::Result::Queue::::BEGIN@10Tapper::Schema::TestrunDB::Result::Queue::BEGIN@10
11110µs10µsTapper::Schema::TestrunDB::Result::Queue::::BEGIN@2Tapper::Schema::TestrunDB::Result::Queue::BEGIN@2
11110µs44µsTapper::Schema::TestrunDB::Result::Queue::::BEGIN@12Tapper::Schema::TestrunDB::Result::Queue::BEGIN@12
1118µs13µsTapper::Schema::TestrunDB::Result::Queue::::BEGIN@9Tapper::Schema::TestrunDB::Result::Queue::BEGIN@9
1116µs6µsTapper::Schema::TestrunDB::Result::Queue::::CORE:substTapper::Schema::TestrunDB::Result::Queue::CORE:subst (opcode)
0000s0sTapper::Schema::TestrunDB::Result::Queue::::is_memberTapper::Schema::TestrunDB::Result::Queue::is_member
0000s0sTapper::Schema::TestrunDB::Result::Queue::::ordered_preconditionsTapper::Schema::TestrunDB::Result::Queue::ordered_preconditions
0000s0sTapper::Schema::TestrunDB::Result::Queue::::produceTapper::Schema::TestrunDB::Result::Queue::produce
0000s0sTapper::Schema::TestrunDB::Result::Queue::::producerTapper::Schema::TestrunDB::Result::Queue::producer
0000s0sTapper::Schema::TestrunDB::Result::Queue::::to_stringTapper::Schema::TestrunDB::Result::Queue::to_string
0000s0sTapper::Schema::TestrunDB::Result::Queue::::update_contentTapper::Schema::TestrunDB::Result::Queue::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::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
BEGIN {
314µs $Tapper::Schema::TestrunDB::Result::Queue::AUTHORITY = 'cpan:AMD';
4124µs110µs}
5{
621µs $Tapper::Schema::TestrunDB::Result::Queue::VERSION = '0.001';
7}
8
9320µs218µ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
use strict;
# spent 13µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::BEGIN@9 # spent 5µs making 1 call to strict::import
10325µs240µ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
use warnings;
# spent 25µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::BEGIN@10 # spent 15µs making 1 call to warnings::import
11
123640µs278µ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
use parent 'DBIx::Class';
# spent 44µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::BEGIN@12 # spent 34µs making 1 call to parent::import
13
14111µs12.27ms__PACKAGE__->load_components(qw/InflateColumn::DateTime Core/);
# spent 2.27ms making 1 call to Class::C3::Componentised::load_components
15116µs1451µs__PACKAGE__->table("queue");
# spent 451µs making 1 call to DBIx::Class::ResultSourceProxy::Table::table
16133µs11.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
28112µs16µs(my $basepkg = __PACKAGE__) =~ s/::\w+$//;
29
30116µs154µs__PACKAGE__->set_primary_key("id");
31116µs132µs__PACKAGE__->add_unique_constraint( unique_queue_name => [ qw/name/ ], );
3218µs1173µ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
3313µs1100µ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
38sub 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
{
40807451µs my ($self) = @_;
41
428077.26ms1614534ms $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
51sub 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
{
53477310µs my ($self, $free_hosts) = @_;
544773.81ms477410ms my $jobs = $self->queued_testruns;
# spent 410ms making 477 calls to Tapper::Schema::TestrunDB::Result::Queue::queued_testruns, avg 860µs/call
554773.81ms4771.07s foreach my $job ($jobs->all()) {
# spent 1.07s making 477 calls to DBIx::Class::ResultSet::all, avg 2.25ms/call
562971.39ms2976.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
57147986µs29422.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
59147837µs294771ms 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 }
631471.70ms return $job;
64 }
65 }
663302.56ms return;
67}
68
69
70sub 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
86sub is_member
87{
88 my ($head, @tail) = @_;
89 grep { $head->id eq $_->id } @tail;
90}
91
92
93sub 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
120sub 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
131sub 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
146sub 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
155125µs1;
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
sub Tapper::Schema::TestrunDB::Result::Queue::CORE:subst; # opcode