try {
super.create(model, logRuleSource, monitor, new InferenceQueueLog());
// reload
model = reloader.reload();
} catch (NumberFormatException e1) {
throw new InferenceException(e1);
} catch (IOException e1) {
throw new InferenceException(e1);
} catch (ModelLoadException e1) {
throw new InferenceException(e1);
}
int MAX_TIMES = 10;
List<Long> timedList = new ArrayList<Long>();
// now execute it 5 times, to get the times
for (int iteration = 0; iteration < MAX_TIMES; iteration++) {
System.out.println("iteration " + (iteration + 1) + "...");
long startTime = System.currentTimeMillis();
super.create(model, logRuleSource, monitor);
long diff = System.currentTimeMillis() - startTime;
timedList.add(diff);
// reload
try {
model = reloader.reload();
} catch (ModelLoadException e) {
throw new InferenceException(e);
}
}
long diff = timedList.get(0);
// this execution is to get the actual final result
super.create(model, logRuleSource, monitor);
// investigate final model properties
List<Object> finalProperties = getModelPropertiesInvestigator(false).investigate(model);
List<Object> finalPropertiesNoGen = getModelPropertiesInvestigator(true).investigate(model);
List<Object> finalDiff = getIncreaseAbsolute(finalPropertiesNoGen, finalProperties);
List<Object> finalDiffPct = getIncreasePercent(finalPropertiesNoGen, finalProperties);
// how many are in the final model?
int finalCount = 0;
{
Iterator<EObject> it = model.eAllContents();
while (it.hasNext()) {
it.next();
finalCount++;
}
}
// write this out to a log file
try {
File f = new File("inference-properties.csv");
if (!f.exists()) {
// write down a list of all the property names
write(f, "mode", getModelPropertiesInvestigator(false).getModelProperties());
}
write(f, "initial", initialProperties);
write(f, "initial-no-gen", initialPropertiesNoGen);
write(f, "initial-diff", initialDiff);
write(f, "initial-diff-%", initialDiffPct);
write(f, "final", finalProperties);
write(f, "final-no-gen", finalPropertiesNoGen);
write(f, "final-diff", finalDiff);
write(f, "final-diff-%", finalDiffPct);
write(f, "time", timedList);
System.out.println(initial + " -> " + finalCount + "(" + diff + " ms)");
} catch (IOException e) {
throw new InferenceException(e);
}
}
/**