String statement = "";
int numTests = 0;
// it seems that the very first parsing takes a while, so I put it aside
Statement parsedStm = parserManager.parse(new StringReader(statement = (String) statementsList.get(0)));
TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
ArrayList parsedSelects = new ArrayList(NUM_REPS * statementsList.size());
long time = System.currentTimeMillis();
// measure the time to parse NUM_REPS times all statements in the 2 files
for (int i = 0; i < NUM_REPS; i++) {
try {
int j = 0;
for (Iterator iter = statementsList.iterator(); iter.hasNext(); j++) {
statement = (String) iter.next();
parsedStm = parserManager.parse(new StringReader(statement));
numTests++;
if (parsedStm instanceof Select) {
parsedSelects.add(parsedStm);
}
}
} catch (JSQLParserException e) {
throw new TestException("impossible to parse statement: " + statement, e);
}
}
long elapsedTime = System.currentTimeMillis() - time;
long statementsPerSecond = numTests * 1000 / elapsedTime;
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(7);
df.setMinimumFractionDigits(4);
System.out.println(numTests + " statements parsed in " + elapsedTime + " milliseconds");
System.out.println(" (" + statementsPerSecond + " statements per second, "
+ df.format(1.0 / statementsPerSecond) + " seconds per statement )");
numTests = 0;
time = System.currentTimeMillis();
// measure the time to get the tables names from all the SELECTs parsed before
for (Iterator iter = parsedSelects.iterator(); iter.hasNext();) {
Select select = (Select) iter.next();
if (select != null) {
numTests++;
List tableListRetr = tablesNamesFinder.getTableList(select);
}
}
elapsedTime = System.currentTimeMillis() - time;
statementsPerSecond = numTests * 1000 / elapsedTime;
System.out.println(numTests + " select scans for table name executed in " + elapsedTime + " milliseconds");