April 12, 2010

Fast XML DOM vs XmlDom Benchmarks !

Today I got a nice comment about “Fast XML DOM” script consumption being more of Ron Hess’s “XmlDom.cls”. That surprised me and I thought why don’t give a try and publish the results.

Benchmarking - Fixture

The most important thing to get benchmarking transparent and easy for everybody to reproduce was to search a decently big XML document to perform operations on. For this I decided to pick any public XML Atom feed, and decided to use it from a google code project feed. Here is the link to this xml.

Apart from that, for first round of bench marking, I picked two other criteria’s for benchmarking both the APIs. These are

  • Benchmark#1 - DOM Creation: This operation is pretty heavy as it involves creating DOM structure from a XML string.
  • Benchmark#2 - getElementsByTagName() API Call”: This is pretty popular and nice API to test how well a XML API performs on parsing XML structure to give matching nodes for a name.
  • Benchmark#3 - getElementByTagName() API Call”: This API call is pretty similar to that to the above one. But its performance depends on the way its implemented.

To keep this benchmarking simple and extensive for future a new class “TG_XMLDOM_BenchMarks” has been added to the API. You can check it to see how I am benchmarking.

Benchmark#1 - DOM Creation

Results:

INFO|XmlDom.constructor() -> Scripts Used : 4804 ,time consumed : 264
INFO|TG_XmlDom.constructor() -> Scripts Used : 26 ,time consumed : 18

Benchmark#2 - getElementsByTagName API call

Results:

INFO|XmlDom.getElementsByTagName() -> Scripts Used : 795 ,time consumed : 28
INFO|TG_XmlDom.getElementsByTagName() -> Scripts Used : 560 ,time consumed : 55

Benchmark#3 - getElementByTagName API call

Results:

INFO|XmlDom.getElementByTagName() -> Scripts Used : 798 ,time consumed : 27
INFO|TG_XmlDom.getElementByTagName() -> Scripts Used : 38 ,time consumed : 2

I am glad benchmarking started and resulted well. I will doing more bench marking in coming days. This will give Fast XML DOM users/developers more confidence on the API and will help us figure out more areas for polishing and optimizations.