import com.sun.org.apache.xerces.internal.utils.ConfigurationError;

public class TestXercesNormal {

	public static void main(String[] args) throws ClassNotFoundException, ConfigurationError, InstantiationException, IllegalAccessException {
		long startTime = System.currentTimeMillis();
		 for(int i = 0; i < 100000; i++) { 
	            com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory.getInstance(); 
	        }
		 long deltaTime = System.currentTimeMillis() - startTime;
		 System.out.println("time taken using normal method:" + deltaTime);
		 
		 startTime = System.currentTimeMillis();
		 Class cachedClass = com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass("com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl", true); 
	        for(int i = 0; i < 100000; i++) { 
	            com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory factory = 
	                (com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory) cachedClass.newInstance(); 
	        } 
	     deltaTime = System.currentTimeMillis() - startTime;
	     System.out.println("time taken using optimized method:" + deltaTime);  

	}

}
