DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > Mobile Performance Testing

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.

Torrey Betts user avatar by
Torrey Betts
·
Apr. 22, 16 · Mobile Zone · Tutorial
Like (1)
Save
Tweet
2.27K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

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.

  • Android Project (1.9mb)
  • iOS Project (563kb)

Android

For XML loading and reading the DocumentBuilderFactory, DocumentBuilder, Document 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.

Android

iOS


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.

iOS

Conclusion

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.

JSON Data set XML

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Deployment of Low-Latency Solutions in the Cloud
  • Choosing Between GraphQL Vs REST
  • Why I'm Choosing Pulumi Over Terraform
  • Synchronization Methods for Many-To-Many Associations

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo