nspropertylistserialization 与 nsjsonserialization 的性能
我正在考虑将来自 Web 服务端点的数据序列化为 JSON 转换为二进制属性列表。我正在对 Cocoa 进行反序列化。同时使用过 NSPropertyListSerialization 和 NSJSONSerialization 的人是否注意到解析时间上的差异?我很好奇,因为我之前读过,有一个明显的区别 - 请参阅 这篇博文(在“底层”部分)查看 Hipmunk 的示例。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我提取了 200 条推文,并使用 SBJSON 和 NSJSONSerialization 分析了有效负载。结果:
SBJSON:489ms / 397KB
NSJSONSerialization:133ms / 3.8 KB
NSJSONSerialization 具有相当显着的优势 - 特别是在内存占用方面。
http://blog.skulptstudio.com/nsjsonserialization-vs-sbjson-performance
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
我可以说 NSJSONSerialization 比 JSONKit 更快,我将它用于 Core Graphics 项目,之前平均需要 26 毫秒的代码现在只需要 16 毫秒,仅在 JSON 反序列化方面发生了变化。
不确定
NSPropertyListSerialization
,但 JSONKit 的 GitHub 页面声称它比二进制更快.plist,这让我相信NSJSONSerialization
类是其中最快的。如果我错了请纠正我。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 thatNSJSONSerialization
class is the fastest of them all. Correct me if I'm wrong.