performance of nspropertylistserialization vs nsjsonserialization

蓝咒 提交于 2020-01-03 02:40:07

问题


I'm considering making a switch from serializing data from my web service endpoint as JSON to a binary property list. I'm unserializing on Cocoa. Has anyone who has used both NSPropertyListSerialization and NSJSONSerialization noticed a difference in parsing times? I'm curious as I've read before that there's a noticeable difference—see this blog post (in the Under the Hood section) for an example by Hipmunk.

Also interesting to me if there's a noticeable difference between NSJSONSerialization and external libraries like JSONKit or TouchJSON.


回答1:


I can say that NSJSONSerialization is faster than JSONKit, I used it for a Core Graphics project and code which took on average 26ms before is now 16ms, with only changes in the JSON deserialization.

Not sure on NSPropertyListSerialization, but the GitHub page of JSONKit claims it's faster than binary .plist, which leads me to believe that NSJSONSerialization class is the fastest of them all. Correct me if I'm wrong.




回答2:


I pulled down 200 tweets and profiled parsing the payload using both SBJSON and NSJSONSerialization. The results:

SBJSON: 489ms / 397KB NSJSONSerialization : 133ms / 3.8 KB

NSJSONSerialization has a pretty significant advantage - especially in terms of the memory footprint.

http://blog.skulptstudio.com/nsjsonserialization-vs-sbjson-performance



来源:https://stackoverflow.com/questions/7559340/performance-of-nspropertylistserialization-vs-nsjsonserialization

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