XSLT Profilers
Posted on: Saturday, February 16th, 2008 at 6:47 pm
On this page:
Microsoft recently announced an XSLT profiler for Visual Studio 2008. (I have used it briefly and it seems quite good.)
PHP recently announced PHP 5.3 which will include an XSLT profiler that can be invoked from within code. Current versions of PHP and the Microsoft one can invoke an XSLT profiler through the command line or against static XML/XSL files only, so being able to call it from within code is quite useful.
The run time invocation is really useful because if you are passing parameters into the XSLT or are generating the XML through DOM programmatically it is easier to profile. Otherwise, you need to capture the XML generated and save it, then invoke a profiler separately from the command line.
An example of calling it from within PHP is this (taken from a SitePoint article explaining the new features — see previous link):
$doc = new DOMDocument();
$xsl = new XSLTProcessor();
$doc->load('./lib/collection.xsl');
$xsl->importStyleSheet($doc);
$doc->load('./lib/collection.xml');
$xsl->setProfiling("/tmp/xslt-profiling.txt");
echo $xsl->transformToXML($doc);
echo '<h2>Profile report</h2>';
echo '<pre>' . file_get_contents( '/tmp/xslt-profiling.txt' ) . '</pre>';
Are there other profilers out there you recommend?
The profilers in oXygen and XML Spy look quite useful too (not used them, though heard about them).
I have not used XSLT profilers extensively. Just once in a blue moon. Some of the XSLT performance tips I have written earlier seems to have served me well, thus far, but I think more regular use of these profilers will be important.
Have you used other profilers for XSLT? What are they like?
Have you used other profilers that you can invoke from your code, rather than from an IDE or command line?
Do you find that to be useful or in the end is it just as easy to capture the XML and run the profiler in the IDE (which usually has a more powerful GUI to splice and dice the profile data)?
What about XSLT code coverage?
Is anyone aware of any good XSLT code coverage tools?
The reason this is important is that as well as getting good performance, it is important to know if you are exercising all your XSLT code or not.
This would be particularly useful when integrated with unit-tested XSLTs (which I will be writing about shortly!).
Image credits
“Stopwatch” by jamieriddell from flickr. See the original image at http://www.flickr.com/photos/jamieriddell/2183060366/.












On February 17th, 2008 at 11:08 pm Miguel de Melo said :
On February 18th, 2008 at 10:20 am Anup Shah said :