在我的应用程序中调用ORMLite RuntimeExceptionDao的createOrUpdate(...)方法非常慢.
我有一个非常简单的object(Item),有2个int(一个是generatedId),a String和a double.我用下面的代码测试(大致)更新数据库中的对象所需的时间(100次).日志语句记录:
时间更新1行100次:3069
为什么在只有1行的表中更新对象需要3秒才能更新100次.这是正常的ORMLite速度吗?如果没有,可能是什么问题?
RuntimeExceptionDao<Item, Integer> dao =
DatabaseManager.getInstance().getHelper().getReadingStateDao();
Item item = new Item();
long start = System.currentTimeMillis();
for (int i = 0; i < 100; i++) {
item.setViewMode(i);
dao.createOrUpdate(item);
}
long update = System.currentTimeMillis();
Log.v(TAG, "time to update 1 row 100 times: " + (update - start));
Run Code Online (Sandbox Code Playgroud)
如果我创建100个新行,那么速度会更慢.
注意:我已经在使用了ormlite_config.txt.它记录"Loaded configuration for class ...Item"所以这不是问题.
谢谢.