I was curious about the difference, if any, in performance between SBJSON and YAJL with Objective-C bindings. SBJSON is a strict JSON parser written in Objective-C. YAJL is a small event-driven (SAX-style) JSON parser written in ANSI C. Awhile back I wrote YAJL Objective-C bindings and I did some very basic speed tests on JSON data from twitter, delicious, last.fm and yelp. I ran these tests on the original, 3G and 3GS iPhones.
The SBJSON test ran
NSString#JSONValue, and the equivalent YAJL test ran
NSData#yajl_JSON. The YAJL bindings operate directly on NSData, and this makes a bit more sense since we usually have NSData first, whereas for SBJSON you have to decode to a string before parsing. I didn’t include this difference in my tests though.
These are tests of parsing only (and not loading of any data or strings) of the 4 APIs datasets run 100 times on the original iPhone, 3G and 3GS:
So the YAJL framework gives about a 60% speed increase. The YAJL Objective-C bindings can be found on github.
Update: The project used to do the perf test can be found here.