[#3225] Added benchmark

This commit is contained in:
Lukas Eder 2014-05-05 09:43:12 +02:00
parent 28e3a7959d
commit f7beeab747
2 changed files with 32 additions and 0 deletions

View File

@ -55,6 +55,7 @@ import org.jooq.Record2;
import org.jooq.Record3;
import org.jooq.Record6;
import org.jooq.Result;
import org.jooq.ResultQuery;
import org.jooq.Select;
import org.jooq.TableRecord;
import org.jooq.UpdatableRecord;
@ -92,6 +93,7 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
private static final int REPETITIONS_RECORD_INTO_TABLE_RECORD = 20000;
private static final int REPETITIONS_FIELD_ACCESS = 1000000;
private static final int REPETITIONS_SELECT = 100;
private static final int REPETITIONS_PLAIN_SQL = 10000;
private static final String RANDOM = "" + new Random().nextLong();
public BenchmarkTests(jOOQAbstractTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T725, T639, T785, CASE> delegate) {
@ -185,6 +187,31 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
watch.splitInfo("Reuse SQL String");
}
public void testBenchmarkPlainSQL() throws Exception {
Configuration configuration = create().configuration().derive(new ExecuteListenerProvider[0]);
configuration.settings().setExecuteLogging(false);
DSLContext create = create(configuration);
// System.out.println("Start");
// System.in.read();
// System.in.read();
ResultQuery<?> q = create
.select()
.from("t_book")
.where("id = ?", -1)
.keepStatement(true);
StopWatch watch = new StopWatch();
for (int i = 0; i < REPETITIONS_PLAIN_SQL; i++) {
q.bind(1, i % 4 + 1).fetchOne();
}
watch.splitInfo("Done with " + REPETITIONS_PLAIN_SQL + " repetitions");
// System.out.println("Stop");
// System.in.read();
// System.in.read();
}
private void testBenchmarkReuseSQLString(DSLContext create, int repetitions) throws Exception {
String sql = createSelect(create).getSQL(INDEXED);
PreparedStatement pst = getConnection().prepareStatement(sql);

View File

@ -2683,6 +2683,11 @@ public abstract class jOOQAbstractTest<
new BenchmarkTests(this).testBenchmarkSelect();
}
@Test
public void testBenchmarkPlainSQL() throws Exception {
new BenchmarkTests(this).testBenchmarkPlainSQL();
}
@Test
public void testKeepStatement() throws Exception {
new StatementTests(this).testKeepStatement();