use of sqlite.feature.performance.simple.BindSimpleDataSource in project kripton by xcesco.
the class TestPerformanceRuntime method testRunSave.
@Test
public void testRunSave() {
// delete all
final BindSimpleDataSource dataSource = BindSimpleDataSource.instance();
dataSource.execute(new BindSimpleDataSource.Transaction() {
@Override
public TransactionResult onExecute(BindSimpleDaoFactory daoFactory) {
daoFactory.getSimpleAddressDao().deleteAll();
Collection<SimpleAddressItem> simpleAddressItems = Generator.getKriptonSimpleAddresses(SimpleAddressItem.class, LOOP_COUNT);
long insertDuration;
long insertOptimizedDuration;
// normal INSERT
{
log("insert NORMAL start");
long startTime = System.currentTimeMillis();
for (SimpleAddressItem simpleAddressItem : simpleAddressItems) {
daoFactory.getSimpleAddressDao().insert(simpleAddressItem);
}
insertDuration = System.currentTimeMillis() - startTime;
log("insert duration: %s", insertDuration);
}
// end
daoFactory.getSimpleAddressDao().deleteAll();
// optimized INSERT
{
log("insert OPTIZED start");
long startTime = System.currentTimeMillis();
for (SimpleAddressItem simpleAddressItem : simpleAddressItems) {
daoFactory.getSimpleAddressDao().insert(simpleAddressItem);
}
insertOptimizedDuration = System.currentTimeMillis() - startTime;
log("insert OPTIMIZED duration: %s", insertOptimizedDuration);
}
// end
return TransactionResult.COMMIT;
}
});
}
Aggregations