what's faster on iPhone? XML pList or JSON?
Asked Answered
P

4

13

Assuming both XML plist and JSON are delivered over http, gzipped, which one will be processed faster on an iPhone?

Palmira answered 19/8, 2010 at 2:8 Comment(0)
S
11

A co-worker and I did some rudimentary benchmarks recently to test which was faster for an application we were writing. We tested this JSON framework, and the NSXML parser as well as a TreeNode parser we found in an Objective-C book. Here is the note I sent to the other developers on our team:

The benchmark tested how each library handled getting the filename and path
of 100 assets, 100 times each (for a total count of 10,000 runs per library).
The results are below:

Method    Average(s)    Total(s)
TreeNode  0.307475      30.747493
NSXML     0.483778      48.377843
JSON      0.233179      23.317870 
Spokesman answered 19/8, 2010 at 2:51 Comment(4)
did he try [NSDictionary dictionaryWithContentsOfURL:plistURL]?Palmira
Unfortunately no, we did some preliminary research that led us to believe that the NSXML and the JSON imlementations would be fastest, and we had already implemented the TreeNode solution as a first pass. Due to this, we only benchmarked the 3 solutions against one another.Spokesman
oh, I thought since plist xml is supported natively, it should have been optimized somehow.Palmira
That's what we had been led to believe as well, but various online sources steered us away from that. Either way, after using the three solutions above, the JSON parser is lightyears ahead of the others in terms of usability.Spokesman
A
3

JSON beats plists according to this: http://samsoff.es/posts/web-services-with-cocoa-surprise

Abstract answered 19/8, 2010 at 2:43 Comment(3)
His tests weren't done with binary plists, which are far more efficient.Evaporate
@Evaporate and how many web frameworks do you know of that can easily generate binary plists?Abstract
I have since retested and JSONKit beats binary plist.Troubadour
L
0

It depends on the data that is delivered and the way it is parsed, but they should both be similar in speed. You should just choose the one that is easier for you to develop a parser and then fine tune the parser.

Langevin answered 19/8, 2010 at 2:24 Comment(0)
D
0

In the "Building a Server-Driven User Experience" session of WwDC, an Apple developer stated that PLIST was preferred for being faster and easier to use.

Duple answered 19/8, 2010 at 2:37 Comment(2)
I think they only concluded that binary pList was faster and easier to use, but there's no way to create binary pList in Java...Palmira
I had lunch with the presenter of that talk and he admitted that JSONKit is actually really impressive and faster than plists. He said he was mainly a fan of plists because they have a WebObjects backend.Troubadour

© 2022 - 2024 — McMap. All rights reserved.