Update: A new post from December 2010 with updated stats is available here.
For a few weeks I’ve been working on a new iPhone application.
Like most of other Cocoa apps I’ve written so far, this app also includes a JSON parser to load some kind of data from a server. The first thing the application does when it starts is connect to the JSON API, download a data file (about 100 KB) and parse it. This used to take about 10-15 seconds on the device, and I thought it was reasonable until I noticed that the HTTP response actually arrives after a second or so. So what was it doing for the rest of the time? I had to find out.
So I did some debugging, and it turned out that the 10 seconds are spent just on parsing the downloaded JSON file. That’s pretty bad… Like in all previous apps, I used an open source library BSJSONAdditions, which I knew wasn’t the fastest one available, but I never had any major problems with it before. On the other hand, I never tested it on a 100 KB file…
I knew there were a few other JSON parser libraries in ObjC, so I decided to make a small benchmark and see how well they all compared to the one I used. The other libraries I tried were: JSON Framework, TouchJSON and YAJL.