Author: pmouawad
Date: Sat May 6 12:58:21 2017
New Revision: 1794137
URL: http://svn.apache.org/viewvc?rev=1794137&view=rev
Log:
Bug 61071 : Bug 61071 - Median calculated incorrectly
Add Test contributed by Aleksei Balan within PR 295
Add another test showing a bug on getPercentPoint()
Bugzilla Id: 61071
Modified:
jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java
Modified: jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java
URL:
http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java?rev=1794137&r1=1794136&r2=1794137&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java
(original)
+++ jmeter/trunk/test/src/org/apache/jorphan/math/TestStatCalculator.java Sat
May 6 12:58:21 2017
@@ -22,7 +22,10 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertTrue;
import java.util.Map;
+
+import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
public class TestStatCalculator {
@@ -37,19 +40,34 @@ public class TestStatCalculator {
@Test
public void testPercentagePoint() throws Exception {
- calc.addValue(10);
- calc.addValue(9);
- calc.addValue(5);
- calc.addValue(6);
- calc.addValue(1);
- calc.addValue(3);
- calc.addValue(8);
- calc.addValue(2);
- calc.addValue(7);
- calc.addValue(4);
+ long values[] = new long[] {
+ 10L,9L,5L,6L,1L,3L,8L,2L,7L,4L
+ };
+ for (long l : values) {
+ calc.addValue(l);
+ }
assertEquals(10, calc.getCount());
assertEquals(9, calc.getPercentPoint(0.8999999).intValue());
}
+
+ @Test
+ @Ignore
+ // Disabled due to in progress Bug 61071
+ public void testPercentagePointBug() throws Exception {
+ long values[] = new long[] {
+ 10L,9L,5L,6L,1L,3L,8L,2L,7L,4L
+ };
+ DescriptiveStatistics statistics = new DescriptiveStatistics();
+ for (long l : values) {
+ calc.addValue(l);
+ statistics.addValue(l);
+ }
+ assertEquals(9, calc.getPercentPoint(0.8999999).intValue());
+ //
+ assertEquals(Math.round(statistics.getPercentile(90)),
+ calc.getPercentPoint(0.9).intValue());
+ }
+
@Test
public void testCalculation() {
assertEquals(Long.MIN_VALUE, calc.getMax().longValue());
@@ -70,6 +88,23 @@ public class TestStatCalculator {
assertEquals(3, calc.getMin().intValue());
assertEquals(15, calc.getMedian().intValue());
}
+
+ @Test
+ @Ignore
+ // Disabled due to in progress Bug 61071
+ public void testMedianBug61071() {
+ long[] values = new long[] {
+ 10L, 20L, 30L, 40L, 50L, 60L, 80L, 90L
+ };
+ DescriptiveStatistics statistics = new DescriptiveStatistics();
+
+ for (long l : values) {
+ calc.addValue(l);
+ statistics.addValue(l);
+ }
+ assertEquals((int) statistics.getPercentile(50),
calc.getMedian().intValue());
+ }
+
@Test
public void testLong(){
calc.addValue(0L);