Mobile Performance Testing

DZone 's Guide to

Mobile Performance Testing

This article has a look at the performance differences when parsing JSON vs XML. Read on to find out if there's a winner.

· Mobile Zone ·
Free Resource


It doesn't matter if you're loading a configuration file, data set or even something obtained from a website to use as a data source, there is a performance tradeoff you'll encounter because of the processing time that occurs while parsing JSON or XML. This blog post covers how well loading and reading JSON & XML files using native APIs perform on iOS & Android.

Test Files

To test performance the SouthWind data set was used for JSON and XML. Both data sets are of roughly the same size, 1.3mb, and contain the same information. Source code used for the performance is provided below. The source for each project is quite generic and simply loads the data set file and reads all the employees into an array. All of the timing information is output through log statements.


For XML loading and reading the DocumentBuilderFactoryDocumentBuilderDocument and NodeList classes were used. For JSON loading and reading the JSONObject and JSONArray classes were used. 

Testing was done using a Kindle Fire HDX 7" tablet. The results on Android greatly varied on each run, but JSON was the faster choice by 300 milliseconds and even up to more than a second of processing time.



For XML loading and reading the NSXMLParser class was used. Because of how NSXMLParser is used it required created a separate class and adopting the NSXMLParserDelegate. For JSON loading and reading the NSJSONSerialization class was used for creating an NSDictionary from the JSON. 

Testing was done using an iPad 3. The results on iOS were consistent throughout the run and provided JSON quite the edge over XML by more than a second for each of the runs.



As you might of guessed JSON APIs are a lot faster at loading and reading compared to XML APIs. Picking which option to use requires you to look at the entire solution you're working toward. For example, a lot of companies make use of XLST transformations with their XML which can be very powerful. If your app doesn't need a format with a lot of overhead for extra search functionality & transformation, then JSON is the way to go. The open source community has really done a great job extending what's possible with JSON.

android, comparison, ios, json, performance, xml

Published at DZone with permission of Torrey Betts . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}