You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2005/03/23 08:48:36 UTC
svn commit: r158744 - in
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1: ALElement.class
ALElement.java LLElement.class Tester.class Tester.java summary.html
Author: dasarath
Date: Tue Mar 22 23:48:31 2005
New Revision: 158744
URL: http://svn.apache.org/viewcvs?view=rev&rev=158744
Log: (empty)
Added:
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/summary.html
Modified:
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.class
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.java
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLElement.class
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.class
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.java
Modified: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.class
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/ALElement.class?view=diff&r1=158743&r2=158744
==============================================================================
Binary files - no diff available.
Modified: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/ALElement.java?view=diff&r1=158743&r2=158744
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.java (original)
+++ webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.java Tue Mar 22 23:48:31 2005
@@ -1,40 +1,35 @@
+
import java.util.ArrayList;
import java.util.Iterator;
-/*
- * Created on Dec 30, 2004
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-
/**
* @author Dasarath
- *
+ *
* @date Dec 30, 2004
*/
public class ALElement {
ArrayList al;
- public static final int S= 100;
-
+
public ALElement() {
- al= new ArrayList(S);
+ al = new ArrayList();
}
public void addChild(ALElement child) {
- al.add(child);
+ al.add(child);
}
-
- public ALElement traverse(){
- ALElement e= null;
-
- Iterator iter= al.iterator();
- while (iter.hasNext())
- e= (ALElement)iter.next();
-
-/* int n= al.size();
- for (int i= 0; i < n; i++)
- e= (ALElement)al.get(i);
-*/ return e;
+
+ public ALElement traverse(boolean useIter) {
+ ALElement e = null;
+
+ if (useIter) {
+ Iterator iter = al.iterator();
+ while (iter.hasNext())
+ e = (ALElement) iter.next();
+ } else {
+ int n = al.size();
+ for (int i = 0; i < n; i++)
+ e = (ALElement) al.get(i);
+ }
+ return e;
}
-}
+}
\ No newline at end of file
Modified: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLElement.class
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/LLElement.class?view=diff&r1=158743&r2=158744
==============================================================================
Binary files - no diff available.
Modified: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.class
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/Tester.class?view=diff&r1=158743&r2=158744
==============================================================================
Binary files - no diff available.
Modified: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/Tester.java?view=diff&r1=158743&r2=158744
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.java (original)
+++ webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.java Tue Mar 22 23:48:31 2005
@@ -5,43 +5,67 @@
/**
* @author Dasarath
- *
+ *
* @date Dec 30, 2004
*/
public class Tester {
- public static final long N= 200;
- public static final long M= 10000;
- public static final long T= 100;
- void test1() throws Exception {
- for (int i= 0; i < N; i++) {
- LLElement e= new LLElement();
- for (int j= 0; j < M; j++)
+ public static final long N = 200;
+
+ private long numChildren;
+
+ private long numTraversals;
+
+ Tester(long c, long t) {
+ numChildren = c;
+ numTraversals = t;
+ }
+
+ void testLLElement() throws Exception {
+ for (int i = 0; i < N; i++) {
+ LLElement e = new LLElement();
+ for (int j = 0; j < numChildren; j++)
e.addChild(new LLElement());
- for (int k= 0; k < T; k++)
- e.traverse();
+ for (int k = 0; k < numTraversals; k++)
+ e.traverse();
}
}
- void test2() throws Exception {
- for (int i= 0; i < N; i++) {
- ALElement e= new ALElement();
- for (int j= 0; j < M; j++)
+ void testALElement(boolean useIter) throws Exception {
+ for (int i = 0; i < N; i++) {
+ ALElement e = new ALElement();
+ for (int j = 0; j < numChildren; j++)
e.addChild(new ALElement());
- for (int k= 0; k < T; k++)
- e.traverse();
+ for (int k = 0; k < numTraversals; k++)
+ e.traverse(useIter);
}
}
- public static void main(String[] args) {
- try {
- long t1= System.currentTimeMillis();
- new Tester().test2();
- long t2= System.currentTimeMillis();
- System.out.println((t2 - t1)/N);
- }
- catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ private static void test(long c, long t, boolean useIter) throws Exception {
+ Tester instance = new Tester(c, t);
+ System.out.println("children= " + c + ", traversals= " + t
+ + "using iterator= " + useIter);
+ long t1 = System.currentTimeMillis();
+ instance.testLLElement();
+ long t2 = System.currentTimeMillis();
+ long r = (t2 - t1) / N;
+ System.out.println("LLElement= " + r + "ms");
+ t1 = System.currentTimeMillis();
+ instance.testALElement(useIter);
+ t2 = System.currentTimeMillis();
+ r = (t2 - t1) / N;
+ System.out.println("ALElement= " + r + "ms");
+ }
+
+ public static void main(String[] args) throws Exception {
+ test(1000, 1, false);
+ test(10000, 1, false);
+
+ test(100, 100, false);
+ test(100, 1000, false);
+ test(100, 10000, false);
+
+ test(100, 100, true);
+ test(100, 1000, true);
+ test(100, 10000, true);
}
-}
+}
\ No newline at end of file
Added: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/summary.html
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/summary.html?view=auto&rev=158744
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/summary.html (added)
+++ webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/summary.html Tue Mar 22 23:48:31 2005
@@ -0,0 +1,87 @@
+<html>
+<body>
+<p>
+This is a performance summary of 2 implementations of Element interface in AXIOM.
+One implementation uses <code>java.util.ArrayList</code> to hold child elements while the other
+keeps pointers to the first child and next/previous sibling in each element-- thus
+burning in the linked list into Element class itself. The latter as you know is what
+is used in AXIOM at the moment. However, recently there have been some discussion
+as to whether that is the right way to go...
+</p><p>
+Each row in the table below shows one set of test results. Each test comprised of first
+creating an Element, then adding a number of child elements and finally traversing all
+ the child elements added. The number of child elements added and the number
+ of traversals performed have been varied. Two approaches were used for traversing
+ the children when using an <code>ArrayList</code>. One used an <code>Iterator</code> while the other used
+ a 'for' loop. The details can be found by inspecting the code
+ (<a href="ALElement.java">ALElement</a>, <a href="LLElement.java">LLElement</a>).
+</p>
+<p>Have a look at the <a href="Tester.java"><code>Tester</code></a> for info on how
+the test was carried out.</p>
+<table border="2">
+<tr>
+<td>children</td>
+<td>traversals</td>
+<td>using iterator</td>
+<td>time(ms)/LLElement</td>
+<td>time(ms)/ALElement</td>
+</tr>
+<tr>
+<td>1000</td>
+<td>1</td>
+<td>no</td>
+<td>0</td>
+<td>0</td>
+</tr>
+<tr>
+<td>10000</td>
+<td>1</td>
+<td>no</td>
+<td>2</td>
+<td>22</td>
+</tr>
+<tr>
+<td>100</td>
+<td>100</td>
+<td>no</td>
+<td>0</td>
+<td>0</td>
+</tr>
+<tr>
+<td>100</td>
+<td>1000</td>
+<td>no</td>
+<td>0</td>
+<td>2</td>
+</tr>
+<tr>
+<td>100</td>
+<td>10000</td>
+<td>no</td>
+<td>6</td>
+<td>27</td>
+</tr>
+<tr>
+<td>100</td>
+<td>100</td>
+<td>yes</td>
+<td>0</td>
+<td>0</td>
+</tr>
+<tr>
+<td>100</td>
+<td>1000</td>
+<td>yes</td>
+<td>0</td>
+<td>7</td>
+</tr>
+<tr>
+<td>100</td>
+<td>10000</td>
+<td>yes</td>
+<td>6</td>
+<td>72</td>
+</tr>
+</table>
+</body>
+</html>
\ No newline at end of file