ORM performance: is greenDAO faster than ORMLite?

强颜欢笑 提交于 2019-12-31 08:14:28

问题


I've been using ORMLite in my application and I was considering whether to move to greenDAO.

Performance is a huge part of that decision, and greenDAO's Features page says:

For the same given entity, greenDAO inserts and updates entities over 2 times faster, and loads entities 4.5 times faster for loading entities than ORMLite.
...
(Figures and chart updated 10-23-2011)

I thought ORMLite's config file generation step should remove the need for reflection at runtime.

The ORMLite changlog suggests that the greenDAO benchmark was done after the config file feature was released, but the greenDAO features page doesn't explicitly say if a static config file was generated for the test.

4.26: 9/26/2011 (svn r1978)
* ANDROID: Added field configuration utility to avoid Dao creation performance problems with annotations.

There have also been ORMLite performance fixes since then, e.g.

4.40: 4/16/2012 (svn r2516)
* ANDROID: Big performance bug fix when creating DAOs. Foreign fields always used reflection instead of table configs.

Can anybody confirm if there is still a big performance difference between greenDAO and ORMLite? Thanks!


回答1:


We've just published a Github project that we used to compare the performance of ORMLite and GreenDao to raw SQLite:
https://github.com/daj/android-orm-benchmark

The project also allows you to compare the performance of an in-memory database to an on disk one.

The headline results are:

GreenDao is much faster than ORMLite. It is roughly:

  • 3X faster at writing large numbers of objects.
  • 50% faster at reading in all 10000 entries in a single table.
  • 2X to 3X faster at an indexed read of a single row (though both were very fast).
  • 15X faster at doing a LIKE search for 100 records in a 10000 entry table.

The project contains both a naive raw SQLite benchmark, and an optimized SQLite benchmark.

GreenDao vs unoptimized raw SQLite

  • GreenDao is 2X faster for the write benchmark.
  • GreenDao is 25% slower for the read benchmark.

GreenDao vs optimized raw SQLite

  • GreenDao is 50% slower for the read and write benchmarks.

For detailed results please see the Github repository above.

Of course we may have bugs in our benchmarking code...if you find any please fork, fix and submit a pull request! :-)

Disclaimer: make sure you do your own research before choosing GreenDao over ORMLite.



来源:https://stackoverflow.com/questions/20079568/orm-performance-is-greendao-faster-than-ormlite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!