Usage of net.sf.saxon.TransformerFactoryImpl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Nitinkcv
    New Member
    • Mar 2007
    • 65

    Usage of net.sf.saxon.TransformerFactoryImpl

    Hi all,

    I have a xsl and xml file which is transformed to a particular format. I make use of the net.sf.saxon.Tr ansformerFactor yImpl to do my transformation.

    I'm actually timing the transformations to see how long they take. So basically i do a transformation of a file once, ten times and then 1000 times to see how long it takes.

    Basically i put a timer statement before the for loop and a timer after the for loop to find out the difference.

    This is part of my code:

    Code:
     
    public static void main(String args[]) {
    		 System.setProperty("javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl");
       test(10);
       test(10);
       test(1000);
    }
    
    public static void test(int n){
    	 long start=0;
    	 long end =0;
    
    	start = new Date().getTime();
    	for (int i=0; i<n ; i++){
    		process();
    	}
    	end = new Date().getTime();
    	System.out.println("No of times run-->"+n);
    	System.out.println(end-start);
    }
    The timings that i get are somewhat odd.

    Code:
    No of times run-->1
    469
    No of times run-->10
    218
    No of times run-->1000
    8468
    My only only assumption why it takes 469 ms to run it once and 218ms to run it 10 times, is something to do with initializing the transformation engine??

    Could anyone please shed some light?
    Nitin
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    The load time of the class is significant. Run it once to get the load time out of the way and then run it once again to get the actual timing. It is probable that there is a singleton which has to create itself before running the first time, but then it exists for subsequent runs.

    Comment

    Working...