Source Code Cross Referenced for ResourceBundlePerf.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » test » perf » 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 » Internationalization Localization » icu4j » com.ibm.icu.dev.test.perf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         **********************************************************************
003:         * Copyright (c) 2006, International Business Machines
004:         * Corporation and others.  All Rights Reserved.
005:         **********************************************************************
006:         */
007:
008:        package com.ibm.icu.dev.test.perf;
009:
010:        import java.nio.ByteBuffer;
011:        import java.util.ResourceBundle;
012:
013:        import com.ibm.icu.impl.ICULocaleData;
014:        import com.ibm.icu.impl.ICUResourceBundle;
015:        import com.ibm.icu.util.UResourceBundle;
016:
017:        public class ResourceBundlePerf extends PerfTest {
018:
019:            private ICUResourceBundle icuRes = null;
020:            private ResourceBundle javaRes = null;
021:
022:            public static void main(String[] org_args) throws Exception {
023:                new ResourceBundlePerf().run(org_args);
024:            }
025:
026:            protected void setup(String[] args) {
027:                icuRes = (ICUResourceBundle) UResourceBundle.getBundleInstance(
028:                        "com/ibm/icu/dev/data/testdata", "testtypes");
029:                javaRes = ICULocaleData
030:                        .getResourceBundle("com.ibm.icu.dev.data",
031:                                "TestDataElements", "testtypes");
032:            }
033:
034:            PerfTest.Function TestResourceBundleConstructionJava() {
035:                return new PerfTest.Function() {
036:                    public void call() {
037:                        ICULocaleData.getResourceBundle("com.ibm.icu.dev.data",
038:                                "TestDataElements", "testtypes");
039:                    }
040:                };
041:            }
042:
043:            PerfTest.Function TestResourceBundleConstructionICU() {
044:                return new PerfTest.Function() {
045:                    public void call() {
046:                        UResourceBundle.getBundleInstance(
047:                                "com/ibm/icu/dev/data/testdata", "testtypes");
048:                    }
049:                };
050:            }
051:
052:            PerfTest.Function TestEmptyArrayJava() {
053:                return new PerfTest.Function() {
054:                    public void call() {
055:                        String[] s = javaRes.getStringArray("emptyarray");
056:                        if (s.length != 0)
057:                            throw new Error("not zero");
058:                    }
059:                };
060:            }
061:
062:            PerfTest.Function TestEmptyArrayICU() {
063:                return new PerfTest.Function() {
064:                    public void call() {
065:                        String[] s = icuRes.getStringArray("emptyarray");
066:                        if (s.length != 0)
067:                            throw new Error("not zero");
068:                    }
069:                };
070:            }
071:
072:            class GetStringJava extends PerfTest.Function {
073:                String key;
074:                String expected;
075:
076:                GetStringJava(String key, String expected) {
077:                    this .key = key;
078:                    this .expected = expected;
079:                }
080:
081:                public void call() {
082:                    String s = javaRes.getString(key);
083:                    if (!s.equals(expected))
084:                        throw new Error("not equal");
085:                }
086:            }
087:
088:            class GetStringIcu extends PerfTest.Function {
089:                String key;
090:                String expected;
091:
092:                GetStringIcu(String key, String expected) {
093:                    this .key = key;
094:                    this .expected = expected;
095:                }
096:
097:                public void call() {
098:                    String s = icuRes.getString(key);
099:                    if (!s.equals(expected))
100:                        throw new Error("not equal");
101:                }
102:            }
103:
104:            PerfTest.Function TestZeroTestJava() {
105:                return new GetStringJava("zerotest", "abc\u0000def");
106:            }
107:
108:            PerfTest.Function TestZeroTestICU() {
109:                return new GetStringIcu("zerotest", "abc\u0000def");
110:            }
111:
112:            PerfTest.Function TestEmptyExplicitStringJava() {
113:                return new GetStringJava("emptyexplicitstring", "");
114:            }
115:
116:            PerfTest.Function TestEmptyExplicitStringICU() {
117:                return new GetStringIcu("emptyexplicitstring", "");
118:            }
119:
120:            PerfTest.Function TestEmptyStringJava() {
121:                return new GetStringJava("emptystring", "");
122:            }
123:
124:            PerfTest.Function TestEmptyStringICU() {
125:                return new GetStringIcu("emptystring", "");
126:            }
127:
128:            class GetIntJava extends PerfTest.Function {
129:                String key;
130:                int expected;
131:
132:                GetIntJava(String key, int expected) {
133:                    this .key = key;
134:                    this .expected = expected;
135:                }
136:
137:                public void call() {
138:                    Integer t = (Integer) javaRes.getObject(key);
139:                    if (t.intValue() != expected)
140:                        throw new Error("not equal");
141:                }
142:            }
143:
144:            class GetIntIcu extends PerfTest.Function {
145:                String key;
146:                int expected;
147:
148:                GetIntIcu(String key, int expected) {
149:                    this .key = key;
150:                    this .expected = expected;
151:                }
152:
153:                public void call() {
154:                    ICUResourceBundle temp = icuRes.get(key);
155:                    int t = temp.getInt();
156:                    if (t != expected)
157:                        throw new Error("not equal");
158:                }
159:            }
160:
161:            PerfTest.Function TestGet123Java() {
162:                return new GetIntJava("onehundredtwentythree", 123);
163:            }
164:
165:            PerfTest.Function TestGet123ICU() {
166:                return new GetIntIcu("onehundredtwentythree", 123);
167:            }
168:
169:            PerfTest.Function TestGetEmptyIntJava() {
170:                return new GetIntJava("emptyint", 0);
171:            }
172:
173:            PerfTest.Function TestGetEmptyIntICU() {
174:                return new GetIntIcu("emptyint", 0);
175:            }
176:
177:            PerfTest.Function TestGetOneJava() {
178:                return new GetIntJava("one", 1);
179:            }
180:
181:            PerfTest.Function TestGetOneICU() {
182:                return new GetIntIcu("one", 1);
183:            }
184:
185:            PerfTest.Function TestGetMinusOneJava() {
186:                return new GetIntJava("minusone", -1);
187:            }
188:
189:            PerfTest.Function TestGetMinusOneICU() {
190:                return new GetIntIcu("minusone", -1);
191:            }
192:
193:            PerfTest.Function TestGetPlusOneJava() {
194:                return new GetIntJava("plusone", 1);
195:            }
196:
197:            PerfTest.Function TestGetPlusOneICU() {
198:                return new GetIntIcu("plusone", 1);
199:            }
200:
201:            PerfTest.Function TestGetMinusOneUintJava() { // TODO: no equivalence?
202:                return new PerfTest.Function() {
203:                    public void call() {
204:                        Integer t = (Integer) javaRes.getObject("minusone");
205:                        if (t.intValue() != -1)
206:                            throw new Error("not equal");
207:                    }
208:                };
209:            }
210:
211:            PerfTest.Function TestGetMinusOneUintICU() {
212:                return new PerfTest.Function() {
213:                    public void call() {
214:                        ICUResourceBundle sub = icuRes.get("minusone");
215:                        int t = sub.getUInt();
216:                        if (t != 0xFFFFFFF)
217:                            throw new Error("not equal");
218:                    }
219:                };
220:            }
221:
222:            class GetIvJava extends PerfTest.Function {
223:                String key;
224:                int[] expected;
225:
226:                GetIvJava(String key, int[] expected) {
227:                    this .key = key;
228:                    this .expected = expected;
229:                }
230:
231:                public void call() {
232:                    Integer[] iv = (Integer[]) javaRes.getObject(key);
233:                    for (int i = 0; i < iv.length; i++) {
234:                        if (expected[i] != iv[i].intValue())
235:                            throw new Error("not equal");
236:                    }
237:                }
238:            }
239:
240:            class GetIvIcu extends PerfTest.Function {
241:                String key;
242:                int[] expected;
243:
244:                GetIvIcu(String key, int[] expected) {
245:                    this .key = key;
246:                    this .expected = expected;
247:                }
248:
249:                public void call() {
250:                    ICUResourceBundle temp = icuRes.get(key);
251:                    int[] iv = temp.getIntVector();
252:                    for (int i = 0; i < iv.length; i++) {
253:                        if (expected[i] != iv[i])
254:                            throw new Error("not equal");
255:                    }
256:                }
257:            }
258:
259:            PerfTest.Function TestGetIntegerArrayJava() {
260:                return new GetIvJava("integerarray", new int[] { 1, 2, 3, -3,
261:                        4, 5, 6, 7 });
262:            }
263:
264:            PerfTest.Function TestGetIntegerArrayICU() {
265:                return new GetIvIcu("integerarray", new int[] { 1, 2, 3, -3, 4,
266:                        5, 6, 7 });
267:            }
268:
269:            PerfTest.Function TestGetEmptyIntegerArrayJava() {
270:                return new GetIvJava("emptyintv", new int[0]);
271:            }
272:
273:            PerfTest.Function TestGetEmptyIntegerArrayICU() {
274:                return new GetIvIcu("emptyintv", new int[0]);
275:            }
276:
277:            class GetBinaryIcu extends PerfTest.Function {
278:                String key;
279:                int expected_len;
280:
281:                GetBinaryIcu(String key, int expected_len) {
282:                    this .key = key;
283:                    this .expected_len = expected_len;
284:                }
285:
286:                public void call() {
287:                    ICUResourceBundle temp = icuRes.get(key);
288:                    ByteBuffer got = temp.getBinary();
289:                    if (got.remaining() != expected_len)
290:                        throw new Error("not the expected len");
291:                    for (int i = 0; i < got.remaining(); i++) {
292:                        byte b = got.get();
293:                        if (i != b)
294:                            throw new Error("not equal");
295:                    }
296:                }
297:            }
298:
299:            PerfTest.Function TestGetBinaryTestICU() {
300:                return new GetBinaryIcu("binarytest", 15);
301:            }
302:
303:            PerfTest.Function TestGetBinaryTestJava() {
304:                return new PerfTest.Function() {
305:                    public void call() {
306:                        byte[] t = (byte[]) javaRes.getObject("binarytest");
307:                        if (t.length != 15)
308:                            throw new Error("not equal");
309:                    }
310:                };
311:            }
312:
313:            PerfTest.Function TestGetEmptyBinaryICU() {
314:                return new GetBinaryIcu("emptybin", 0);
315:            }
316:
317:            PerfTest.Function TestGetEmptyBinaryJava() {
318:                return new PerfTest.Function() {
319:                    public void call() {
320:                        byte[] t = (byte[]) javaRes.getObject("emptybin");
321:                        if (t.length != 0)
322:                            throw new Error("not equal");
323:                    }
324:                };
325:            }
326:
327:            class GetMenuJava extends PerfTest.Function {
328:                String key;
329:                String[] expected;
330:
331:                GetMenuJava(String key, String[] expected) {
332:                    this .key = key;
333:                    this .expected = expected;
334:                }
335:
336:                public void call() {
337:                    int p = 0;
338:                    Object[][] menus = (Object[][]) javaRes.getObject(key);
339:                    int sizei = menus.length;
340:                    for (int i = 0; i < sizei; i++) {
341:                        String menu_name = (String) menus[i][0];
342:                        Object[][] menu_items = (Object[][]) menus[i][1];
343:                        if (!expected[p++].equals(menu_name))
344:                            throw new Error("not equal");
345:
346:                        int sizej = menu_items.length;
347:                        for (int j = 0; j < sizej; j++) {
348:                            String key = (String) menu_items[j][0];
349:                            String value = (String) menu_items[j][1];
350:                            if (!expected[p++].equals(key))
351:                                throw new Error("not equal");
352:                            if (!expected[p++].equals(value))
353:                                throw new Error("not equal");
354:                        }
355:                    }
356:
357:                }
358:            }
359:
360:            class GetMenuIcu extends PerfTest.Function {
361:                String key;
362:                String[] expected;
363:
364:                GetMenuIcu(String key, String[] expected) {
365:                    this .key = key;
366:                    this .expected = expected;
367:                }
368:
369:                public void call() {
370:                    int p = 0;
371:                    ICUResourceBundle menus = icuRes.get(key);
372:                    int sizei = menus.getSize();
373:                    for (int i = 0; i < sizei; i++) {
374:                        ICUResourceBundle menu = menus.get(i);
375:                        String menu_name = menu.getKey();
376:                        if (!expected[p++].equals(menu_name))
377:                            throw new Error("not equal");
378:
379:                        int sizej = menu.getSize();
380:                        for (int j = 0; j < sizej; j++) {
381:                            ICUResourceBundle menu_item = menu.get(j);
382:                            String key = menu_item.getKey();
383:                            String value = menu_item.getString();
384:                            if (!expected[p++].equals(key))
385:                                throw new Error("not equal");
386:                            if (!expected[p++].equals(value))
387:                                throw new Error("not equal");
388:                        }
389:                    }
390:
391:                }
392:            }
393:
394:            PerfTest.Function TestGetMenuJava() {
395:                String[] expected = new String[] { "file", "exit", "Exit",
396:                        "open", "Open", "save", "Save" };
397:                return new GetMenuJava("menu", expected);
398:            }
399:
400:            PerfTest.Function TestGetMenuICU() {
401:                String[] expected = new String[] { "file", "exit", "Exit",
402:                        "open", "Open", "save", "Save" };
403:                return new GetMenuIcu("menu", expected);
404:            }
405:
406:            PerfTest.Function TestGetEmptyMenuJava() {
407:                return new GetMenuJava("emptytable", new String[] {});
408:            }
409:
410:            PerfTest.Function TestGetEmptyMenuICU() {
411:                return new GetMenuIcu("emptytable", new String[] {});
412:            }
413:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.