use of com.abubusoft.kripton.android.sqlite.TransactionResult 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;
}
});
}
use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.
the class TestFeatureSQLTypeAdapterBitmapRuntime method testSelect.
@Test
public void testSelect() {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
final Bitmap bitmap = BitmapFactory.decodeFile("/src/test/resources/imgs/img.png", options);
BindAppDataSource ds = BindAppDataSource.instance();
ds.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindAppDaoFactory daoFactory) {
Person bean = new Person();
bean.image = bitmap;
daoFactory.getDaoPerson().insert(bean);
List<Person> list = daoFactory.getDaoPerson().list();
for (Person person : list) {
// use
saveImage((new File("src/test/resources/imgs/img0.png")).getAbsolutePath(), person.image);
}
return TransactionResult.COMMIT;
}
});
}
use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.
the class TestSpeedRuntime method testSingle.
@Test
public void testSingle() {
final One<Long> start = new One<>();
final One<Long> end = new One<>();
final int COUNTER = 200000;
final BindPersonDataSource ds = BindPersonDataSource.instance();
ds.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindPersonDaoFactory daoFactory) {
start.value0 = System.currentTimeMillis();
PersonDaoImpl dao = daoFactory.getPersonDao();
for (int i = 0; i < COUNTER; i++) {
Person bean = new Person();
bean.name = "name" + i;
bean.surname = "surname" + i;
// Object bean = new
dao.insert(bean);
}
end.value0 = System.currentTimeMillis();
return TransactionResult.COMMIT;
}
});
// 3100
System.out.println("Esecuzione terminata in " + (end.value0 - start.value0) + " ms");
}
use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.
the class TestForeignKeyARuntime method testRunSqlite3.
@Test
public void testRunSqlite3() throws IOException, InstantiationException, IllegalAccessException {
BindDummyDataSource dataSource = BindDummyDataSource.instance();
dataSource.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindDummyDaoFactory daoFactory) {
DaoBeanA_1Impl dao = daoFactory.getDaoBeanA_1();
BeanA_2 beanParent = new BeanA_2();
beanParent.valueString2 = "parent";
daoFactory.getDaoBeanA_2().insert(beanParent);
BeanA_1 bean = new BeanA_1();
bean.valueString = "hello";
bean.beanA2Id = beanParent.id;
dao.insert(bean);
assertEquals(1, bean.id);
return TransactionResult.COMMIT;
}
});
}
use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.
the class TestForeignKeyARuntime method testRunSqlite4.
@Test
public void testRunSqlite4() throws IOException, InstantiationException, IllegalAccessException {
BindDummyDataSource dataSource = BindDummyDataSource.instance();
dataSource.execute(new Transaction() {
@Override
public TransactionResult onExecute(BindDummyDaoFactory daoFactory) {
DaoBeanA_1Impl dao = daoFactory.getDaoBeanA_1();
BeanA_2 beanParent = new BeanA_2();
beanParent.valueString2 = "parent";
daoFactory.getDaoBeanA_2().insert(beanParent);
BeanA_1 bean = new BeanA_1();
bean.valueString = "hello";
bean.beanA2Id = beanParent.id;
dao.insert(bean);
assertEquals(1, bean.id);
return TransactionResult.COMMIT;
}
});
}
Aggregations