Don't count empty ones.

This commit is contained in:
asofold 2014-07-18 02:25:38 +02:00
parent 27d35c1208
commit 4ee4e6f08d

View File

@ -69,10 +69,16 @@ public class MorePackets extends Check {
final float burnScore = (float) idealPackets * (float) data.morePacketsFreq.bucketDuration() / 1000f; final float burnScore = (float) idealPackets * (float) data.morePacketsFreq.bucketDuration() / 1000f;
// Find index. // Find index.
int i; int i;
int empty = 0;
boolean used = false; boolean used = false;
for (i = 1; i < data.morePacketsFreq.numberOfBuckets(); i++) { for (i = 1; i < data.morePacketsFreq.numberOfBuckets(); i++) {
if (data.morePacketsFreq.bucketScore(i) > 0f) { if (data.morePacketsFreq.bucketScore(i) > 0f) {
if (used) { if (used) {
for (int j = i; j < data.morePacketsFreq.numberOfBuckets(); j ++) {
if (data.morePacketsFreq.bucketScore(j) == 0f) {
empty += 1;
}
}
break; break;
} else { } else {
used = true; used = true;
@ -82,7 +88,7 @@ public class MorePackets extends Check {
final double fullCount; final double fullCount;
if (i < data.morePacketsFreq.numberOfBuckets()) { if (i < data.morePacketsFreq.numberOfBuckets()) {
// Assume all following time windows are burnt. // Assume all following time windows are burnt.
final float trailing = Math.max(data.morePacketsFreq.trailingScore(i, 1f), burnScore * (data.morePacketsFreq.numberOfBuckets() - i)); final float trailing = Math.max(data.morePacketsFreq.trailingScore(i, 1f), burnScore * (data.morePacketsFreq.numberOfBuckets() - i - empty));
final float leading = data.morePacketsFreq.leadingScore(i, 1f); final float leading = data.morePacketsFreq.leadingScore(i, 1f);
fullCount = leading + trailing; fullCount = leading + trailing;
} else { } else {