Skip to content
Snippets Groups Projects
Commit 0009f91d authored by Christian Wulf's avatar Christian Wulf
Browse files

refactored performance test

parent 1e8ef0b1
No related branches found
No related tags found
No related merge requests found
package teetime.examples.experiment16; package teetime.examples.experiment16;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import util.test.AbstractProfiledPerformanceAssertion;
import util.test.PerformanceResult; import util.test.PerformanceResult;
import util.test.PerformanceTest; import util.test.PerformanceTest;
import util.test.AbstractProfiledPerformanceAssertion;
class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion { class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion {
...@@ -15,22 +15,25 @@ class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion { ...@@ -15,22 +15,25 @@ class ChwHomePerformanceCheck extends AbstractProfiledPerformanceAssertion {
@Override @Override
public void check() { public void check() {
PerformanceResult test16a = PerformanceTest.measurementRepository.performanceResults PerformanceResult test16a = PerformanceTest.measurementRepository.performanceResults
.get("testWithManyObjectsAnd1Thread(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)"); .get("testWithManyObjectsAnd1Thread(" + MethodCallThoughputTimestampAnalysis16Test.class.getName() + ")");
PerformanceResult test16b = PerformanceTest.measurementRepository.performanceResults PerformanceResult test16b = PerformanceTest.measurementRepository.performanceResults
.get("testWithManyObjectsAnd2Threads(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)"); .get("testWithManyObjectsAnd2Threads(" + MethodCallThoughputTimestampAnalysis16Test.class.getName() + ")");
PerformanceResult test16c = PerformanceTest.measurementRepository.performanceResults PerformanceResult test16c = PerformanceTest.measurementRepository.performanceResults
.get("testWithManyObjectsAnd4Threads(teetime.examples.experiment16.MethodCallThoughputTimestampAnalysis16Test)"); .get("testWithManyObjectsAnd4Threads(" + MethodCallThoughputTimestampAnalysis16Test.class.getName() + ")");
// check speedup // check speedup
double speedupB = (double) test16a.overallDurationInNs / test16b.overallDurationInNs; double speedupB = (double) test16a.overallDurationInNs / test16b.overallDurationInNs;
double speedupC = (double) test16a.overallDurationInNs / test16c.overallDurationInNs; double speedupC = (double) test16a.overallDurationInNs / test16c.overallDurationInNs;
System.out.println("speedupB: " + speedupB); System.out.println(ChwHomePerformanceCheck.class.getName() + ", speedupB: " + speedupB);
System.out.println("speedupC: " + speedupC); System.out.println(ChwHomePerformanceCheck.class.getName() + ", speedupC: " + speedupC);
assertEquals(2, speedupB, 0.3); // assertEquals(2, speedupB, 0.3);
// since 31.08.2014 (incl.) // since 31.08.2014 (incl.)
// assertEquals(3.6, speedupC, 0.3); // assertEquals(3.6, speedupC, 0.3);
// since 04.11.2014 (incl.) // since 04.11.2014 (incl.)
assertEquals(5, speedupC, 0.3); // assertEquals(5, speedupC, 0.4);
// since 07.12.2014 (incl.)
assertEquals(2, speedupB, 0.4);
assertEquals(5, speedupC, 0.4);
} }
} }
...@@ -24,19 +24,31 @@ import org.junit.runners.MethodSorters; ...@@ -24,19 +24,31 @@ import org.junit.runners.MethodSorters;
import teetime.util.ConstructorClosure; import teetime.util.ConstructorClosure;
import teetime.util.ListUtil; import teetime.util.ListUtil;
import teetime.util.TimestampObject; import teetime.util.TimestampObject;
import util.test.AbstractProfiledPerformanceAssertion;
import util.test.PerformanceCheckProfileRepository; import util.test.PerformanceCheckProfileRepository;
import util.test.PerformanceTest; import util.test.PerformanceTest;
import util.test.AbstractProfiledPerformanceAssertion;
/** /**
* @author Christian Wulf * @author Christian Wulf
* *
* @since 1.10 * @since 1.0
*/ */
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
// @RunWith(Parameterized.class)
public class MethodCallThoughputTimestampAnalysis16Test extends PerformanceTest { public class MethodCallThoughputTimestampAnalysis16Test extends PerformanceTest {
// TODO use @Parameter for the number of threads // private final int numThreads;
//
// @Parameters
// public static Iterable<Object[]> data() {
// return Arrays.asList(new Object[][] {
// { 1 }, { 2 }, { 4 }
// });
// }
//
// public MethodCallThoughputTimestampAnalysis16Test(final int numThreads) {
// this.numThreads = numThreads;
// }
@BeforeClass @BeforeClass
public static void beforeClass() { public static void beforeClass() {
...@@ -52,17 +64,17 @@ public class MethodCallThoughputTimestampAnalysis16Test extends PerformanceTest ...@@ -52,17 +64,17 @@ public class MethodCallThoughputTimestampAnalysis16Test extends PerformanceTest
@Test @Test
public void testWithManyObjectsAnd1Thread() { public void testWithManyObjectsAnd1Thread() {
this.performAnalysis(1); performAnalysis(1);
} }
@Test @Test
public void testWithManyObjectsAnd2Threads() { public void testWithManyObjectsAnd2Threads() {
this.performAnalysis(2); performAnalysis(2);
} }
@Test @Test
public void testWithManyObjectsAnd4Threads() { public void testWithManyObjectsAnd4Threads() {
this.performAnalysis(4); performAnalysis(4);
} }
private void performAnalysis(final int numThreads) { private void performAnalysis(final int numThreads) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment