2 *******************************************************************************
\r
3 * Copyright (C) 2001-2004, International Business Machines Corporation and *
\r
4 * others. All Rights Reserved. *
\r
5 *******************************************************************************
\r
8 package com.ibm.icu.dev.test.perf;
\r
10 import com.ibm.icu.lang.UCharacter;
\r
13 * Base performance test that takes in a method name for testing with JDK.
\r
16 * java com.ibm.icu.dev.test.perf.UCharacterPerf $MethodName $LoopCount -
\r
17 * $START_TEST_CHARACTER $END_TEST_CHARACTER
\r
19 * where $*_TEST_CHARACTER are in hex decimals with a leading 0x
\r
21 public final class UCharacterPerf extends PerfTest
\r
23 // public methods ------------------------------------------------------
\r
25 public static void main(String[] args) throws Exception
\r
27 new UCharacterPerf().run(args);
\r
28 // new UCharacterPerf().TestPerformance();
\r
31 protected void setup(String[] args) {
\r
32 // We only take one argument, the pattern
\r
33 MIN_ = Character.MIN_VALUE;
\r
34 MAX_ = Character.MAX_VALUE;
\r
35 if (args.length >= 1) {
\r
36 MIN_ = Integer.parseInt(args[0], 16);
\r
38 if (args.length >= 2) {
\r
39 MAX_ = Integer.parseInt(args[1], 16);
\r
43 PerfTest.Function testDigit()
\r
45 return new PerfTest.Function() {
\r
46 public void call() {
\r
47 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
48 UCharacter.digit(ch, 10);
\r
52 public long getOperationsPerIteration() {
\r
53 return MAX_ - MIN_ + 1;
\r
58 PerfTest.Function testJDKDigit()
\r
60 return new PerfTest.Function() {
\r
61 public void call() {
\r
62 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
63 Character.digit(ch, 10);
\r
67 public long getOperationsPerIteration() {
\r
68 return MAX_ - MIN_ + 1;
\r
73 PerfTest.Function testGetNumericValue()
\r
75 return new PerfTest.Function() {
\r
76 public void call() {
\r
77 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
78 UCharacter.getNumericValue(ch);
\r
82 public long getOperationsPerIteration() {
\r
83 return MAX_ - MIN_ + 1;
\r
88 PerfTest.Function testJDKGetNumericValue()
\r
90 return new PerfTest.Function() {
\r
91 public void call() {
\r
92 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
93 Character.getNumericValue(ch);
\r
97 public long getOperationsPerIteration() {
\r
98 return MAX_ - MIN_ + 1;
\r
103 PerfTest.Function testGetType()
\r
105 return new PerfTest.Function() {
\r
106 public void call() {
\r
107 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
108 UCharacter.getType(ch);
\r
112 public long getOperationsPerIteration() {
\r
113 return MAX_ - MIN_ + 1;
\r
118 PerfTest.Function testJDKGetType()
\r
120 return new PerfTest.Function() {
\r
121 public void call() {
\r
122 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
123 Character.getType(ch);
\r
127 public long getOperationsPerIteration() {
\r
128 return MAX_ - MIN_ + 1;
\r
133 PerfTest.Function testIsDefined()
\r
135 return new PerfTest.Function() {
\r
136 public void call() {
\r
137 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
138 UCharacter.isDefined(ch);
\r
142 public long getOperationsPerIteration() {
\r
143 return MAX_ - MIN_ + 1;
\r
148 PerfTest.Function testJDKIsDefined()
\r
150 return new PerfTest.Function() {
\r
151 public void call() {
\r
152 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
153 Character.isDefined(ch);
\r
157 public long getOperationsPerIteration() {
\r
158 return MAX_ - MIN_ + 1;
\r
163 PerfTest.Function testIsDigit()
\r
165 return new PerfTest.Function() {
\r
166 public void call() {
\r
167 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
168 UCharacter.isDigit(ch);
\r
172 public long getOperationsPerIteration() {
\r
173 return MAX_ - MIN_ + 1;
\r
178 PerfTest.Function testJDKIsDigit()
\r
180 return new PerfTest.Function() {
\r
181 public void call() {
\r
182 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
183 Character.isDigit(ch);
\r
187 public long getOperationsPerIteration() {
\r
188 return MAX_ - MIN_ + 1;
\r
193 PerfTest.Function testIsIdentifierIgnorable()
\r
195 return new PerfTest.Function() {
\r
196 public void call() {
\r
197 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
198 UCharacter.isIdentifierIgnorable(ch);
\r
202 public long getOperationsPerIteration() {
\r
203 return MAX_ - MIN_ + 1;
\r
208 PerfTest.Function testJDKIsIdentifierIgnorable()
\r
210 return new PerfTest.Function() {
\r
211 public void call() {
\r
212 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
213 Character.isIdentifierIgnorable(ch);
\r
217 public long getOperationsPerIteration() {
\r
218 return MAX_ - MIN_ + 1;
\r
223 PerfTest.Function testIsISOControl()
\r
225 return new PerfTest.Function() {
\r
226 public void call() {
\r
227 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
228 UCharacter.isISOControl(ch);
\r
232 public long getOperationsPerIteration() {
\r
233 return MAX_ - MIN_ + 1;
\r
238 PerfTest.Function testJDKIsISOControl()
\r
240 return new PerfTest.Function() {
\r
241 public void call() {
\r
242 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
243 Character.isISOControl(ch);
\r
247 public long getOperationsPerIteration() {
\r
248 return MAX_ - MIN_ + 1;
\r
253 PerfTest.Function testIsLetter()
\r
255 return new PerfTest.Function() {
\r
256 public void call() {
\r
257 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
258 UCharacter.isLetter(ch);
\r
262 public long getOperationsPerIteration() {
\r
263 return MAX_ - MIN_ + 1;
\r
268 PerfTest.Function testJDKIsLetter()
\r
270 return new PerfTest.Function() {
\r
271 public void call() {
\r
272 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
273 Character.isLetter(ch);
\r
277 public long getOperationsPerIteration() {
\r
278 return MAX_ - MIN_ + 1;
\r
283 PerfTest.Function testIsLetterOrDigit()
\r
285 return new PerfTest.Function() {
\r
286 public void call() {
\r
287 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
288 UCharacter.isLetterOrDigit(ch);
\r
292 public long getOperationsPerIteration() {
\r
293 return MAX_ - MIN_ + 1;
\r
298 PerfTest.Function testJDKIsLetterOrDigit()
\r
300 return new PerfTest.Function() {
\r
301 public void call() {
\r
302 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
303 Character.isLetterOrDigit(ch);
\r
307 public long getOperationsPerIteration() {
\r
308 return MAX_ - MIN_ + 1;
\r
313 PerfTest.Function testIsLowerCase()
\r
315 return new PerfTest.Function() {
\r
316 public void call() {
\r
317 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
318 UCharacter.isLowerCase(ch);
\r
322 public long getOperationsPerIteration() {
\r
323 return MAX_ - MIN_ + 1;
\r
328 PerfTest.Function testJDKIsLowerCase()
\r
330 return new PerfTest.Function() {
\r
331 public void call() {
\r
332 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
333 Character.isLowerCase(ch);
\r
337 public long getOperationsPerIteration() {
\r
338 return MAX_ - MIN_ + 1;
\r
343 PerfTest.Function testIsSpaceChar()
\r
345 return new PerfTest.Function() {
\r
346 public void call() {
\r
347 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
348 UCharacter.isSpaceChar(ch);
\r
352 public long getOperationsPerIteration() {
\r
353 return MAX_ - MIN_ + 1;
\r
358 PerfTest.Function testJDKIsSpaceChar()
\r
360 return new PerfTest.Function() {
\r
361 public void call() {
\r
362 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
363 Character.isSpaceChar(ch);
\r
367 public long getOperationsPerIteration() {
\r
368 return MAX_ - MIN_ + 1;
\r
373 PerfTest.Function testIsTitleCase()
\r
375 return new PerfTest.Function() {
\r
376 public void call() {
\r
377 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
378 UCharacter.isTitleCase(ch);
\r
382 public long getOperationsPerIteration() {
\r
383 return MAX_ - MIN_ + 1;
\r
388 PerfTest.Function testJDKIsTitleCase()
\r
390 return new PerfTest.Function() {
\r
391 public void call() {
\r
392 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
393 Character.isTitleCase(ch);
\r
397 public long getOperationsPerIteration() {
\r
398 return MAX_ - MIN_ + 1;
\r
403 PerfTest.Function testIsUnicodeIdentifierPart()
\r
405 return new PerfTest.Function() {
\r
406 public void call() {
\r
407 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
408 UCharacter.isUnicodeIdentifierPart(ch);
\r
412 public long getOperationsPerIteration() {
\r
413 return MAX_ - MIN_ + 1;
\r
418 PerfTest.Function testJDKIsUnicodeIdentifierPart()
\r
420 return new PerfTest.Function() {
\r
421 public void call() {
\r
422 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
423 Character.isUnicodeIdentifierPart(ch);
\r
427 public long getOperationsPerIteration() {
\r
428 return MAX_ - MIN_ + 1;
\r
433 PerfTest.Function testIsUnicodeIdentifierStart()
\r
435 return new PerfTest.Function() {
\r
436 public void call() {
\r
437 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
438 UCharacter.isUnicodeIdentifierStart(ch);
\r
442 public long getOperationsPerIteration() {
\r
443 return MAX_ - MIN_ + 1;
\r
448 PerfTest.Function testJDKIsUnicodeIdentifierStart()
\r
450 return new PerfTest.Function() {
\r
451 public void call() {
\r
452 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
453 Character.isUnicodeIdentifierStart(ch);
\r
457 public long getOperationsPerIteration() {
\r
458 return MAX_ - MIN_ + 1;
\r
463 PerfTest.Function testIsUpperCase()
\r
465 return new PerfTest.Function() {
\r
466 public void call() {
\r
467 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
468 UCharacter.isUpperCase(ch);
\r
472 public long getOperationsPerIteration() {
\r
473 return MAX_ - MIN_ + 1;
\r
478 PerfTest.Function testJDKIsUpperCase()
\r
480 return new PerfTest.Function() {
\r
481 public void call() {
\r
482 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
483 Character.isUpperCase(ch);
\r
487 public long getOperationsPerIteration() {
\r
488 return MAX_ - MIN_ + 1;
\r
493 PerfTest.Function testIsWhiteSpace()
\r
495 return new PerfTest.Function() {
\r
496 public void call() {
\r
497 for (int ch = MIN_; ch < MAX_; ch ++) {
\r
498 UCharacter.isWhitespace(ch);
\r
502 public long getOperationsPerIteration() {
\r
503 return MAX_ - MIN_ + 1;
\r
508 PerfTest.Function testJDKIsWhiteSpace()
\r
510 return new PerfTest.Function() {
\r
511 public void call() {
\r
512 for (char ch = (char)MIN_; ch < (char)MAX_; ch ++) {
\r
513 Character.isWhitespace(ch);
\r
517 public long getOperationsPerIteration() {
\r
518 return MAX_ - MIN_ + 1;
\r
523 // private data member --------------------------------------------------
\r
526 * Minimum codepoint to do test. Test is ran from MIN_ to MAX_
\r
528 private static int MIN_;
\r
530 * Minimum codepoint to do test. Test is ran from MIN_ to MAX_
\r
532 private static int MAX_;
\r