JSON解释速度对比 - Which parser is fastest on Android?
来源:互联网 发布:淘宝纯棉尿布 编辑:程序博客网 时间:2024/06/06 03:02
Correctness and Performance benchmark for various Java-based JSON libraries
Which parser is fastest on Android?
Here's a quick overview from the implementor of Android's two JSON parsers:
- org.json The API requires you to load the entire document into a String. This is somewhat cumbersome to use and inefficient for large documents. But it's a DOM model so you can get a lot done with very little code.
- android.util.JsonReader is a basic pull parser. It has a concise API and is reasonably efficient. It's included in Android 3.0. For earlier Android releases it's available as google-gson-stream which offers the same API in a 14 KiB .jar file. The larger GSON library also offers a DOM API and easy databinding.
- Jackson is efficient and fully-featured. Jackson has a capable but large API. It accomplishes great efficiency by going to some extremes, like implementing its own floating point parsing and charset decoding. If you use Jackson, you may want to use ProGuard to shrink its 222 KiB jar.
As for hard numbers, Jackson has the edge:
16 Kb Google Reader data: JsonReader 2.3 MBps Jackson 3.8 MBps 68 Kb Twitter data: JsonReader 2.2 MBps Jackson 5 MBps 185 Kb Google Reader data: JsonReader 2.5 MBps Jackson 6.5 MBps
Some of the optimizations currently employed by Jackson may be coming to Android.
----------------------------------------------------------------
Jackson 首页 : http://jackson.codehaus.org/Home
下面有一篇更详尽的数据比较,Jackson的优势是明显的:
http://martinadamek.com/2011/02/04/json-parsers-performance-on-android-with-warmup-and-multiple-iterations/
JSON Parsers Performance on Android (With Warmup and Multiple Iterations)
My recent posts on JSON parsers performance on Android platform were followed by some nice feedback. But to be honest, the previous version of the code was not exactly optimal. As @cowtowncoder pointed out in comments, there were several problems.
First and most stupid was that I was using very poor implementation of input reading for Android built-in parser. Now after change in the code, this parser is no longer the slowest one. Next problem was that I did not do any warm-up before actual test were executed. Next Tatu suggested to try to run tests in multiple iterations, so I am running them now 1, 5 and 100 times. I’m also using Jackson factory as static singleton, which is recommended.
Now, let’s see actual results as they appear now:
So it’s Jackson, what you should use if you need really fast reading of JSON data. All the code is up on GitHub.
最终实测:大数据上,jackson比Gson快30%左右,大数据量
- JSON解释速度对比 - Which parser is fastest on Android?
- Use pg_test_fsync test which wal_sync_method is fastest in your filesystem
- Android - JSON Parser Tutorial
- Finally,Which light is on?
- Caused by: The Result type [json] which is defined in the Result annotation on the class
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- json parser
- Android studio编程时出现的错误:unspecified on project app resolves to an APK archive which is not supported
- Android Studio 报错:unspecified on project app resolves to an APK archive which is not supported解决方案
- Android Studio依赖项目出现unspecified on project app resolves to an APK archive which is not supported
- FPGA&CPLD学习心得
- linux 调度 schedule分析
- 快速排序的递归实现。 分治法。
- setTimeout两个注意点
- java hashtable
- JSON解释速度对比 - Which parser is fastest on Android?
- 使用VS2008+OpenCV2.3.1遇到Msvcp100.dll文件缺失引发的一系列问题!
- ajax出现错误的原因
- Myeclipse单步调试
- Hdu 1518 - Square
- 全面接触Java集合框架
- 堆,栈,代码段,数据段,BSS 段概念解析
- Start now :)
- C#实现二分半折查找法