try {
long startTime = System.currentTimeMillis();
for (int loopCounter=0; loopCounter<loops; loopCounter++) {
String propertyKey = "testDbPerfKey-" + loopCounter;
DB db = DBFactory.getInstance();
PropertyManager pm = PropertyManager.getInstance();
String testValue = "testDbPerfValue-" + loopCounter;
Property p = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
pm.saveProperty(p);
// forget session cache etc.
db.closeSession();
pm.deleteProperty(p);
}
long endTime = System.currentTimeMillis();
timeWithoutTransction = endTime - startTime;
Tracing.logInfo("testDbPerf without transaction takes :" + timeWithoutTransction + "ms", this.getClass());
} catch (Exception ex) {
fail("Exception in testDbPerf without transaction ex="+ ex);
}
try {
long startTime = System.currentTimeMillis();
for (int loopCounter=0; loopCounter<loops; loopCounter++) {
String propertyKey = "testDbPerfKey-" + loopCounter;
DB db = DBFactory.getInstance();
PropertyManager pm = PropertyManager.getInstance();
String testValue = "testDbPerfValue-" + loopCounter;
Property p = pm.createPropertyInstance(null, null, null, null, propertyKey, null, null, testValue, null);
pm.saveProperty(p);
// forget session cache etc.
db.closeSession();
db = DBFactory.getInstance();
pm.deleteProperty(p);
}
long endTime = System.currentTimeMillis();
long timeWithTransction = endTime - startTime;
Tracing.logInfo("testDbPerf with transaction takes :" + timeWithTransction + "ms", this.getClass());
Tracing.logInfo("testDbPerf diff between transaction and without transaction :" + (timeWithTransction - timeWithoutTransction) + "ms", this.getClass());