lijoantony / JsonBenchmarkCpp

Benchmark of JSON frameworks in c++
Other
16 stars 9 forks source link

h1. JsonBenchmarkCpp

JsonBenchmarkCpp is a small program to benchmark various JSON frameworks in c++

Currently supports following libs,

"Cajun":http://sourceforge.net/projects/cajun-jsonapi

"json_spirit":http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx

"libjson":http://sourceforge.net/projects/libjson

"json-parser":https://github.com/udp/json-parser

"AveryWs js":https://github.com/matthewaveryusa/averyws

See my "blog post":http://www.lijoantony.com/?p=5 for details.

h2. Building

Install "git":http://git-scm.com

@git clone git://github.com/lijoantony/JsonBenchmarkCpp.git@

Edit main.cpp to suit your needs

Either edit the Makefile as you like and use make to build the executable

or use your favourite build system to compile and link main.cpp with the libs.

h2. Results Summary

Frameworks ranked in the order "libjson":http://sourceforge.net/projects/libjson, "json_spirit":http://www.codeproject.com/KB/recipes/JSON_Spirit.aspx and "Cajun":http://sourceforge.net/projects/cajun-jsonapi for both parsing and writing speeds

Eg:

bc. $./JsonBenchmarkCpp > results.dat averydb@debian:~/gits/JsonBenchmarkCpp$ cat results.dat

library parsing writing

cajun 669 160
json_spirit 14907 731
libjson 139 203
Avery 35 55
json_parser 114

Here the numbers shows time taken by each lib for the particular operation in microseconds. libjson is a clear winner among the three. Sample results and corresponding graphs are available in results directory. For accurate results, replace the content of file data.json with your JSON data and run the executable.

Use the gnuplot script results/graph.p to draw bar diagram out of this data:

bc. $ ./graph.p > graph.png

h3. Thanks

Thanks to the library authors for their effort and time. You saved me from reinventing the same wheel again!

Special thanks to Jonathan Wallace, for actively developing libjson and helping me with my queries.