Permalink
Browse files

- adding feature allowing experiments to start from a particular prog…

…ram number
  • Loading branch information...
1 parent 3566079 commit 4630d96c4249f2b2c0080e0a22997c3051fe9cb7 @ajosephau committed Apr 4, 2015
@@ -19,10 +19,12 @@ timeout=60000
console_results_header=program file size
tab_delimited_file_results_header=program file size
+# starting_program - the program number to start for tests or scenarios
+starting_program=1
+
# ***************************
# Grammar settings
# ***************************
-
# grammar_path - relative or absolute file path to the grammar file for generating programs
grammar_path=tests\\gso_test\\grammars\\java_lejos_superoptimizer_training.g4
@@ -19,6 +19,9 @@ timeout=60000
console_results_header=program file size
tab_delimited_file_results_header=program file size
+# starting_program - the program number to start for tests or scenarios
+starting_program=1
+
# ***************************
# Grammar settings
# ***************************
@@ -51,7 +54,7 @@ test_output_file=LeJOSFnTest.java
test_script_path=tests\\lejos_experiment\\tests\\runLeJOSFnTest.bat
# test_instance_count - number of instances to use for the tests. if the tests require real hardware then this is limited to the number of simulation hardware devices available.
-test_instance_count=8
+test_instance_count=1
# test_results_output_file_path - a path to a file where scenario results will be saved to
test_results_output_file_path=tests\\lejos_experiment\\results\\test_results.txt
@@ -36,6 +36,7 @@
private static String scenarioScriptPath;
private static String log4j_properties_location;
+ private static int startingProgram;
private static int testInstanceCount;
private static int scenarioInstanceCount;
private static int recursionLimit;
@@ -49,6 +50,7 @@ public static void setupParameters(String pathToConfigFile) throws IOException {
grammar_path = properties.getProperty("grammar_path");
consoleResultsHeader = properties.getProperty("console_results_header");
tabDelimitedFileResultsHeader = properties.getProperty("tab_delimited_file_results_header");
+ startingProgram = Integer.parseInt(properties.getProperty("starting_program"));
recursionLimit = Integer.parseInt(properties.getProperty("program_builder_recursion_limit"));
startingRule = properties.getProperty("starting_rule");
programListOutputFilePath = properties.getProperty("program_list_output_file_path");
@@ -66,6 +68,7 @@ public static void setupParameters(String pathToConfigFile) throws IOException {
scenarioScriptPath = properties.getProperty("scenario_script_path");
timeout = Integer.parseInt(properties.getProperty("timeout"));
+ startingProgram = Integer.parseInt(properties.getProperty("starting_program"));
testInstanceCount = Integer.parseInt(properties.getProperty("test_instance_count"));
scenarioInstanceCount = Integer.parseInt(properties.getProperty("scenario_instance_count"));
@@ -86,7 +89,7 @@ public static void runAsSingleProcessStandalone(String inputFile) {
gsoLogger.info("Step 2 of 5: Running tests. Current time: " + new java.util.Date());
ProcessRunnerFactory testRunners = new ProcessRunnerFactory();
testRunners.createTestRunners(testTemplateFolder, testTemplateFile, testOutputFolder, testOutputFile, testScriptPath, startingRule, timeout, testInstanceCount);
- testRunners.assignProgramsToProcessRunners(programs);
+ testRunners.assignProgramsToProcessRunners(programs, startingProgram);
programs.clear();
TreeMap<String, String> testResults = new TreeMap<>();
if(testInstanceCount > 1) {
@@ -103,7 +106,7 @@ public static void runAsSingleProcessStandalone(String inputFile) {
ArrayList<String> scenarioPrograms = new ArrayList<>(testResults.keySet());
ProcessRunnerFactory scenarioRunners = new ProcessRunnerFactory();
scenarioRunners.createScenarioRunners(scenarioTemplateFolder, scenarioTemplateFile, scenarioOutputFolder, scenarioOutputFile, scenarioScriptPath, startingRule, timeout, scenarioInstanceCount);
- scenarioRunners.assignProgramsToProcessRunners(scenarioPrograms);
+ scenarioRunners.assignProgramsToProcessRunners(scenarioPrograms, startingProgram);
TreeMap<String, String> scenarioResults = new TreeMap<>();
if(scenarioInstanceCount > 1) {
scenarioResults = scenarioRunners.runAllProcessesInSerial();
@@ -201,6 +201,10 @@ public void setTimeout(int timeout) {
this.timeout = timeout;
}
+ public void setPrograms(ArrayList<String> programs) {
+ this.programs = programs;
+ }
+
public ArrayList<String> getPrograms() {
return programs;
}
@@ -41,11 +41,17 @@ private void createProcessRunners(String outputFolder) {
tbfLogger.debug("Result from creating directory: " + directory.getAbsolutePath() + ": " + mkdirResult);
}
- public void assignProgramsToProcessRunners(ArrayList<String> programs) {
+ public void assignProgramsToProcessRunners(ArrayList<String> programs, int startingProgram) {
int numProcessRunners = processRunners.size();
for (int i = 0; i < programs.size(); i++) {
processRunners.get(i % numProcessRunners).addProgramToPrograms(programs.get(i));
}
+
+ for(ProcessRunner pr: processRunners) {
+ if(startingProgram > pr.getPrograms().size()) {
+ pr.setPrograms(new ArrayList(pr.getPrograms().subList(startingProgram, pr.getPrograms().size())));
+ }
+ }
}
public TreeMap<String, String> runAllProcessesInSerial() {

0 comments on commit 4630d96

Please sign in to comment.