Source Code Cross Referenced for ObjectHashMapTest2.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Rule Engine » drolls Rule Engine » org.drools.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.util;
002:
003:        import junit.framework.TestCase;
004:        import org.drools.util.ObjectHashMap;
005:
006:        public class ObjectHashMapTest2 extends TestCase {
007:
008:            public ObjectHashMapTest2() {
009:                super ();
010:            }
011:
012:            public void testJUHashmap() {
013:                final java.util.HashMap map = new java.util.HashMap();
014:                assertNotNull(map);
015:                final int count = 1000;
016:                for (int idx = 0; idx < count; idx++) {
017:                    final String key = "key" + idx;
018:                    final String val = "value" + idx;
019:                    map.put(key, val);
020:                    assertEquals(val, map.get(key));
021:                }
022:            }
023:
024:            public void testStringData() {
025:                final ObjectHashMap map = new ObjectHashMap();
026:                assertNotNull(map);
027:                final int count = 1000;
028:                for (int idx = 0; idx < count; idx++) {
029:                    final String key = "key" + idx;
030:                    final String val = "value" + idx;
031:                    map.put(key, val);
032:                    assertEquals(val, map.get(key));
033:                }
034:            }
035:
036:            public void testStringDataDupFalse() {
037:                final ObjectHashMap map = new ObjectHashMap();
038:                assertNotNull(map);
039:                final int count = 10000;
040:                for (int idx = 0; idx < count; idx++) {
041:                    final String key = "key" + idx;
042:                    final String val = "value" + idx;
043:                    map.put(key, val, false);
044:                    assertEquals(val, map.get(key));
045:                }
046:            }
047:
048:            public void testIntegerData() {
049:                final ObjectHashMap map = new ObjectHashMap();
050:                assertNotNull(map);
051:                final int count = 1000;
052:                for (int idx = 0; idx < count; idx++) {
053:                    final Integer key = new Integer(idx);
054:                    final Integer val = new Integer(idx);
055:                    map.put(key, val);
056:                    assertEquals(val, map.get(key));
057:                }
058:            }
059:
060:            public void testJUHashMap1() {
061:                final int count = 100000;
062:                final java.util.HashMap map = new java.util.HashMap();
063:                assertNotNull(map);
064:                final long start = System.currentTimeMillis();
065:                for (int idx = 0; idx < count; idx++) {
066:                    final String key = "key" + idx;
067:                    final String strval = "value" + idx;
068:                    map.put(key, strval);
069:                }
070:                final long end = System.currentTimeMillis();
071:                System.out.println("java.util.HashMap put(key,value) ET - "
072:                        + ((end - start)));
073:            }
074:
075:            public void testStringData2() {
076:                final int count = 100000;
077:                final ObjectHashMap map = new ObjectHashMap();
078:                assertNotNull(map);
079:                final long start = System.currentTimeMillis();
080:                for (int idx = 0; idx < count; idx++) {
081:                    final String key = "key" + idx;
082:                    final String strval = "value" + idx;
083:                    map.put(key, strval);
084:                }
085:                final long end = System.currentTimeMillis();
086:                System.out.println("Custom ObjectHashMap put(key,value) ET - "
087:                        + ((end - start)));
088:            }
089:
090:            public void testStringData3() {
091:                final int count = 100000;
092:                final ObjectHashMap map = new ObjectHashMap();
093:                assertNotNull(map);
094:                for (int idx = 0; idx < count; idx++) {
095:                    final String key = "key" + idx;
096:                    final String strval = "value" + idx;
097:                    map.put(key, strval);
098:                }
099:                final long start = System.currentTimeMillis();
100:                for (int idx = 0; idx < count; idx++) {
101:                    final String key = "key" + idx;
102:                    map.get(key);
103:                }
104:                final long end = System.currentTimeMillis();
105:                System.out.println("Custom ObjectHashMap get(key) ET - "
106:                        + ((end - start)));
107:            }
108:
109:            public void testJUHashMap2() {
110:                final int count = 100000;
111:                final java.util.HashMap map = new java.util.HashMap();
112:                assertNotNull(map);
113:                for (int idx = 0; idx < count; idx++) {
114:                    final String key = "key" + idx;
115:                    final String strval = "value" + idx;
116:                    map.put(key, strval);
117:                }
118:                final long start = System.currentTimeMillis();
119:                for (int idx = 0; idx < count; idx++) {
120:                    final String key = "key" + idx;
121:                    map.get(key);
122:                }
123:                final long end = System.currentTimeMillis();
124:                System.out.println("java.util.HashMap get(key) ET - "
125:                        + ((end - start)));
126:            }
127:
128:            public void testStringData4() {
129:                final int count = 100000;
130:                final ObjectHashMap map = new ObjectHashMap();
131:                assertNotNull(map);
132:                for (int idx = 0; idx < count; idx++) {
133:                    final String key = "key" + idx;
134:                    final String strval = "value" + idx;
135:                    map.put(key, strval);
136:                }
137:                final long start = System.currentTimeMillis();
138:                final org.drools.util.Iterator itr = map.iterator();
139:                Object val = null;
140:                while ((val = itr.next()) != null) {
141:                    val.hashCode();
142:                }
143:                final long end = System.currentTimeMillis();
144:                System.out.println("Custom ObjectHashMap iterate ET - "
145:                        + ((end - start)));
146:            }
147:
148:            public void testJUHashMap3() {
149:                final int count = 100000;
150:                final java.util.HashMap map = new java.util.HashMap();
151:                assertNotNull(map);
152:                for (int idx = 0; idx < count; idx++) {
153:                    final String key = "key" + idx;
154:                    final String strval = "value" + idx;
155:                    map.put(key, strval);
156:                }
157:                final long start = System.currentTimeMillis();
158:                final java.util.Iterator itr = map.values().iterator();
159:                while (itr.hasNext()) {
160:                    itr.next().hashCode();
161:                }
162:                final long end = System.currentTimeMillis();
163:                System.out.println("java.util.HashMap iterate ET - "
164:                        + ((end - start)));
165:            }
166:
167:            public void testStringData5() {
168:                final int count = 100000;
169:                final ObjectHashMap map = new ObjectHashMap();
170:                assertNotNull(map);
171:                final long start = System.currentTimeMillis();
172:                for (int idx = 0; idx < count; idx++) {
173:                    final String key = "key" + idx;
174:                    final String strval = "value" + idx;
175:                    map.put(key, strval, false);
176:                }
177:                final long end = System.currentTimeMillis();
178:                System.out.println("Custom ObjectHashMap dup false ET - "
179:                        + ((end - start)));
180:            }
181:
182:            public static void main(final String[] args) {
183:                final ObjectHashMapTest2 test = new ObjectHashMapTest2();
184:                final int loop = 5;
185:                for (int idx = 0; idx < loop; idx++) {
186:                    test.testIntegerData();
187:                    test.testStringData();
188:                    test.testJUHashmap();
189:                    test.testStringData2();
190:                    test.testJUHashMap1();
191:                    test.testStringData3();
192:                    test.testJUHashMap2();
193:                    test.testStringData4();
194:                    test.testJUHashMap3();
195:                    test.testStringData5();
196:                    test.testStringDataDupFalse();
197:                    System.out.println(" --------------- ");
198:                }
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.