json_logo-555px

Previously i blog about how to use QJson* classes in Qt5 to parse Json file and I did mentioned that I’ll be doing a benchmark comparing the QJson* with javscript JSON.parse() in QML. I’ve done it, and here’s the result

I’ve done comparison between 3 methods, which is QJson, RapidJson and JSON.parse. Since the json file is quite small (5kB), I’ve decided to measure time needed to parse the json content for 10, 000 times.

Here’s the result:

json_benchmark0

For 10, 000 times of parsing, RapidJson is the fastest with 2.6 seconds, QJson just a little bit slower with 3.6 seconds and JSON.parse consumes 10.3 seconds.

Here’s a graph for better visualization.

json_benchmark2

So, as a rough conclusion from this experiment, QJson is way faster than JSON.parse but still lose some ground to RapidJson. However, I do think that QJson is easier to use than RapidJson especially you’re using Qt.

The source code for this experiment is available at GitHub (https://github.com/cckwes/q5json) and is released under GPL license, feel free to have a look and modify as you like. Thanks.

p/s: Please drop a comment below if you have any opinion on the benchmark result or ideas to improve the benchmark method. Thanks again.