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

fixed building the test method idendifier

parent a537e535
No related branches found
No related tags found
No related merge requests found
...@@ -7,4 +7,7 @@ public class MeasurementRepository { ...@@ -7,4 +7,7 @@ public class MeasurementRepository {
public final Map<String, PerformanceResult> performanceResults = new HashMap<String, PerformanceResult>(); public final Map<String, PerformanceResult> performanceResults = new HashMap<String, PerformanceResult>();
public static final String buildTestMethodIdentifier(final Class<?> testClass, final String methodName) {
return testClass.getName() + "(" + methodName + ")";
}
} }
...@@ -48,8 +48,11 @@ public abstract class PerformanceTest { ...@@ -48,8 +48,11 @@ public abstract class PerformanceTest {
@After @After
public void after() { public void after() {
String testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(description.getTestClass(), description.getMethodName());
PerformanceResult performanceResult = StatisticsUtil.computeStatistics(this.stopWatch.getDurationInNs(), this.timestampObjects); PerformanceResult performanceResult = StatisticsUtil.computeStatistics(this.stopWatch.getDurationInNs(), this.timestampObjects);
measurementRepository.performanceResults.put(this.description.getDisplayName(), performanceResult); measurementRepository.performanceResults.put(testMethodIdentifier, performanceResult);
addToRepository(performanceResult);
System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(performanceResult.overallDurationInNs) + " ms"); System.out.println("Duration: " + TimeUnit.NANOSECONDS.toMillis(performanceResult.overallDurationInNs) + " ms");
System.out.println("avg duration: " + TimeUnit.NANOSECONDS.toMicros(performanceResult.avgDurInNs) + " µs"); System.out.println("avg duration: " + TimeUnit.NANOSECONDS.toMicros(performanceResult.avgDurInNs) + " µs");
...@@ -59,4 +62,9 @@ public abstract class PerformanceTest { ...@@ -59,4 +62,9 @@ public abstract class PerformanceTest {
+ TimeUnit.NANOSECONDS.toMicros(performanceResult.avgDurInNs + performanceResult.confidenceWidthInNs) + " µs]"); + TimeUnit.NANOSECONDS.toMicros(performanceResult.avgDurInNs + performanceResult.confidenceWidthInNs) + " µs]");
} }
@Deprecated
private void addToRepository(final PerformanceResult performanceResult) {
measurementRepository.performanceResults.put(this.description.getDisplayName(), performanceResult);
}
} }
...@@ -5,8 +5,4 @@ public abstract class ProfiledPerformanceAssertion { ...@@ -5,8 +5,4 @@ public abstract class ProfiledPerformanceAssertion {
public abstract String getCorrespondingPerformanceProfile(); public abstract String getCorrespondingPerformanceProfile();
public abstract void check(); public abstract void check();
protected String buildTestMethodIdentifier(final Class<? extends PerformanceTest> testClass, final String methodName) {
return testClass.getName() + "(" + methodName + ")";
}
} }
...@@ -2,6 +2,7 @@ package teetime.examples.experiment14; ...@@ -2,6 +2,7 @@ package teetime.examples.experiment14;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test; import teetime.examples.experiment01.MethodCallThoughputTimestampAnalysis1Test;
import util.test.MeasurementRepository;
import util.test.PerformanceResult; import util.test.PerformanceResult;
import util.test.PerformanceTest; import util.test.PerformanceTest;
import util.test.ProfiledPerformanceAssertion; import util.test.ProfiledPerformanceAssertion;
...@@ -15,10 +16,10 @@ public class ChwWorkPerformanceCheck extends ProfiledPerformanceAssertion { ...@@ -15,10 +16,10 @@ public class ChwWorkPerformanceCheck extends ProfiledPerformanceAssertion {
@Override @Override
public void check() { public void check() {
PerformanceResult test01 = PerformanceTest.measurementRepository.performanceResults String testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis1Test.class, "testWithManyObjects");
.get(buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis1Test.class, "testWithManyObjects")); PerformanceResult test01 = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
PerformanceResult test14 = PerformanceTest.measurementRepository.performanceResults testMethodIdentifier = MeasurementRepository.buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis14Test.class, "testWithManyObjects");
.get(buildTestMethodIdentifier(MethodCallThoughputTimestampAnalysis14Test.class, "testWithManyObjects")); PerformanceResult test14 = PerformanceTest.measurementRepository.performanceResults.get(testMethodIdentifier);
double medianSpeedup = (double) test14.quantiles.get(0.5) / test01.quantiles.get(0.5); double medianSpeedup = (double) test14.quantiles.get(0.5) / test01.quantiles.get(0.5);
......
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