Press ESC to close

Fast XML DOM getElementsByTagName Optimized !

Today I did some code optimization, cleanup and refactoring. Result of that was TG_XmlNode.getElementsByTagName() was optimized to consume lesser script statements. I was able to reduce the script consumption upto 50%, by in-lining many statements and adding few checks.

Together with this I added a bench marking class “TG_XMLDOM_BenchMarks.cls”. This can be used to quickly bench mark XmlDom vs Fast Xml DOM on different xml samples.

How to use bench marking

  1. Open “TG_XMLDOM_BenchMarks.cls

  2. Locate static string variable named “XML_URL” to public URL of your XML sample. Together with this, you need to white list domain for this url via “Setup > Security Controls > Remote Site Settings”.

  3. Call  “TG_XMLDOM_BenchMarks.benchmark()” to start benchmarking.

    // Just call this method
    TG_XMLDOM_BenchMarks.benchmark();
  4. Check the debug logs, the results will be logged with Logging Level of INFO. Sample shown below:  

    INFO|XmlDom.constructor() -> Scripts Used : 4804 ,time consumed : 264
    INFO|TG_XmlDom.constructor() -> Scripts Used : 26 ,time consumed : 18
References :
  1. SFDC Code share Page

  2. Google Code project

  3. Quick Start Guide

  4. Source Code

Comments (2)

Leave a Reply

%d bloggers like this: