You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/01 04:22:56 UTC

svn commit: r524513 - in /incubator/tuscany/java/sca/scdl4j: stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java xml/src/test/java/org/apache/tuscany/scdl/SAXPerfTest.java

Author: jsdelfino
Date: Sat Mar 31 19:22:55 2007
New Revision: 524513

URL: http://svn.apache.org/viewvc?view=rev&rev=524513
Log:
Basic performance tests for the StAX and SAX loaders.

Added:
    incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java   (with props)
    incubator/tuscany/java/sca/scdl4j/xml/src/test/java/org/apache/tuscany/scdl/SAXPerfTest.java   (with props)

Added: incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java?view=auto&rev=524513
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java (added)
+++ incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java Sat Mar 31 19:22:55 2007
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.scdl.stax.impl;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.policy.model.PolicyFactory;
+import org.apache.tuscany.policy.model.impl.DefaultPolicyFactory;
+import org.apache.tuscany.scdl.stax.LoaderRegistry;
+
+/**
+ * Test the usability of the assembly model API when loading SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class StAXPerfTest {
+	
+    private XMLInputFactory inputFactory;
+    private AssemblyFactory assemblyFactory;
+    private PolicyFactory policyFactory;
+    private LoaderRegistry loaderRegistry;
+
+	public static void main(String[] args) throws Exception {
+		
+		StAXPerfTest perfTest = new StAXPerfTest();
+		perfTest.setUp();
+		
+		// Warm up
+		for (long i = 0; i<500; i++) {
+			perfTest.testReadComposite();
+		}
+		
+		long begin = System.currentTimeMillis();
+		long iter = 10000;
+		for (long i = 0; i<iter; i++) {
+			perfTest.testReadComposite();
+		}
+		long end = System.currentTimeMillis();
+		System.out.println("Iterations: "+ iter);
+		System.out.println("Time: "+ (end - begin));
+		System.out.println("Memory: "+Runtime.getRuntime().totalMemory()/1024);
+	}
+
+    public void setUp() throws Exception {
+        inputFactory = XMLInputFactory.newInstance();
+        assemblyFactory = new DefaultAssemblyFactory();
+        policyFactory = new DefaultPolicyFactory();
+        loaderRegistry = new LoaderRegistryImpl();
+    }
+
+    public void tearDown() throws Exception {
+        assemblyFactory = null;
+        policyFactory = null;
+        inputFactory = null;
+        loaderRegistry = null;
+    }
+
+    public void testReadComposite() throws Exception {
+        InputStream is = getClass().getClassLoader().getResourceAsStream("TestAllCalculator.composite");
+        CompositeLoader loader = new CompositeLoader(assemblyFactory, policyFactory, loaderRegistry);
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+
+        Composite composite = loader.load(reader);
+        is.close();
+
+        if (composite == null)
+        	throw new IllegalStateException("Null composite");
+    }
+
+}

Propchange: incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/scdl4j/stax/src/test/java/org/apache/tuscany/scdl/stax/impl/StAXPerfTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/scdl4j/xml/src/test/java/org/apache/tuscany/scdl/SAXPerfTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/xml/src/test/java/org/apache/tuscany/scdl/SAXPerfTest.java?view=auto&rev=524513
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/xml/src/test/java/org/apache/tuscany/scdl/SAXPerfTest.java (added)
+++ incubator/tuscany/java/sca/scdl4j/xml/src/test/java/org/apache/tuscany/scdl/SAXPerfTest.java Sat Mar 31 19:22:55 2007
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.scdl;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.policy.model.PolicyFactory;
+import org.apache.tuscany.policy.model.impl.DefaultPolicyFactory;
+import org.apache.tuscany.scdl.impl.CompositeHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Test the usability of the assembly model API when loading SCDL
+ * 
+ * @version $Rev$ $Date$
+ */
+public class SAXPerfTest extends TestCase {
+
+    XMLReader reader;
+    AssemblyFactory assemblyFactory;
+    PolicyFactory policyFactory;
+    
+	public static void main(String[] args) throws Exception {
+		
+		SAXPerfTest perfTest = new SAXPerfTest();
+		perfTest.setUp();
+		
+		// Warm up
+		for (long i = 0; i<500; i++) {
+			perfTest.testReadComposite();
+		}
+		
+		long begin = System.currentTimeMillis();
+		long iter = 10000;
+		for (long i = 0; i<iter; i++) {
+			perfTest.testReadComposite();
+		}
+		long end = System.currentTimeMillis();
+		System.out.println("Iterations: "+ iter);
+		System.out.println("Time: "+ (end - begin));
+		System.out.println("Memory: "+Runtime.getRuntime().totalMemory()/1024);
+		
+	}
+
+    public void setUp() throws Exception {
+        reader = XMLReaderFactory.createXMLReader();
+        reader.setFeature("http://xml.org/sax/features/namespaces", true);
+        reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
+        
+        assemblyFactory = new DefaultAssemblyFactory();
+        policyFactory = new DefaultPolicyFactory();
+    }
+
+    public void tearDown() throws Exception {
+        assemblyFactory = null;
+        policyFactory = null;
+        reader = null;
+    }
+
+    public void testReadComposite() throws Exception {
+        InputStream is = getClass().getClassLoader().getResourceAsStream("TestAllCalculator.composite");
+        CompositeHandler handler = new CompositeHandler(assemblyFactory, policyFactory, null, null, null);
+        reader.setContentHandler(handler);
+        reader.parse(new InputSource(is));
+        
+        Composite composite = handler.getComposite();
+
+        if (composite == null)
+        	throw new IllegalStateException("Null composite");
+    }
+
+}

Propchange: incubator/tuscany/java/sca/scdl4j/xml/src/test/java/org/apache/tuscany/scdl/SAXPerfTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/scdl4j/xml/src/test/java/org/apache/tuscany/scdl/SAXPerfTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org