MCP/Scheduler/Algorithm/WFQ.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 8 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod 25.0% 1 / 4 totaltotal 90.5% 48 / 53 CC 7 SCAR 11.0
CC
7
Cov
98%
lookup_next_queue
5.0
get_virtual_finishing_time
2.0
update_queue
2.0
CRAP 3.0
« MCP/Info.pm ↑ Summary MCP/State/Plugin/Dummy.pm »
1 ## no critic (RequireUseStrict)
2 package Tapper::MCP::Scheduler::Algorithm::WFQ;
3 7 our $AUTHORITY = 'cpan:TAPPER';
4 # ABSTRACT: Scheduling algorithm "Weighted Fair Queueing"
5 7 $Tapper::MCP::Scheduler::Algorithm::WFQ::VERSION = '5.0.9';
6 7 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 7 ▶ use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 35 ▶ sub get_virtual_finishing_time {
Subroutine get_virtual_finishing_time: called CC=2 SCAR=7.1
Pod documented
10 35 my ($self, $queue) = @_;
11  
12 35 ▶ my $prio = $queue->priority || 1;
Condition50%1/2
$queue->priority || 1
l!l
350
MC/DC0%0/1
$queue->priority || 1
$queue->priority
Truth table50%1/2
A
A= $queue->priority
Aresult
11
00
13 35 return ($queue->runcount + 1.0) / $prio;
14 }
15  
16  
17 14 ▶ sub lookup_next_queue {
Subroutine lookup_next_queue: called CC=5 SCAR=16.1
Pod undocumented
18 14 my ($self, $queues) = @_;
19  
20 14 my $vft;
21 my $queue;
22  
23 14 foreach my $q (values %$queues)
24 {
25 41 my $this_vft;
26 41 ▶ next if not $q->priority;
Branch: 1 branch
BranchTrueFalseTotal
unless $q->priority 6 35 41
27  
28 35 $this_vft = $self->get_virtual_finishing_time($q);
29  
30 35 ▶ if (not defined $vft)
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $vft) { } 14 21 35
elsif ($vft > $this_vft) { } 6 15 21
31 {
32 14 $vft = $this_vft;
33 14 $queue = $q;
34 }
35 elsif ($vft > $this_vft)
36 {
37 6 $vft = $this_vft;
38 6 $queue = $q;
39 }
40 }
41 14 return $queue;
42 }
43  
44  
45  
46 sub get_next_queue
47 6 ▶ {
Subroutine get_next_queue: called CC=1 SCAR=0.0
Pod undocumented
48 6 my ($self, $queues) = @_;
49  
50 6 my $vft;
51 6 my $queue = $self->lookup_next_queue( $queues);
52 6 $self->update_queue($queue);
53 6 return $queue;
54 }
55  
56 7 ▶ sub update_queue {
Subroutine update_queue: called CC=2 SCAR=6.9
Pod undocumented
57 7 my ($self, $q) = @_;
58 7 $q->runcount ( $q->runcount + 1 );
59 7 ▶ if ($q->can('update')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($q->can("update")) 1 6 7
60 1 $q->update;
61 }
62 }
63  
64 7 1;
65  
66 __END__
« MCP/Info.pm ↑ Summary MCP/State/Plugin/Dummy.pm »