protected void determineTotalsAndAverages() {
failureCount = 0;
boolean firstNonFailure = true;
totalScore = null;
totalWinningScoreDifference = null;
ScoreDifferencePercentage totalWorstScoreDifferencePercentage = null;
long totalAverageCalculateCountPerSecond = 0L;
long totalTimeMillisSpent = 0L;
for (SingleBenchmarkResult singleBenchmarkResult : singleBenchmarkResultList) {
if (singleBenchmarkResult.isFailure()) {
failureCount++;
} else {
if (firstNonFailure) {
totalScore = singleBenchmarkResult.getScore();
totalWinningScoreDifference = singleBenchmarkResult.getWinningScoreDifference();
totalWorstScoreDifferencePercentage = singleBenchmarkResult.getWorstScoreDifferencePercentage();
totalAverageCalculateCountPerSecond = singleBenchmarkResult.getAverageCalculateCountPerSecond();
totalTimeMillisSpent = singleBenchmarkResult.getTimeMillisSpent();
firstNonFailure = false;
} else {
totalScore = totalScore.add(singleBenchmarkResult.getScore());
totalWinningScoreDifference = totalWinningScoreDifference.add(
singleBenchmarkResult.getWinningScoreDifference());
totalWorstScoreDifferencePercentage = totalWorstScoreDifferencePercentage.add(
singleBenchmarkResult.getWorstScoreDifferencePercentage());
totalAverageCalculateCountPerSecond += singleBenchmarkResult.getAverageCalculateCountPerSecond();
totalTimeMillisSpent += singleBenchmarkResult.getTimeMillisSpent();
}
}
}
if (!firstNonFailure) {
int successCount = getSuccessCount();
averageScore = totalScore.divide(successCount);
averageWorstScoreDifferencePercentage = totalWorstScoreDifferencePercentage.divide((double) successCount);
averageAverageCalculateCountPerSecond = totalAverageCalculateCountPerSecond / (long) successCount;
averageTimeMillisSpent = totalTimeMillisSpent / (long) successCount;
}
}