JSON v XML

There are a whole bunch of JSON v XML posts out there. So, I will not rehash the various arguments on which is better. However, we needed to select a file format to store configuration information. To make things convenient, we decided to use the Boost::Property_Tree library.

So, this is essentially about how the Boost library performs when parsing JSON and XML. The sample JSON and XML files were obtained from the JSON examples website.

After writing a simple program to perform 10,000 reads and 100 writes, we timed the operation. The programme was compiled with GCC and LLVM with optimisation turned on. The reason we used the 10,000:100 ratio for read and write is because this application will be performing more reads than writes.

The results are:

JSON (GCC): 1.85s
XML  (GCC): 3.07s
JSON(LLVM): 1.69s
XML (LLVM): 2.83s

Seems that the Boost library has a better JSON parser than an XML parser. What is also interesting is that the LLVM compiled code runs about 10% faster than the GCC version.

← Previous post

Next post →

3 Comments

  1. angch

    In other news, it seems that C has a better gzip compressor than a bzip2 compressor.

Leave a Reply