[jboss-svn-commits] JBL Code SVN: r7755 - labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Nov 21 22:20:29 EST 2006


Author: woolfel
Date: 2006-11-21 22:20:28 -0500 (Tue, 21 Nov 2006)
New Revision: 7755

Modified:
   labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest2.java
Log:
updated the test and changed to nanoTime
peter

Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest2.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest2.java	2006-11-22 00:08:58 UTC (rev 7754)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/util/ObjectHashMapTest2.java	2006-11-22 03:20:28 UTC (rev 7755)
@@ -33,6 +33,18 @@
 		}
 	}
 
+	public void testStringDataDupFalse() {
+		ObjectHashMap map = new ObjectHashMap();
+		assertNotNull(map);
+		int count = 10000;
+		for (int idx=0; idx < count; idx++) {
+			String key = "key" + idx;
+			String val = "value" + idx;
+			map.put(key, val,false);
+			assertEquals(val,map.get(key));
+		}
+	}
+
 	public void testIntegerData() {
 		ObjectHashMap map = new ObjectHashMap();
 		assertNotNull(map);
@@ -49,28 +61,28 @@
 		int count = 100000;
 		ObjectHashMap map = new ObjectHashMap();
 		assertNotNull(map);
-		long start = System.currentTimeMillis();
+		long start = System.nanoTime();
 		for (int idx=0; idx < count; idx++) {
 			String key = "key" + idx;
 			String strval = "value" + idx;
 			map.put(key,strval);
 		}
-		long end = System.currentTimeMillis();
-		System.out.println("Custom ObjectHashMap ET - " + (end-start));
+		long end = System.nanoTime();
+		System.out.println("Custom ObjectHashMap put(key,value) ET - " + ((end-start)/1000000));
 	}
 	
 	public void testJUHashMap1() {
 		int count = 100000;
 		java.util.HashMap map = new java.util.HashMap();
 		assertNotNull(map);
-		long start = System.currentTimeMillis();
+		long start = System.nanoTime();
 		for (int idx=0; idx < count; idx++) {
 			String key = "key" + idx;
 			String strval = "value" + idx;
 			map.put(key,strval);
 		}
-		long end = System.currentTimeMillis();
-		System.out.println("java.util.HashMap ET - " + (end-start));
+		long end = System.nanoTime();
+		System.out.println("java.util.HashMap put(key,value) ET - " + ((end-start)/1000000));
 	}
 
 	public void testStringData3() {
@@ -82,13 +94,13 @@
 			String strval = "value" + idx;
 			map.put(key,strval);
 		}
-		long start = System.currentTimeMillis();
+		long start = System.nanoTime();
 		for (int idx=0; idx < count; idx++) {
 			String key = "key" + idx;
 			map.get(key);
 		}
-		long end = System.currentTimeMillis();
-		System.out.println("Custom ObjectHashMap get(key) ET - " + (end-start));
+		long end = System.nanoTime();
+		System.out.println("Custom ObjectHashMap get(key) ET - " + ((end-start)/1000000));
 	}
 	
 	public void testJUHashMap2() {
@@ -100,13 +112,13 @@
 			String strval = "value" + idx;
 			map.put(key,strval);
 		}
-		long start = System.currentTimeMillis();
+		long start = System.nanoTime();
 		for (int idx=0; idx < count; idx++) {
 			String key = "key" + idx;
 			map.get(key);
 		}
-		long end = System.currentTimeMillis();
-		System.out.println("java.util.HashMap get(key) ET - " + (end-start));
+		long end = System.nanoTime();
+		System.out.println("java.util.HashMap get(key) ET - " + ((end-start)/1000000));
 	}
 	
 	public void testStringData4() {
@@ -118,14 +130,14 @@
 			String strval = "value" + idx;
 			map.put(key,strval);
 		}
-		long start = System.currentTimeMillis();
+		long start = System.nanoTime();
 		org.drools.util.Iterator itr = map.iterator();
 		Object val = null;
 		while ( (val = itr.next()) != null) {
 			val.hashCode();
 		}
-		long end = System.currentTimeMillis();
-		System.out.println("Custom ObjectHashMap iterate ET - " + (end-start));
+		long end = System.nanoTime();
+		System.out.println("Custom ObjectHashMap iterate ET - " + ((end-start)/1000000));
 	}
 
 	public void testJUHashMap3() {
@@ -137,13 +149,46 @@
 			String strval = "value" + idx;
 			map.put(key,strval);
 		}
-		long start = System.currentTimeMillis();
+		long start = System.nanoTime();
 		java.util.Iterator itr = map.values().iterator();
 		Object val = null;
 		while ( itr.hasNext()) {
 			itr.next().hashCode();
 		}
-		long end = System.currentTimeMillis();
-		System.out.println("java.util.HashMap iterate ET - " + (end-start));
+		long end = System.nanoTime();
+		System.out.println("java.util.HashMap iterate ET - " + ((end-start)/1000000));
 	}
+	
+	public void testStringData5() {
+		int count = 100000;
+		ObjectHashMap map = new ObjectHashMap();
+		assertNotNull(map);
+		long start = System.nanoTime();
+		for (int idx=0; idx < count; idx++) {
+			String key = "key" + idx;
+			String strval = "value" + idx;
+			map.put(key,strval,false);
+		}
+		long end = System.nanoTime();
+		System.out.println("Custom ObjectHashMap dup false ET - " + ((end-start)/1000000));
+	}
+	
+	public static void main(String[] args) {
+		ObjectHashMapTest2 test = new ObjectHashMapTest2();
+		int loop = 5;
+		for (int idx=0; idx < loop; idx++) {
+			test.testIntegerData();
+			test.testStringData();
+			test.testJUHashmap();
+			test.testStringData2();
+			test.testJUHashMap1();
+			test.testStringData3();
+			test.testJUHashMap2();
+			test.testStringData4();
+			test.testJUHashMap3();
+			test.testStringData5();
+			test.testStringDataDupFalse();
+			System.out.println(" --------------- ");
+		}
+	}
 }
\ No newline at end of file




More information about the jboss-svn-commits mailing list