Skip to content

Commit

Permalink
Merge pull request #130 from oskopek/PLANNER-409
Browse files Browse the repository at this point in the history
PLANNER-409: Name benchmark directories uniquely + test
  • Loading branch information
ge0ffrey committed Aug 21, 2015
2 parents f1ea78a + 7863b71 commit 196f966
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,23 @@ public void initBenchmarkReportDirectory(File benchmarkDirectory) {
if (StringUtils.isEmpty(name)) {
name = timestamp;
}
benchmarkReportDirectory = new File(benchmarkDirectory,
BooleanUtils.isFalse(aggregation) ? timestamp : timestamp + "_aggregation");
boolean benchmarkReportDirectoryAdded = benchmarkReportDirectory.mkdirs();
if (!benchmarkReportDirectoryAdded) {
throw new IllegalArgumentException("The benchmarkReportDirectory (" + benchmarkReportDirectory
+ ") creation failed. It probably already exists.");
if (!benchmarkDirectory.mkdirs()) {
if (!benchmarkDirectory.isDirectory()) {
throw new IllegalArgumentException("The benchmarkDirectory (" + benchmarkDirectory
+ ") already exists, but is not a directory.");
}
if (!benchmarkDirectory.canWrite()) {
throw new IllegalArgumentException("The benchmarkDirectory (" + benchmarkDirectory
+ ") already exists, but is not writable.");
}
}
int duplicationIndex = 0;
do {
String directoryName = timestamp + (duplicationIndex == 0 ? "" : "_" + duplicationIndex);
duplicationIndex++;
benchmarkReportDirectory = new File(benchmarkDirectory,
BooleanUtils.isFalse(aggregation) ? directoryName : directoryName + "_aggregation");
} while (!benchmarkReportDirectory.mkdir());
for (ProblemBenchmarkResult problemBenchmarkResult : unifiedProblemBenchmarkResultList) {
problemBenchmarkResult.makeDirs(benchmarkReportDirectory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.io.File;

import org.junit.Test;
import org.optaplanner.benchmark.api.PlannerBenchmarkFactory;
import org.optaplanner.benchmark.impl.PlannerBenchmarkRunner;
import org.optaplanner.examples.common.app.PlannerBenchmarkTest;

public class NQueensBenchmarkTest extends PlannerBenchmarkTest {
Expand All @@ -37,4 +39,13 @@ public void benchmark64queens() {
runBenchmarkTest(new File("data/nqueens/unsolved/64queens.xml"));
}

@Test
public void benchmarkDirectoryNameDuplication() {
PlannerBenchmarkFactory plannerBenchmarkFactory = buildPlannerBenchmarkFactory(new File("data/nqueens/unsolved/4queens.xml"));
PlannerBenchmarkRunner plannerBenchmarkRunner = (PlannerBenchmarkRunner) plannerBenchmarkFactory.buildPlannerBenchmark();
plannerBenchmarkRunner.benchmarkingStarted();
plannerBenchmarkRunner.getPlannerBenchmarkResult().initBenchmarkReportDirectory(plannerBenchmarkFactory.getPlannerBenchmarkConfig().getBenchmarkDirectory());
plannerBenchmarkRunner.getPlannerBenchmarkResult().initBenchmarkReportDirectory(plannerBenchmarkFactory.getPlannerBenchmarkConfig().getBenchmarkDirectory());
}

}

0 comments on commit 196f966

Please sign in to comment.