November 25, 2014
Hot Topics:

Android XML Parser Performance, Page 2

  • June 11, 2009
  • By Shane Conder
  • Send Email »
  • More Articles »

A Quick Disclaimer

I know that the performance can be tuned; however, the results of this tuning should reap similar benefits across all three methods of parsing. Additionally, a lot of conversion from strings to numbers and dates takes place. However, since we're comparing the three methods of parsing and not how to parse this particular file type the fastest, this is an acceptable method of comparing them in a particular real world situation. That being said, the code is provided for review.

Testing My Assumptions Regarding Parser Performance

As I stated before, I had assumed the new XML Pull Parser would fare best, followed by SAX with DOM coming in last. This did not turn out to be correct.

The chart below shows the results of the three different tests I performed, small, medium and large data sets, in number of sections for test completion:



Click here for larger image

As you can see, DOM was still the slowest parsing method, but SAX consistently outperformed the XML Pull Parser slightly. This came as something of a surprise.

I also looked at how many records could be parsed each second. This would be a potentially easier metric to see how each parser scaled as well as an easy to manipulate number to see how long an arbitrarily sized file would take to parse.



Click here for larger image

Indeed, the Pull parser method was not the fastest parsing method. However, the results show that on file sizes larger than I tested, the Pull parser may actually end up faster. However, since the total time for any of the methods will be too long to reasonably execute on a handset, this does not matter.

Overall Impressions of Parser Performance on Android

The first surprise I had was at how slow all three methods were. Users don't want to wait long for results on mobile phones, so parsing anything more than a few dozen records may mandate a different method.

When Parsing on the Handset is Required: Stick with SAX

When parsing of XML on the Android handset is required, I would recommend using the SAX parser, especially where the file sizes are relatively small.

Get the code for this article

Author

Shane Conder is a software developer focused on mobile and web technologies. He co-authored Android Wireless Application Development, available from Addison-Wesley. He is currently working at a small mobile software company. Contact Shane at shane+a2@kf6nvr.net. "



Originally published on http://www.developer.com.

Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel