line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Loop::Sustainable::Strategy::ByLoad; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1145
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
76
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
5
|
2
|
|
|
2
|
|
1948
|
use parent qw(Loop::Sustainable::Strategy); |
|
2
|
|
|
|
|
688
|
|
|
2
|
|
|
|
|
12
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Class::Accessor::Lite ( |
8
|
2
|
|
|
|
|
11
|
new => 0, |
9
|
|
|
|
|
|
|
rw => [qw/load/], |
10
|
2
|
|
|
2
|
|
123
|
); |
|
2
|
|
|
|
|
5
|
|
11
|
2
|
|
|
2
|
|
120
|
use List::Util qw(max); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
529
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
4
|
|
|
4
|
1
|
2678
|
my $class = shift; |
17
|
4
|
|
|
|
|
22
|
my $self = $class->SUPER::new( @_ ); |
18
|
4
|
50
|
|
|
|
16
|
$self->{load} = 0.5 unless (defined $self->{load}); |
19
|
4
|
|
|
|
|
10
|
$self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub wait_correction { |
23
|
8
|
|
|
8
|
1
|
2023
|
my ( $self, $i, $elapsed, $rv ) = @_; |
24
|
8
|
|
|
|
|
62
|
return ( max( $elapsed, 0 ) * ( 1 - $self->{load} ) / $self->{load} ) / $self->check_strategy_interval; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__END__ |