You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2005/03/23 18:39:54 UTC
svn commit: r158806 - in
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1: ALAttr.java
ALElement.java LLAttr.java LLElement.java Tester.java
Author: dasarath
Date: Wed Mar 23 09:39:52 2005
New Revision: 158806
URL: http://svn.apache.org/viewcvs?view=rev&rev=158806
Log: (empty)
Added:
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALAttr.java
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLAttr.java
Modified:
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.java
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLElement.java
webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.java
Added: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALAttr.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/ALAttr.java?view=auto&rev=158806
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALAttr.java (added)
+++ webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALAttr.java Wed Mar 23 09:39:52 2005
@@ -0,0 +1,14 @@
+/*
+ * Created on Mar 22, 2005
+ */
+
+/**
+ * @author Dasarath Weeratunge
+ */
+public class ALAttr {
+ public String name;
+
+ public ALAttr(String name){
+ this.name= name;
+ }
+}
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=158805&r2=158806
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.java (original)
+++ webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/ALElement.java Wed Mar 23 09:39:52 2005
@@ -1,6 +1,8 @@
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Vector;
/**
* @author Dasarath
@@ -8,10 +10,22 @@
* @date Dec 30, 2004
*/
public class ALElement {
- ArrayList al;
+// ArrayList al;
+ Vector al;
+ HashMap attrs;
public ALElement() {
- al = new ArrayList();
+// al = new ArrayList();
+ al= new Vector();
+ attrs= new HashMap();
+ }
+
+ public void addAttr(ALAttr a){
+ attrs.put(a.name, a);
+ }
+
+ public void getAttr(String n){
+ attrs.get(n);
}
public void addChild(ALElement child) {
Added: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLAttr.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/LLAttr.java?view=auto&rev=158806
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLAttr.java (added)
+++ webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLAttr.java Wed Mar 23 09:39:52 2005
@@ -0,0 +1,17 @@
+/*
+ * Created on Mar 22, 2005
+ */
+
+/**
+ * @author Dasarath Weeratunge
+ */
+public class LLAttr {
+ public LLAttr nextSib, prevSib;
+ public String name;
+
+ public LLAttr(String name) {
+ nextSib= null;
+ prevSib= null;
+ this.name= name;
+ }
+}
Modified: webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/archive/java/scratch/dasarath/om/%241/LLElement.java?view=diff&r1=158805&r2=158806
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLElement.java (original)
+++ webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/LLElement.java Wed Mar 23 09:39:52 2005
@@ -10,11 +10,13 @@
*/
public class LLElement {
LLElement nextSib, prevSib, firstChild;
+ LLAttr fattr;
public LLElement() {
firstChild= null;
nextSib= null;
prevSib= null;
+ fattr= null;
}
public void addChild(LLElement child) {
@@ -27,6 +29,27 @@
}
firstChild= child;
}
+
+ public void addAttr(LLAttr a){
+ a.prevSib= null;
+ if (fattr == null)
+ a.nextSib = null;
+ else {
+ a.nextSib = fattr;
+ fattr.prevSib = a;
+ }
+ fattr = a;
+ }
+
+ public LLAttr getAttr(String n){
+ LLAttr a= fattr;
+ while (a != null) {
+ if (a.name.equals(n))
+ return a;
+ a= a.nextSib;
+ }
+ return null;
+ }
public LLElement traverse(){
LLElement e= firstChild;
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=158805&r2=158806
==============================================================================
--- webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.java (original)
+++ webservices/axis/trunk/archive/java/scratch/dasarath/om/$1/Tester.java Wed Mar 23 09:39:52 2005
@@ -10,6 +10,11 @@
*/
public class Tester {
public static final long N = 200;
+ public static final long M = 1000000;
+ private String[] names1= new String[10];
+ private String[] names2= new String[10];
+ private ALAttr[] attrsa= new ALAttr[10];
+ private LLAttr[] attrsl= new LLAttr[10];
private long numChildren;
@@ -18,6 +23,52 @@
Tester(long c, long t) {
numChildren = c;
numTraversals = t;
+ names1[3] = "m0ustUnderstand";
+ names1[2] = "mu1stUnderstand";
+ names1[7] = "mus2tUnderstand";
+ names1[4] = "must3Understand";
+ names1[9] = "mustU4nderstand";
+ names1[1] = "mustUn5derstand";
+ names1[5] = "mustUnd6erstand";
+ names1[8] = "mustUnde7rstand";
+ names1[6] = "mustUnder8stand";
+ names1[0] = "mustUnders9tand";
+
+ names2[0] = names1[3];
+ names2[1] = names1[2];
+ names2[2] = names1[7];
+ names2[3] = names1[4];
+ names2[4] = names1[9];
+ names2[5] = names1[1];
+ names2[6] = names1[5];
+ names2[7] = names1[8];
+ names2[8] = names1[6];
+ names2[9] = names1[0];
+
+ for (int i= 0; i < 10; i++){
+ attrsa[i]= new ALAttr(names1[i]);
+ attrsl[i]= new LLAttr(names1[i]);
+ }
+ }
+
+ void testLLAttr() throws Exception {
+ for (int i = 0; i < M; i++) {
+ LLElement e = new LLElement();
+ for (int j = 0; j < 4; j++)
+ e.addAttr(attrsl[j]);
+ for (int k = 0; k < 4; k++)
+ e.getAttr(names2[k]);
+ }
+ }
+
+ void testALAttr() throws Exception {
+ for (int i = 0; i < M; i++) {
+ ALElement e = new ALElement();
+ for (int j = 0; j < 4; j++)
+ e.addAttr(attrsa[j]);
+ for (int k = 0; k < 4; k++)
+ e.getAttr(names2[k]);
+ }
}
void testLLElement() throws Exception {
@@ -40,6 +91,20 @@
}
}
+ private static void testAttr() throws Exception {
+ Tester instance = new Tester(0, 0);
+ long t1 = System.currentTimeMillis();
+ instance.testALAttr();
+ long t2 = System.currentTimeMillis();
+ long r = (t2 - t1) / N;
+ System.out.println("ALAttr= " + r + "ms");
+ t1 = System.currentTimeMillis();
+ instance.testLLAttr();
+ t2 = System.currentTimeMillis();
+ r = (t2 - t1) / N;
+ System.out.println("=LLAttr= " + r + "ms");
+ }
+
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
@@ -57,6 +122,7 @@
}
public static void main(String[] args) throws Exception {
+ testAttr();
test(1000, 1, false);
test(10000, 1, false);