JSON Parsing Speed Test: YAJL vs SBJSON (iPhone Edition)

October 8, 2009 — 2 Comments

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:


iphone


iphone3g


iphone3gs


So the YAJL framework gives about a 60% speed increase. The YAJL Objective-C bindings can be found on github.

Be sure to thank @lloydhilaiel for making YAJL full of so much awesomeness.

Update: The project used to do the perf test can be found here.

Trackbacks and Pingbacks:

  1. JSON und iPhones @ #002A - November 2, 2010

    [...] Geschwindigkeitsvergleich beider Frameworks geht YAJL klar an die Spitze und sollte deshalb auch bei mir Anwendung finden. [...]

  2. Benchmark: YAJL VS SBJSON - November 8, 2010

    [...] Je vous conseil la lecture de ce cours article de Gabriel Handford, si vous cherchez une bonne librairie JSON pour vos développement. JSON Parsing Speed Test: YAJL vs SBJSON (iPhone Edition) [...]

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s