Search in sources :

Example 1 with SimpleAddressItem

use of sqlite.feature.performance.simple.SimpleAddressItem in project kripton by xcesco.

the class Generator method getKriptonSimpleAddresses.

public static Collection<SimpleAddressItem> getKriptonSimpleAddresses(Class<SimpleAddressItem> itemClass, int count) {
    Collection<SimpleAddressItem> addressItemCollection = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        SimpleAddressItem addressItem = null;
        addressItem = new SimpleAddressItem();
        addressItem.setName("Test");
        addressItem.setAddress("5486 Memory Lane");
        addressItem.setCity("Bronx");
        addressItem.setState("NY");
        addressItem.setPhone(7185555555l);
        addressItemCollection.add(addressItem);
    }
    return addressItemCollection;
}
Also used : SimpleAddressItem(sqlite.feature.performance.simple.SimpleAddressItem) ArrayList(java.util.ArrayList)

Example 2 with SimpleAddressItem

use of sqlite.feature.performance.simple.SimpleAddressItem 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;
        }
    });
}
Also used : SimpleAddressItem(sqlite.feature.performance.simple.SimpleAddressItem) BindSimpleDataSource(sqlite.feature.performance.simple.BindSimpleDataSource) TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) BindSimpleDaoFactory(sqlite.feature.performance.simple.BindSimpleDaoFactory) Collection(java.util.Collection) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

SimpleAddressItem (sqlite.feature.performance.simple.SimpleAddressItem)2 BaseAndroidTest (base.BaseAndroidTest)1 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Test (org.junit.Test)1 BindSimpleDaoFactory (sqlite.feature.performance.simple.BindSimpleDaoFactory)1 BindSimpleDataSource (sqlite.feature.performance.simple.BindSimpleDataSource)1