de.dagere.kopeme.measuresummarizing.MedianSummarizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kopeme-core Show documentation
Show all versions of kopeme-core Show documentation
KoPeMe performance testing core
package de.dagere.kopeme.measuresummarizing;
import java.util.Arrays;
import java.util.List;
public class MedianSummarizer implements MeasureSummarizer {
/**
* Returns the median of the List of measures
* @return median of the liste of measures
*/
@Override
public long getValue(List values) {
Long longarray[] = values.toArray(new Long[0]);
Arrays.sort(longarray);
int middle = ((longarray.length) / 2);
long median;
if (longarray.length % 2 == 0) {
long medianA = longarray[middle];
long medianB = longarray[middle - 1];
median = (medianA + medianB) / 2;
} else {
median = longarray[middle + 1];
}
return median;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy