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
- Open “TG_XMLDOM_BenchMarks.cls”
- 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”.
- Call “TG_XMLDOM_BenchMarks.benchmark()” to start benchmarking.
// Just call this method TG_XMLDOM_BenchMarks.benchmark();
- 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