Skip to content

Commit

Permalink
Added the trivial recovery to the performance test (#23).
Browse files Browse the repository at this point in the history
  • Loading branch information
HansMartinA committed Aug 2, 2023
1 parent e269a38 commit 1e06e87
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class PerformanceDataPoint {
private long parseTime;
private long resolutionTime;
private long recoverTime;

public long getParseTime() {
return parseTime;
Expand All @@ -35,4 +36,12 @@ public long getResolutionTime() {
public void setResolutionTime(long resolutionTime) {
this.resolutionTime = resolutionTime;
}

public long getRecoverTime() {
return recoverTime;
}

public void setRecoverTime(long recoverTime) {
this.recoverTime = recoverTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import tools.mdsd.jamopp.options.ParserOptions;
import tools.mdsd.jamopp.parser.jdt.singlefile.JaMoPPJDTSingleFileParser;
import tools.mdsd.jamopp.recovery.trivial.TrivialRecovery;
import tools.mdsd.jamopp.resource.JavaResource2;
import tools.mdsd.jamopp.test.AbstractJaMoPPTests;
import tools.mdsd.jamopp.test.OutputUtility;
Expand Down Expand Up @@ -84,7 +85,7 @@ public void measureTeaStoreFullResolution() {
ParserOptions.RESOLVE_BINDINGS_OF_INFERABLE_TYPES.setValue(Boolean.TRUE);
ParserOptions.RESOLVE_EVERYTHING.setValue(Boolean.TRUE);
ParserOptions.RESOLVE_ALL_BINDINGS.setValue(Boolean.TRUE);
measurePerformance("teastore-full-resolution", 100, true);
measurePerformance("teastore-full-resolution", 100, true, false);
}

@Test
Expand All @@ -96,31 +97,53 @@ public void measureTeaStoreWithoutResolvingEverything() {
ParserOptions.RESOLVE_BINDINGS_OF_INFERABLE_TYPES.setValue(Boolean.TRUE);
ParserOptions.RESOLVE_EVERYTHING.setValue(Boolean.FALSE);
ParserOptions.RESOLVE_ALL_BINDINGS.setValue(Boolean.TRUE);
measurePerformance("teastore-without-resolving-everything", 100, true);
measurePerformance("teastore-without-resolving-everything", 100, true, false);
}

@Test
public void measureTeaStoreWithOneLevelResolution() {
private void prepareParserOptionsForOneLevelResolution() {
ParserOptions.CREATE_LAYOUT_INFORMATION.setValue(Boolean.TRUE);
ParserOptions.REGISTER_LOCAL.setValue(Boolean.TRUE);
ParserOptions.PREFER_BINDING_CONVERSION.setValue(Boolean.TRUE);
ParserOptions.RESOLVE_BINDINGS.setValue(Boolean.TRUE);
ParserOptions.RESOLVE_BINDINGS_OF_INFERABLE_TYPES.setValue(Boolean.TRUE);
ParserOptions.RESOLVE_EVERYTHING.setValue(Boolean.FALSE);
ParserOptions.RESOLVE_ALL_BINDINGS.setValue(Boolean.FALSE);
measurePerformance("teastore-one-level-resolution", 100, false);
}

@Test
public void measureTeaStoreSecondVariant() {
public void measureTeaStoreWithOneLevelResolution() {
prepareParserOptionsForOneLevelResolution();
measurePerformance("teastore-one-level-resolution", 100, false, true);
}

@Disabled("Takes several hours.")
@Test
public void measureTeaStoreWithOneLevelResolutionAndFullResolution() {
prepareParserOptionsForOneLevelResolution();
measurePerformance("teastore-one-level-resolution-full", 1, true, false);
}

private void prepareParserOptionsForSecondVariant() {
ParserOptions.CREATE_LAYOUT_INFORMATION.setValue(Boolean.TRUE);
ParserOptions.REGISTER_LOCAL.setValue(Boolean.TRUE);
ParserOptions.PREFER_BINDING_CONVERSION.setValue(Boolean.TRUE);
ParserOptions.RESOLVE_BINDINGS.setValue(Boolean.FALSE);
ParserOptions.RESOLVE_BINDINGS_OF_INFERABLE_TYPES.setValue(Boolean.FALSE);
ParserOptions.RESOLVE_EVERYTHING.setValue(Boolean.FALSE);
ParserOptions.RESOLVE_ALL_BINDINGS.setValue(Boolean.FALSE);
measurePerformance("teastore-second-variant", 100, false);
}

@Test
public void measureTeaStoreSecondVariant() {
prepareParserOptionsForSecondVariant();
measurePerformance("teastore-second-variant", 1, false, true);
}

@Disabled("Takes several hours.")
@Test
public void measureTeaStoreSecondVariantAndFullResolution() {
prepareParserOptionsForSecondVariant();
measurePerformance("teastore-second-variant-resolution", 1, true, false);
}

@Test
Expand Down Expand Up @@ -159,7 +182,7 @@ protected String getTestInputFolder() {
return inputFolder;
}

private void measurePerformance(String name, int max, boolean fullResolution) {
private void measurePerformance(String name, int max, boolean fullResolution, boolean recover) {
String testInput = getTestInputFolder();
LOGGER.debug("Executing performance measurements for " + name);
Path target = Paths.get(testInput);
Expand All @@ -175,6 +198,7 @@ private void measurePerformance(String name, int max, boolean fullResolution) {
}
int actualMax = Math.min(max, max - result.getPoints().size());
for (int i = 0; i < actualMax; i++) {
System.out.println("Measurement " + i + " for " + name);
PerformanceDataPoint point = new PerformanceDataPoint();
long millis = System.currentTimeMillis();
ResourceSet set = parser.parseDirectory(target);
Expand All @@ -193,6 +217,14 @@ private void measurePerformance(String name, int max, boolean fullResolution) {
millis = System.currentTimeMillis() - millis;
}
point.setResolutionTime(millis);

if (recover) {
millis = System.currentTimeMillis();
new TrivialRecovery(set).recover();
millis = System.currentTimeMillis() - millis;
point.setRecoverTime(millis);
}

Set<Resource> parsedFiles = new HashSet<>(set.getResources());
LOGGER.debug("Asserting the resolution of all proxy objects.");
for (Resource res : parsedFiles) {
Expand All @@ -219,7 +251,7 @@ private void measurePerformance(String name, int max, boolean fullResolution) {
result.addPoint(point);
PerformanceData.save(result, outputMeasurement);

if (i == 0 && fullResolution) {
if (i == 0 && (fullResolution || recover)) {
try {
result.setStorage(measureStorage(set));
} catch (IOException e) {
Expand Down

0 comments on commit 1e06e87

Please sign in to comment.