Search code examples
saxonexist-db

Turning on Saxon performance analysis in eXist-db


I've used the performance analysis tool in Saxon (https://www.saxonica.com/documentation11/index.html#!using-xsl/performanceanalysis) to analyze stylesheets, and it's quite useful. I'd like to do the analysis from within eXist-db rather than the command line. For one, the performance could be different. But mainly because some stylesheets open documents in exist-db, and I can't run these from the command line. Is there a way to configure Saxon to output the profile.html document when it's run via eXist-db?

I was hoping there would be an attribute in conf.xml , or attributes that could be sent via transform:transform(), but I don't see any options related to the performance analysis tool.


Solution

  • I can't be certain this will work, but it's worth a try.

    The $attributes parameter of Exist-db's transform() method allows you to set Saxon configuration properties. The available properties are listed at https://www.saxonica.com/documentation11/index.html#!configuration/config-features . You could try setting the properties TRACE_LISTENER_CLASS (to "net.sf.saxon.trace.TimingTraceListener") and TRACE_LISTENER_OUTPUT_FILE (to the required "profile.html" output file).

    Incidentally, note that the performance is going to be different when you run with a trace listener. The profile generated using -TP is useful because it tells you which templates and functions are accounting for the most time and therefore need attention; the absolute numbers are not important or accurate. The hot spots will almost certainly be the same whether you are running within eXist or from the command line.