Results 1 to 2 of 2
  1. #1
    sveri is offline Member
    Join Date
    Jan 2015
    Posts
    8
    Rep Power
    0

    Default java xml TransformerFactory.newTransformer getting slower during tests

    I have a problem where I do not know what the root cause actually is.

    I create an instance of javax.xml.transform.TransformerFactory and directly afterwards I parse a xsltSource:

    Java Code:
    protected synchronized Transformer getTransformer(Source xsltSource)
        throws TransformerConfigurationException {
    
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer(xsltSource); 
        return transformer;
    }
    I am using the com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl classes.
    Which are the ones provided by the JDK.


    Now I have a test that is part of the test suite. When I run that test standalone the code above takes around 1ms constantly.

    When I run that test as part of my test suite it takes longer. This happens as well in eclipse as with gradle. The duration rises linear with the amount of tests that run before.

    Its orders of magnitudes slower, like 10 - 1000 times, depending on how much tests run before that specific test.

    Using a cached instance of the TransfomerFactory will cut the time the test takes in half. But the symptom remains the same.
    I have been profiling it, but dont see anything suspicious, except the the test takes longer.

    My first assumption was it had directly to do with the number of loaded classes, which it does not. Loading classes arbitrarily does not change the time the test needs.

    Next I added the saxon parser and specifically used that one, but the symptom remains the same.

    Also I figured out I have the same problem with this line of code:

    Java Code:
    SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
    Any ideas what might be the cause here?

  2. #2
    sveri is offline Member
    Join Date
    Jan 2015
    Posts
    8
    Rep Power
    0

    Default Re: java xml TransformerFactory.newTransformer getting slower during tests


Similar Threads

  1. Learning Java looking for Projects/Tests
    By Hawthorne in forum New To Java
    Replies: 3
    Last Post: 06-08-2015, 02:32 PM
  2. Jar file 4 times slower than in IDE
    By slider57 in forum Advanced Java
    Replies: 16
    Last Post: 09-19-2013, 01:58 PM
  3. Adding tests to a Java class
    By someone2088 in forum New To Java
    Replies: 2
    Last Post: 01-11-2012, 04:57 PM
  4. Numeric range query way slower (3.5 vs 3.1)
    By tinwelint in forum Lucene
    Replies: 1
    Last Post: 01-09-2012, 04:00 PM
  5. Replies: 8
    Last Post: 03-12-2010, 04:30 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •