Transfomation with EE slower then HE
Added by Allan Madsen over 10 years ago
Transfomation with EE slower then HE ?
Hi
I did som transformation testing with the saxon9he and it worked great. We desided to buy the saxon9ee licence so we could use it comercially. I changed the saxon9he.jar in my test project with saxon9ee.jar and the saxon-license.lic file.
Now it is much slower.
I have tried 3 different TransformerFactory setups
- TransformerFactory factory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null);
- TransformerFactory factory = TransformerFactory.newInstance("com.saxonica.config.EnterpriseTransformerFactory", null);
- TransformerFactory factory = new EnterpriseTransformerFactory();
but it does not change the performance.
I looked at where the time was used and it seems to be in factory.newTransformer(xslt);
What do i do wrong ? Do you have any ideas how to get the performance back ? Greeting Allan
Here are my test code:
File fileXML = new File("c:/xml/test.xml"); File fileXSL = new File("c:/xsl/test.xsl");
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document xmlDoc = documentBuilder.parse(new FileInputStream(fileXML));
DOMSource input = new DOMSource(xmlDoc);
StringWriter writer = new StringWriter();
StreamResult output = new StreamResult(writer);
Source xslt = new StreamSource(new FileInputStream(fileXSL));
TransformerFactory factory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null); //TransformerFactory factory = TransformerFactory.newInstance("com.saxonica.config.EnterpriseTransformerFactory", null); //TransformerFactory factory = new EnterpriseTransformerFactory();
Transformer transformer = factory.newTransformer(xslt);
transformer.transform(input, output);
System.out.println(writer.toString());
Replies (1)
RE: Transfomation with EE slower then HE - Added by Michael Kay over 10 years ago
The factory.newTransformer() call is compiling the stylesheet, and this will generally take a little longer in Saxon-EE because it is doing more optimization (and also bytecode generation). The assumption is that it's worth doing more work at compile time in order to improve performance at run-time, but of course this doesn't always apply, particularly (a) for very simple stylesheets where optimization delivers little benefit, and (b) where you compile a stylesheet and only use it once, to process a fairly small source document.
If it's "much" slower (rather than just a bit slower) then it may be worth our while investigating it. There could be a case where the optimization is doing something pathological.
The first thing to do if performance is important is to stop using DOM. This is unrelated to your reported problem, but it's probably the quickest way to get an improvement. Processing a DOM as input often takes ten times as long as using Saxon's native tree model. Supply a StreamSource or SAXSource instead of a DOMSource.
Obviously, if you are using the same stylesheet for more than one transformation, then try to avoid the compilation costs by reusing the Templates object.
It's possible to switch off some optimizations using configuration options (FeatureKeys.GENERATE_BYTE_CODE, FeatureKeys.OPTIMIZATION_LEVEL), but this isn't normally necessary and it would be good to see your code to see whether there's any specific problem causing the regression.
Please register to reply