

The world's fastest Objective-C JSON serializer/deserializer - kstenerud

This weekend, I finished writing the world's fastest Objective-C implementation of a JSON serializer/deserializer.<p>It has a simple API, compile clean (even with pedantic warnings), has 90% test coverage, and supports compiling with or without ARC.<p>Code is here: https://github.com/kstenerud/KSJSON<p>Benchmark is here: https://github.com/kstenerud/JSONCompare
======
LinaLauneBaer
Can you explain what optimizations you made and what impact they had on the
performance? Would be great to hear. Also: You are using a lot of "low level"
API calls to Core Foundation. Have you tried using the Foundation classes
instead? Did this have a huge impact on the performance? Thank you!

~~~
kstenerud
I wrote a blog post showing some of the bigger optimizations:
[http://codeinhindsight.blogspot.com/2011/10/down-rabbit-
hole...](http://codeinhindsight.blogspot.com/2011/10/down-rabbit-hole-of-
optimization.html)

Aside from the pokey NumberFormatter and "replaceOccurrencesOfString" calls,
the biggest source of slowdown was the Objective-C calling mechanism itself.
After that, it came down to minimizing even the CF API calls. They work fine,
but they are generic routines, and you can get better speed by rolling your
own specialized code for buffer management and such.

In the end, the only thing I left to CF (aside from constructing the final
objects) was unicode conversion.

