INT-1496: start optimistically with success rate 100%
This commit is contained in:
@@ -92,7 +92,8 @@ public class ExponentialMovingAverageRatio {
|
||||
public double getMean() {
|
||||
int count = cumulative.getCount();
|
||||
if (count == 0) {
|
||||
return 0;
|
||||
// Optimistic to start: success rate is 100%
|
||||
return 1;
|
||||
}
|
||||
long t = System.currentTimeMillis();
|
||||
double alpha = Math.exp((t0 - t) * lapse);
|
||||
|
||||
@@ -45,14 +45,14 @@ public class ExponentialMovingAverageRatioTests {
|
||||
|
||||
@Test
|
||||
public void testGetEarlyMean() throws Exception {
|
||||
assertEquals(0, history.getMean(), 0.01);
|
||||
assertEquals(1, history.getMean(), 0.01);
|
||||
history.success();
|
||||
assertEquals(1, history.getMean(), 0.01);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEarlyFailure() throws Exception {
|
||||
assertEquals(0, history.getMean(), 0.01);
|
||||
assertEquals(1, history.getMean(), 0.01);
|
||||
history.failure();
|
||||
assertEquals(0, history.getMean(), 0.01);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class ExponentialMovingAverageRatioTests {
|
||||
|
||||
@Test
|
||||
public void testGetMean() throws Exception {
|
||||
assertEquals(0, history.getMean(), 0.01);
|
||||
assertEquals(1, history.getMean(), 0.01);
|
||||
history.success();
|
||||
assertEquals(1, history.getMean(), 0.01);
|
||||
history.success();
|
||||
@@ -77,7 +77,7 @@ public class ExponentialMovingAverageRatioTests {
|
||||
|
||||
@Test
|
||||
public void testGetMeanFailuresHighRate() throws Exception {
|
||||
assertEquals(0, history.getMean(), 0.01);
|
||||
assertEquals(1, history.getMean(), 0.01);
|
||||
history.success();
|
||||
assertEquals(average(1), history.getMean(), 0.01);
|
||||
history.failure();
|
||||
@@ -88,7 +88,7 @@ public class ExponentialMovingAverageRatioTests {
|
||||
|
||||
@Test
|
||||
public void testGetMeanFailuresLowRate() throws Exception {
|
||||
assertEquals(0, history.getMean(), 0.01);
|
||||
assertEquals(1, history.getMean(), 0.01);
|
||||
history.failure();
|
||||
assertEquals(average(0), history.getMean(), 0.01);
|
||||
history.failure();
|
||||
|
||||
Reference in New Issue
Block a user