JSON解释速度对比 - Which parser is fastest on Android?
2012-12-15 20:55
471 查看
Correctness and Performance benchmark for various Java-based JSON libraries
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:
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/
FEB 4TH, 2011
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%左右,大数据量
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)
FEB 4TH, 2011My 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%左右,大数据量
相关文章推荐
- Android studio编程时出现的错误:unspecified on project app resolves to an APK archive which is not supported
- Struts注解开发问题2——The Result type [json] which is defined in the Result annotation on the class
- Android解析JSON速度对比
- Caused by: The Result type [json] which is defined in the Result annotation on the class
- Caused by: The Result type [json] which is defined in the Result annotation on the class
- struts2 json注解 时 报错:The Result type [json] which is defined in the Result annotation on the clas
- The `android.dexOptions.incremental` property is deprecated and it has no effect on the build proces
- composer安装yii时报错:The Process class relies on proc_open, which is not
- Android 使用notepad++ 格式化本地Json数据需要的对比安装插件
- [移动开发]AndroidStudio解决unspecifiedonprojectappresolvestoanAPKarchivewhichisnotsupported
- How to fix the phpmyadmin error “json extension is missing” on Ubuntu 14.04 desktop amd64?
- Android总结之json解析(FastJson Gson 对比)
- Android如何绘制视图,解释了为何onMeasure有时要调用多次
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Android总结之json解析(FastJson Gson 对比)
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- Linux文件查找命令具体解释-which whereis find locate
- Android如何绘制视图,解释了为何onMeasure有时要调用多次
- Warning:The `android.dexOptions.incremental` property is deprecated and it has no effect on the buil
- Android/Java 使用Gson解释Json数据