GreenDaoPerformanceTest.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:GreenDao-vs-Realm 作者:
/**
 * Tests performance of {@link com.db.oliviergoutay.greendao_vs_realm.greendao.GreenDaoDailyMealManager#updateDatabase(Context, List)}
 */
@MediumTest
public void testUpdateDatabaseListPerformance() throws InterruptedException {
    List<DailyMealApi> mList = new ArrayList<>();
    Date date = new Date();
    for (int i = 0; i < 365; i++) {
        mList.add(getMockDailyMealForDate(date));
        date = Utilities.getYesterday(date);
    }

    CountDownLatch countDownLatch = new CountDownLatch(1);
    greenDaoDailyMealManager.setTestCountDownLatch(countDownLatch);
    long start = System.currentTimeMillis();
    greenDaoDailyMealManager.updateDatabase(mContext, mList);
    countDownLatch.await();
    long end = System.currentTimeMillis();

    Log.i(TAG, "Mass insert of 365 DailyMealApi took : " + (end - start) + " milliseconds");
    //Check time is less than 3000 millis
    assertTrue(3000 > end - start);

    //Check all were inserted
    assertEquals(365, dao.getDailyMealDao().loadAll().size());
    assertEquals(365 * 4, dao.getMealDao().loadAll().size());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号