* @param item test method call
* @param testItemDurations list of test item durations
* @return duration bean with max/min/avg in ms
*/
public Duration calculateTestDurationBean(String method, List<TestMethodDuration> testMethodDurations) {
Duration resultBean = new Duration(method);
double total = 0.0;
double min = Double.MAX_VALUE;
double max = Double.MIN_VALUE;
int count = 0;
for (TestMethodDuration testMethodDuration : testMethodDurations) {
double timeInMs = testMethodDuration.getRoundedMsDifference().doubleValue();
//double timeInMs = testMethodDuration.getNanoDifference();
if (timeInMs > max) {
max = timeInMs;
}
if (timeInMs < min) {
min = timeInMs;
}
total += timeInMs;
count++;
}
resultBean.setMin(min != Double.MAX_VALUE ? (int)Math.round(min) : 0);
resultBean.setMax(max != Double.MIN_VALUE ? (int)Math.round(max) : 0);
resultBean.setAvg((int)Math.round(total/count));
resultBean.setCount(count);
return resultBean;
}