xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ce...@apache.org
Subject svn commit: r233577 [2/2] - in /xmlbeans/trunk/test/perf: ./ bin/ src/org/apache/xmlbeans/test/performance/jaxb/ src/org/apache/xmlbeans/test/performance/svn/
Date Fri, 19 Aug 2005 23:32:22 GMT
Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/CursorWalkSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/CursorWalkSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/CursorWalkSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/CursorWalkSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,108 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+
+import java.io.CharArrayReader;
+
+public class CursorWalkSVN
+{
+
+  public static void main(String[] args) throws Exception
+  {
+
+    final int iterations = Constants.CURSOR_ITERATIONS;
+    String flavor;
+
+    if(args.length == 0)
+      flavor = "deep-attributes";
+    else
+      flavor = args[0];
+
+
+    CursorWalkSVN test = new CursorWalkSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // get the xml cursor
+    char[] chars = util.createXmlData(flavor, Constants.XML_SIZE);
+    //System.out.println("chars="+chars.length);
+    XmlObject doc = XmlObject.Factory.parse(new CharArrayReader(chars));
+    XmlCursor cursor = doc.newCursor();
+
+    // run the gc?
+
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){     
+      hash += test.run(cursor);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){     
+      hash += test.run(cursor);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time " + cputime+" ");
+    System.out.print("time/it " + ((double)cputime)/((double)iterations) + "\n");
+  }
+
+  private int run(XmlCursor cursor) throws Exception
+  {
+    int iHash = 0;
+
+    while(cursor.hasNextToken()){
+    
+      // walk the doc with the cursor, computing the hash
+      if(cursor.isStart())
+      {
+        iHash += 17; // add a prime number
+      }
+      else if(cursor.isContainer())
+      {
+        iHash += cursor.getTextValue().length();
+      }
+      else if(cursor.isAttr())
+      {
+        iHash += cursor.getTextValue().length();
+      }
+      else if(cursor.isText())
+      {
+        iHash += cursor.getChars().length();
+      }
+
+      cursor.toNextToken();
+
+    }
+
+    // reset the cursor to the beginning 
+    cursor.toStartDoc();
+
+    // return the hash value
+    return iHash;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/DomWalkNLSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/DomWalkNLSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/DomWalkNLSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/DomWalkNLSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,96 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class DomWalkNLSVN
+{
+
+  public static void main(String[] args) throws Exception
+  {
+
+    final int iterations = Constants.CURSOR_ITERATIONS;
+    String flavor;
+
+    if(args.length == 0)
+      flavor = "deep-attributes";
+    else
+      flavor = args[0];
+
+    DomWalkNLSVN test = new DomWalkNLSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // get the xml cursor
+    char[] chars = util.createXmlData(flavor, Constants.XML_SIZE);
+    XmlObject doc = XmlObject.Factory.parse(new CharArrayReader(chars));
+    Node node ;
+
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      node = doc.getDomNode();
+      hash += test.run(node);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      node = doc.getDomNode();
+      hash += test.run(node);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(Node p_node)
+  {
+    int result = 0;
+    short type = p_node.getNodeType();
+
+    if(type == Node.ATTRIBUTE_NODE ||
+       type == Node.CDATA_SECTION_NODE ||
+       type == Node.TEXT_NODE)
+    {
+      result = p_node.getNodeValue().length();
+    }
+    else
+    {
+      result = p_node.getNodeName().length();
+    }
+
+    NodeList children = p_node.getChildNodes();
+    for(int i=0; i<children.getLength(); i++)
+    {
+      result += run(children.item(i));
+    }
+
+    return result;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/DomWalkSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/DomWalkSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/DomWalkSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/DomWalkSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,95 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+import org.w3c.dom.Node;
+
+public class DomWalkSVN
+{
+
+  public static void main(String[] args) throws Exception
+  {
+
+    final int iterations = Constants.CURSOR_ITERATIONS;
+    String flavor;
+
+    if(args.length == 0)
+      flavor = "deep-attributes";
+    else
+      flavor = args[0];
+
+    DomWalkSVN test = new DomWalkSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // get the xml cursor
+    char[] chars = util.createXmlData(flavor, Constants.XML_SIZE);
+    XmlObject doc = XmlObject.Factory.parse(new CharArrayReader(chars));
+    Node node;
+
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      node =  doc.getDomNode();
+      hash += test.run(node);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      node =  doc.getDomNode();
+      hash += test.run(node);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(Node p_node)
+  {
+    int result = 0;
+    short type = p_node.getNodeType();
+
+    if(type == Node.ATTRIBUTE_NODE ||
+       type == Node.CDATA_SECTION_NODE ||
+       type == Node.TEXT_NODE)
+    {
+      result = p_node.getNodeValue().length();
+    }
+    else
+    {
+      result = p_node.getNodeName().length();
+    }
+    
+    Node child = p_node.getFirstChild();
+    while(null != child)
+    {
+      result += run(child);
+      child = child.getNextSibling();
+    }
+    return result;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/MaxMemUntypedBisLoadSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/MaxMemUntypedBisLoadSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/MaxMemUntypedBisLoadSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/MaxMemUntypedBisLoadSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,78 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+
+
+public class MaxMemUntypedBisLoadSVN
+{
+ 
+  public static void main(String[] args) throws Exception
+  {
+  	int interval = Constants.MEM_INTERVAL;
+  	long memory = Runtime.getRuntime().maxMemory();
+  	int size = 0;
+  	int hash = 0;
+    String flavor = null;
+
+    if(args.length == 0)
+      flavor = "deep-attributes";
+    else
+      flavor = args[0];
+
+    MaxMemUntypedBisLoadSVN test = new MaxMemUntypedBisLoadSVN();
+    PerfUtil util = new PerfUtil();
+    
+    try
+    {
+    	System.gc();
+    	// infinite for loop - go until get oom
+    	for(int i=1; true; i++)
+    	{
+    		System.gc();
+    		byte[] bytes = util.createXmlDataBytes(flavor,Constants.MEM_INITIALSIZE+(interval*i));
+    		hash += test.run(new BufferedInputStream(new ByteArrayInputStream(bytes) ));
+    		size = bytes.length;
+    	}
+    }
+    catch (OutOfMemoryError oom)
+    {
+    	System.gc();
+        // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+        System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" flavor="+flavor+" ");
+        System.out.print("hash "+hash+" ");
+        System.out.print("memory "+memory+" ");
+        System.out.println("size="+size);
+    }
+  }
+
+  private int run(BufferedInputStream p_bis) throws Exception
+  {
+    // load the buffered input stream
+    XmlObject xobj = XmlObject.Factory.parse(p_bis);
+    
+    // calculate and return the hash value
+    XmlCursor cursor = xobj.newCursor();
+    cursor.toFirstContentToken();
+    return cursor.getName().toString().length() * 17;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/NPrimTopDownSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/NPrimTopDownSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/NPrimTopDownSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/NPrimTopDownSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,79 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.openuri.nonprimitives.NonPrimitivesDocument;
+import org.openuri.nonprimitives.Numerics;
+import org.openuri.nonprimitives.NonPrimitivesDocument.NonPrimitives;
+
+public class NPrimTopDownSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+
+    NPrimTopDownSVN test = new NPrimTopDownSVN();
+    int iterations = Constants.ITERATIONS;
+    long cputime;
+    int hash = 0;
+        
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run();
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run();
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run() throws Exception
+  {
+    // create the doc
+    NonPrimitivesDocument doc = NonPrimitivesDocument.Factory.newInstance();
+    NonPrimitives nprim = doc.addNewNonPrimitives();
+
+    // create and initialize numeric elements
+    for(int i=0; i<Constants.PO_NUM_LINEITEMS; i++)
+    {
+      Numerics numerics = nprim.addNewNumerics();
+      numerics.setMydecimal(Constants.myBigDecimal);
+      numerics.setMyinteger(Constants.myPosBigInteger);
+      numerics.setMyneginteger(Constants.myNegBigInteger);
+      numerics.setMynonneginteger(Constants.myPosBigInteger);
+      numerics.setMynonposinteger(Constants.myNegBigInteger);
+      numerics.setMyposinteger(Constants.myPosBigInteger);
+    }
+
+    // set the date and string fields
+    nprim.setMydate(Constants.myDate);
+    nprim.setMystring(Constants.myString);
+
+    // calculate a hash to return
+    int hash = ( nprim.getNumericsArray().length ) * 17;
+    return hash;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POGetCustNameSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POGetCustNameSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POGetCustNameSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POGetCustNameSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,100 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+import org.apache.xmlbeans.test.performance.utils.Constants;
+
+// from svn-generated schema jar(s)
+import org.openuri.easypo.PurchaseOrderDocument;
+import org.openuri.easypo.PurchaseOrderDocument.PurchaseOrder;
+import org.openuri.easypo.Customer;
+
+
+public class POGetCustNameSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+
+    final int iterations = Constants.GET_SET_ITERATIONS;
+    String filename;
+
+    // the xml instance can be specified by either a number
+    // or the name of a file located in the test folder
+    // see Constants.java
+    if(args.length == 0){
+      filename = Constants.PO_INSTANCE_1;
+    }
+    else if(args[0].length() > 1){
+      filename = Constants.XSD_DIR+Constants.P+args[0];
+    }
+    else{
+      switch( Integer.parseInt(args[0]) )
+      {
+      case 1: filename = Constants.PO_INSTANCE_1; break;
+      case 2: filename = Constants.PO_INSTANCE_2; break;  
+      case 3: filename = Constants.PO_INSTANCE_3; break;
+      case 4: filename = Constants.PO_INSTANCE_4; break;
+      case 5: filename = Constants.PO_INSTANCE_5; break;
+      case 6: filename = Constants.PO_INSTANCE_6; break;
+      case 7: filename = Constants.PO_INSTANCE_7; break;
+      default: filename = Constants.PO_INSTANCE_1; break;
+      }
+    }    
+
+    POGetCustNameSVN test = new POGetCustNameSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+
+    // get the xmlinstance
+    char[] chars = util.fileToChars(filename);
+        
+    // parse the instance
+    PurchaseOrderDocument podoc = 
+      PurchaseOrderDocument.Factory.parse(new CharArrayReader(chars));
+    PurchaseOrder po = podoc.getPurchaseOrder();
+    Customer customer = po.getCustomer();
+
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run(customer);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){     
+      hash += test.run(customer);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" filesize="+chars.length+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(Customer p_customer) throws Exception
+  {
+    return p_customer.getName().length() * 17;
+  }
+
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POGetSetGetCustNameSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POGetSetGetCustNameSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POGetSetGetCustNameSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POGetSetGetCustNameSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,116 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+import org.apache.xmlbeans.test.performance.utils.Constants;
+
+// from svn-generated schema jar(s)
+import org.openuri.easypo.PurchaseOrderDocument;
+import org.openuri.easypo.PurchaseOrderDocument.PurchaseOrder;
+import org.openuri.easypo.Customer;
+
+
+public class POGetSetGetCustNameSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+
+    final int iterations = Constants.GET_SET_ITERATIONS;
+    String filename;
+    int stringSize = 0;
+    String stringToSet = "";
+
+    // the xml instance can be specified by either a number
+    // or the name of a file located in the test folder
+    // see Constants.java
+    if(args.length == 0){
+      filename = Constants.PO_INSTANCE_1;
+    }
+    else if(args[0].length() > 1){
+      filename = Constants.XSD_DIR+Constants.P+args[0];
+    }
+    else{
+      switch( Integer.parseInt(args[0]) )
+      {
+      case 1: filename = Constants.PO_INSTANCE_1; break;
+      case 2: filename = Constants.PO_INSTANCE_2; break;  
+      case 3: filename = Constants.PO_INSTANCE_3; break;
+      case 4: filename = Constants.PO_INSTANCE_4; break;
+      case 5: filename = Constants.PO_INSTANCE_5; break;
+      case 6: filename = Constants.PO_INSTANCE_6; break;
+      case 7: filename = Constants.PO_INSTANCE_7; break;
+      default: filename = Constants.PO_INSTANCE_1; break;
+      }
+    }    
+
+    // the size of the string used is the second arg or default if not specified
+    if(args.length < 2)
+    {
+      stringSize = Constants.STRING_SIZE;
+    }
+    else
+    {
+      stringSize = Integer.parseInt(args[1]);
+    }
+
+    POGetSetGetCustNameSVN test = new POGetSetGetCustNameSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // create the string to be used for the set
+    stringToSet = util.createString(stringSize);
+
+    // get the xmlinstance
+    char[] chars = util.fileToChars(filename);
+        
+    // parse the instance
+    PurchaseOrderDocument podoc = 
+      PurchaseOrderDocument.Factory.parse(new CharArrayReader(chars));
+    PurchaseOrder po = podoc.getPurchaseOrder();
+    Customer customer = po.getCustomer();
+
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run(customer, stringToSet);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){     
+      hash += test.run(customer, stringToSet);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" filesize="+chars.length+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(Customer p_customer, String p_setval) throws Exception
+  {
+    p_customer.getName();
+    p_customer.setName(p_setval);
+    return p_customer.getName().length() * 17;
+  }
+
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POQueryLineItemsSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POQueryLineItemsSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POQueryLineItemsSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POQueryLineItemsSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,101 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+//import java.io.File;
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+//import org.openuri.easypo.LineItem;
+import org.openuri.easypo.PurchaseOrderDocument;
+//import org.openuri.easypo.Shipper;
+
+import org.apache.xmlbeans.XmlObject;
+
+
+public class POQueryLineItemsSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+    final int iterations = Constants.ITERATIONS;
+    String filename;
+
+    if(args.length == 0){
+      filename = Constants.PO_INSTANCE_1;
+    }
+    else if(args[0].length() > 1){
+      filename = Constants.XSD_DIR+Constants.P+args[0];
+    }
+    else{
+      switch( Integer.parseInt(args[0]) )
+      {
+      case 1: filename = Constants.PO_INSTANCE_1; break;
+      case 2: filename = Constants.PO_INSTANCE_2; break;  
+      case 3: filename = Constants.PO_INSTANCE_3; break;
+      case 4: filename = Constants.PO_INSTANCE_4; break;
+      case 5: filename = Constants.PO_INSTANCE_5; break;
+      case 6: filename = Constants.PO_INSTANCE_6; break;
+      case 7: filename = Constants.PO_INSTANCE_7; break;
+      default: filename = Constants.PO_INSTANCE_1; break;
+      }
+    }    
+
+    POQueryLineItemsSVN test = new POQueryLineItemsSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // get the xmlinstance
+    char[] chars = util.fileToChars(filename);
+    
+    // unmarshall the xml instance
+    PurchaseOrderDocument poDoc = 
+      PurchaseOrderDocument.Factory.parse(new CharArrayReader(chars));       
+    // retreive the purchase order
+    PurchaseOrderDocument.PurchaseOrder po = poDoc.getPurchaseOrder();
+        
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      CharArrayReader reader = new CharArrayReader(chars);     
+      hash += test.run(po);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      CharArrayReader reader = new CharArrayReader(chars);     
+      hash += test.run(po);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" filesize="+chars.length+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(PurchaseOrderDocument.PurchaseOrder p_po) throws Exception
+  {	
+  	XmlObject[] results = p_po.execQuery("declare namespace s='"+Constants.PO_NS+"'; "+
+							".//s:line-item");
+  	
+    return results.length;
+  }
+
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POReadAllSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POReadAllSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POReadAllSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POReadAllSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,117 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+import org.openuri.easypo.Customer;
+import org.openuri.easypo.LineItem;
+import org.openuri.easypo.PurchaseOrderDocument;
+import org.openuri.easypo.Shipper;
+
+
+public class POReadAllSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+
+    final int iterations = Constants.ITERATIONS;
+    String filename;
+
+    if(args.length == 0){
+      filename = Constants.PO_INSTANCE_1;
+    }
+    else if(args[0].length() > 1){
+      filename = Constants.XSD_DIR+Constants.P+args[0];
+    }
+    else{
+      switch( Integer.parseInt(args[0]) )
+      {
+      case 1: filename = Constants.PO_INSTANCE_1; break;
+      case 2: filename = Constants.PO_INSTANCE_2; break;  
+      case 3: filename = Constants.PO_INSTANCE_3; break;
+      case 4: filename = Constants.PO_INSTANCE_4; break;
+      case 5: filename = Constants.PO_INSTANCE_5; break;
+      case 6: filename = Constants.PO_INSTANCE_6; break;
+      case 7: filename = Constants.PO_INSTANCE_7; break;
+      default: filename = Constants.PO_INSTANCE_1; break;
+      }
+    }    
+
+    POReadAllSVN test = new POReadAllSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // get the xmlinstance
+    char[] chars = util.fileToChars(filename);
+        
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      CharArrayReader reader = new CharArrayReader(chars);     
+      hash += test.run(reader);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      CharArrayReader reader = new CharArrayReader(chars);     
+      hash += test.run(reader);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" filesize="+chars.length+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(CharArrayReader reader) throws Exception
+  {
+    int iSumStrings = 0;
+    // unmarshall the xml instance
+    PurchaseOrderDocument poDoc = 
+      PurchaseOrderDocument.Factory.parse(reader);       
+    // retreive the purchase order
+    PurchaseOrderDocument.PurchaseOrder po = poDoc.getPurchaseOrder();
+    // retreive the customer element
+    Customer customer = po.getCustomer();
+    iSumStrings += customer.getAddress().length();
+    iSumStrings += customer.getName().length();
+    // retreive the date
+    po.getDate();
+    // retreive all line items
+    LineItem[] lineitems = po.getLineItemArray();
+    // sum the line item prices and get the other childs
+    float sum = 0;
+    for(int i=0; i<lineitems.length; i++){
+      iSumStrings += lineitems[i].getDescription().length();
+      lineitems[i].getPerUnitOunces();
+      lineitems[i].getQuantity();
+      sum += lineitems[i].getPrice();
+    }
+    // retreive the shipper element
+    Shipper shipper = po.getShipper();
+    iSumStrings += shipper.getName().length();
+    shipper.getPerOunceRate();
+
+    return iSumStrings;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POReadOneSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POReadOneSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POReadOneSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POReadOneSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,100 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+//import java.io.File;
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+import org.openuri.easypo.LineItem;
+import org.openuri.easypo.PurchaseOrderDocument;
+//import org.openuri.easypo.Shipper;
+
+
+public class POReadOneSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+    final int iterations = Constants.ITERATIONS;
+    String filename;
+
+    if(args.length == 0){
+      filename = Constants.PO_INSTANCE_1;
+    }
+    else if(args[0].length() > 1){
+      filename = Constants.XSD_DIR+Constants.P+args[0];
+    }
+    else{
+      switch( Integer.parseInt(args[0]) )
+      {
+      case 1: filename = Constants.PO_INSTANCE_1; break;
+      case 2: filename = Constants.PO_INSTANCE_2; break;  
+      case 3: filename = Constants.PO_INSTANCE_3; break;
+      case 4: filename = Constants.PO_INSTANCE_4; break;
+      case 5: filename = Constants.PO_INSTANCE_5; break;
+      case 6: filename = Constants.PO_INSTANCE_6; break;
+      case 7: filename = Constants.PO_INSTANCE_7; break;
+      default: filename = Constants.PO_INSTANCE_1; break;
+      }
+    }    
+
+    POReadOneSVN test = new POReadOneSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // get the xmlinstance
+    char[] chars = util.fileToChars(filename);
+        
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      CharArrayReader reader = new CharArrayReader(chars);     
+      hash += test.run(reader);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      CharArrayReader reader = new CharArrayReader(chars);     
+      hash += test.run(reader);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" filesize="+chars.length+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(CharArrayReader reader) throws Exception
+  {
+    // unmarshall the xml instance
+    PurchaseOrderDocument poDoc = 
+      PurchaseOrderDocument.Factory.parse(reader);       
+    // retreive the purchase order
+    PurchaseOrderDocument.PurchaseOrder po = poDoc.getPurchaseOrder();
+   
+    // retreive the first line item
+    LineItem lineitem = po.getLineItemArray(0);
+
+    // return the char length of the description
+    return lineitem.getDescription().length();
+  }
+
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POSelectLineItemsSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POSelectLineItemsSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POSelectLineItemsSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POSelectLineItemsSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,101 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+//import java.io.File;
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+//import org.openuri.easypo.LineItem;
+import org.openuri.easypo.PurchaseOrderDocument;
+//import org.openuri.easypo.Shipper;
+
+import org.apache.xmlbeans.XmlObject;
+
+
+public class POSelectLineItemsSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+    final int iterations = Constants.ITERATIONS;
+    String filename;
+
+    if(args.length == 0){
+      filename = Constants.PO_INSTANCE_1;
+    }
+    else if(args[0].length() > 1){
+      filename = Constants.XSD_DIR+Constants.P+args[0];
+    }
+    else{
+      switch( Integer.parseInt(args[0]) )
+      {
+      case 1: filename = Constants.PO_INSTANCE_1; break;
+      case 2: filename = Constants.PO_INSTANCE_2; break;  
+      case 3: filename = Constants.PO_INSTANCE_3; break;
+      case 4: filename = Constants.PO_INSTANCE_4; break;
+      case 5: filename = Constants.PO_INSTANCE_5; break;
+      case 6: filename = Constants.PO_INSTANCE_6; break;
+      case 7: filename = Constants.PO_INSTANCE_7; break;
+      default: filename = Constants.PO_INSTANCE_1; break;
+      }
+    }    
+
+    POSelectLineItemsSVN test = new POSelectLineItemsSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // get the xmlinstance
+    char[] chars = util.fileToChars(filename);
+    
+    // unmarshall the xml instance
+    PurchaseOrderDocument poDoc = 
+      PurchaseOrderDocument.Factory.parse(new CharArrayReader(chars));       
+    // retreive the purchase order
+    PurchaseOrderDocument.PurchaseOrder po = poDoc.getPurchaseOrder();
+        
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      CharArrayReader reader = new CharArrayReader(chars);     
+      hash += test.run(po);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      CharArrayReader reader = new CharArrayReader(chars);     
+      hash += test.run(po);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" filesize="+chars.length+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(PurchaseOrderDocument.PurchaseOrder p_po) throws Exception
+  {
+  	XmlObject[] results = p_po.selectPath("declare namespace s='"+Constants.PO_NS+"'; "+
+  							".//s:line-item");
+  	
+    return results.length;
+  }
+
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POTopDownSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POTopDownSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POTopDownSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POTopDownSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,91 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.util.Calendar;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.openuri.easypo.Customer;
+import org.openuri.easypo.LineItem;
+import org.openuri.easypo.PurchaseOrderDocument;
+import org.openuri.easypo.Shipper;
+import org.openuri.easypo.PurchaseOrderDocument.PurchaseOrder;
+
+
+public class POTopDownSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+
+    POTopDownSVN test = new POTopDownSVN();
+    int iterations = Constants.ITERATIONS;
+    long cputime;
+    int hash = 0;
+        
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run();
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run();
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run() throws Exception
+  {
+    // create the purchase order
+    PurchaseOrderDocument podoc = PurchaseOrderDocument.Factory.newInstance();
+    PurchaseOrder po = podoc.addNewPurchaseOrder();
+
+    // create and initialize customer
+    Customer customer = po.addNewCustomer();
+    customer.setName(Constants.PO_CUSTOMER_NAME);
+    customer.setAddress(Constants.PO_CUSTOMER_ADDR);
+
+    // set the date
+    po.setDate(Calendar.getInstance());
+
+    // create and initialize the line item array
+    for (int i=0; i<Constants.PO_NUM_LINEITEMS; i++)
+    {
+      LineItem li = po.addNewLineItem();
+      li.setDescription(Constants.PO_LI_DESC);
+      li.setPerUnitOunces(Constants.PO_LI_PUO);
+      li.setPrice(Constants.PO_LI_PRICE);
+      li.setQuantity(Constants.PO_LI_QUANTITY);
+    }
+
+    // create and initialize the shipper
+    Shipper shipper = po.addNewShipper();
+    shipper.setName(Constants.PO_SHIPPER_NAME);
+    shipper.setPerOunceRate(Constants.PO_SHIPPER_POR);
+
+    // calculate a hash to return
+    int hash = ( po.getLineItemArray().length ) * 17;
+    return hash;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POTopDownSaveSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POTopDownSaveSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POTopDownSaveSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POTopDownSaveSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,98 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.io.Reader;
+import java.util.Calendar;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.openuri.easypo.Customer;
+import org.openuri.easypo.LineItem;
+import org.openuri.easypo.PurchaseOrderDocument;
+import org.openuri.easypo.Shipper;
+import org.openuri.easypo.PurchaseOrderDocument.PurchaseOrder;
+
+
+public class POTopDownSaveSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+
+    POTopDownSaveSVN test = new POTopDownSaveSVN();
+    int iterations = Constants.ITERATIONS;
+    long cputime;
+    int hash = 0;
+        
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run();
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run();
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run() throws Exception
+  {
+    // create the purchase order
+    PurchaseOrderDocument podoc = PurchaseOrderDocument.Factory.newInstance();
+    PurchaseOrder po = podoc.addNewPurchaseOrder();
+
+    // create and initialize customer
+    Customer customer = po.addNewCustomer();
+    customer.setName(Constants.PO_CUSTOMER_NAME);
+    customer.setAddress(Constants.PO_CUSTOMER_ADDR);
+
+    // set the date
+    po.setDate(Calendar.getInstance());
+
+    // create and initialize the line item array
+    for (int i=0; i<Constants.PO_NUM_LINEITEMS; i++)
+    {
+      LineItem li = po.addNewLineItem();
+      li.setDescription(Constants.PO_LI_DESC);
+      li.setPerUnitOunces(Constants.PO_LI_PUO);
+      li.setPrice(Constants.PO_LI_PRICE);
+      li.setQuantity(Constants.PO_LI_QUANTITY);
+    }
+
+    // create and initialize the shipper
+    Shipper shipper = po.addNewShipper();
+    shipper.setName(Constants.PO_SHIPPER_NAME);
+    shipper.setPerOunceRate(Constants.PO_SHIPPER_POR);
+
+    // grab the instance that was constructed
+    Reader reader = po.newReader();
+    int c;
+    while( (c=reader.read()) != -1){}
+    if(null != reader) reader.close();
+
+    // calculate a hash to return
+    int hash = ( po.getLineItemArray().length ) * 17;
+    return hash;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POValidateXmlObjSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POValidateXmlObjSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POValidateXmlObjSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/POValidateXmlObjSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,93 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import java.io.CharArrayReader;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.apache.xmlbeans.test.performance.utils.PerfUtil;
+import org.openuri.easypo.PurchaseOrderDocument;
+
+public class POValidateXmlObjSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+
+    final int iterations = Constants.ITERATIONS;
+    String filename;
+
+    if(args.length == 0){
+      filename = Constants.PO_INSTANCE_1;
+    }
+    else if(args[0].length() > 1){
+      filename = Constants.XSD_DIR+Constants.P+args[0];
+    }
+    else{
+      switch( Integer.parseInt(args[0]) )
+      {
+      case 1: filename = Constants.PO_INSTANCE_1; break;
+      case 2: filename = Constants.PO_INSTANCE_2; break;  
+      case 3: filename = Constants.PO_INSTANCE_3; break;
+      case 4: filename = Constants.PO_INSTANCE_4; break;
+      case 5: filename = Constants.PO_INSTANCE_5; break;
+      case 6: filename = Constants.PO_INSTANCE_6; break;
+      case 7: filename = Constants.PO_INSTANCE_7; break;
+      default: filename = Constants.PO_INSTANCE_1; break;
+      }
+    }    
+
+    POValidateXmlObjSVN test = new POValidateXmlObjSVN();
+    PerfUtil util = new PerfUtil();
+    long cputime;
+    int hash = 0;
+
+    // get the xmlinstance
+    char[] chars = util.fileToChars(filename);
+    
+    
+    // parse the instance
+    PurchaseOrderDocument podoc = 
+      PurchaseOrderDocument.Factory.parse(new CharArrayReader(chars));
+
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){     
+      hash += test.run(podoc);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){     
+      hash += test.run(podoc);
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" filesize="+chars.length+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run(PurchaseOrderDocument p_podoc) throws Exception
+  {
+    // validate it
+    p_podoc.validate();
+
+    // return an int for the hash
+    return 17;
+  }
+}

Added: xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/PrimTopDownSVN.java
URL: http://svn.apache.org/viewcvs/xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/PrimTopDownSVN.java?rev=233577&view=auto
==============================================================================
--- xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/PrimTopDownSVN.java (added)
+++ xmlbeans/trunk/test/perf/src/org/apache/xmlbeans/test/performance/svn/PrimTopDownSVN.java Fri Aug 19 16:32:14 2005
@@ -0,0 +1,81 @@
+/*   Copyright 2004 The Apache Software Foundation
+*
+*   Licensed 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.xmlbeans.test.performance.svn;
+
+import org.apache.xmlbeans.test.performance.utils.Constants;
+import org.openuri.primitives.Misc;
+import org.openuri.primitives.Numerics;
+import org.openuri.primitives.PrimitivesDocument;
+import org.openuri.primitives.PrimitivesDocument.Primitives;
+
+public class PrimTopDownSVN
+{
+  public static void main(String[] args) throws Exception
+  {
+
+    PrimTopDownSVN test = new PrimTopDownSVN();
+    int iterations = Constants.ITERATIONS;
+    long cputime;
+    int hash = 0;
+        
+    // warm up the vm
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run();
+    }
+    cputime = System.currentTimeMillis() - cputime;
+
+    // run it again for the real measurement
+    cputime = System.currentTimeMillis();
+    for(int i=0; i<iterations; i++){
+      hash += test.run();
+    }
+    cputime = System.currentTimeMillis() - cputime;
+      
+    // print the results
+    // Class.getSimpleName() is only provided in jdk1.5, so have to trim package name off test name for logging to support 1.4
+    System.out.print(Constants.DELIM+test.getClass().getName().substring(test.getClass().getName().lastIndexOf('.')+1)+" ");
+    System.out.print("hash "+hash+" ");
+    System.out.print("time "+cputime+"\n");
+  }
+
+  private int run() throws Exception
+  {
+    // create the doc
+    PrimitivesDocument doc = PrimitivesDocument.Factory.newInstance();
+    Primitives prim = doc.addNewPrimitives();
+
+    // create and initialize numeric elements
+    for(int i=0; i<Constants.PO_NUM_LINEITEMS; i++)
+    {
+      Numerics numerics = prim.addNewNumerics();
+      numerics.setMybyte(Constants.myByte);
+      numerics.setMyint(Constants.myInt);
+      numerics.setMylong(Constants.myLong);
+      numerics.setMyshort(Constants.myShort);
+      numerics.setMyhexbin(Constants.myHexbin);
+      numerics.setMydouble(Constants.myDouble);
+      numerics.setMyfloat(Constants.myFloat);
+    }
+
+    // create and initialize the misc element
+    Misc misc = prim.addNewMisc();
+    misc.setMybool(Constants.myBool);
+
+    // calculate a hash to return
+    int hash = ( prim.getNumericsArray().length ) * 17;
+    return hash;
+  }
+}



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


Mime
View raw message