]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/perf/charperf/charperf.cpp
1 /********************************************************************
3 * Copyright (C) 2002 IBM, Inc. All Rights Reserved.
5 ********************************************************************/
6 /*****************************************************************************
9 * Modification History:
11 * Syn Wee Quek First Version
12 ******************************************************************************
16 * This program tests character properties performance.
26 UOPTION_DEF("min", 'n', UOPT_REQUIRES_ARG
),
27 UOPTION_DEF("min", 'x', UOPT_REQUIRES_ARG
),
32 int main(int argc
, const char *argv
[])
34 UErrorCode status
= U_ZERO_ERROR
;
35 CharPerformanceTest
test(argc
, argv
, status
);
36 if (U_FAILURE(status
)){
39 if (test
.run() == FALSE
){
40 fprintf(stderr
, "FAILED: Tests could not be run please check the "
47 CharPerformanceTest::CharPerformanceTest(int32_t argc
, const char *argv
[],
49 : UPerfTest(argc
, argv
, status
)
51 if (status
== U_ILLEGAL_ARGUMENT_ERROR
){
52 fprintf(stderr
,gUsageString
, "charperf");
55 if (U_FAILURE(status
)){
56 fprintf(stderr
, "FAILED to create UPerfTest object. Error: %s\n",
61 if (_remainingArgc
< 0) {
62 // that means there are some -names not matched in the super class
63 // first tag is always skipped in u_parseArgs
64 int size
= - _remainingArgc
;
67 _remainingArgc
= u_parseArgs(argc
, (char**)argv
,
68 (int32_t)(sizeof(options
)/sizeof(options
[0])), options
);
73 if (options
[MIN_OPTION_
].doesOccur
) {
74 MIN_
= atoi(options
[MIN_OPTION_
].value
);
76 if (options
[MAX_OPTION_
].doesOccur
) {
77 MAX_
= atoi(options
[MAX_OPTION_
].value
);
81 CharPerformanceTest::~CharPerformanceTest()
85 UPerfFunction
* CharPerformanceTest::runIndexedTest(int32_t index
, UBool exec
,
90 TESTCASE(0, TestIsAlpha
);
91 TESTCASE(1, TestIsUpper
);
92 TESTCASE(2, TestIsLower
);
93 TESTCASE(3, TestIsDigit
);
94 TESTCASE(4, TestIsSpace
);
95 TESTCASE(5, TestIsAlphaNumeric
);
96 TESTCASE(6, TestIsPrint
);
97 TESTCASE(7, TestIsControl
);
98 TESTCASE(8, TestToLower
);
99 TESTCASE(9, TestToUpper
);
100 TESTCASE(10, TestIsWhiteSpace
);
101 TESTCASE(11, TestStdLibIsAlpha
);
102 TESTCASE(12, TestStdLibIsUpper
);
103 TESTCASE(13, TestStdLibIsLower
);
104 TESTCASE(14, TestStdLibIsDigit
);
105 TESTCASE(15, TestStdLibIsSpace
);
106 TESTCASE(16, TestStdLibIsAlphaNumeric
);
107 TESTCASE(17, TestStdLibIsPrint
);
108 TESTCASE(18, TestStdLibIsControl
);
109 TESTCASE(19, TestStdLibToLower
);
110 TESTCASE(20, TestStdLibToUpper
);
111 TESTCASE(21, TestStdLibIsWhiteSpace
);
119 UPerfFunction
* CharPerformanceTest::TestIsAlpha()
121 return new CharPerfFunction(isAlpha
, MIN_
, MAX_
);
124 UPerfFunction
* CharPerformanceTest::TestIsUpper()
126 return new CharPerfFunction(isUpper
, MIN_
, MAX_
);
129 UPerfFunction
* CharPerformanceTest::TestIsLower()
131 return new CharPerfFunction(isLower
, MIN_
, MAX_
);
134 UPerfFunction
* CharPerformanceTest::TestIsDigit()
136 return new CharPerfFunction(isDigit
, MIN_
, MAX_
);
139 UPerfFunction
* CharPerformanceTest::TestIsSpace()
141 return new CharPerfFunction(isSpace
, MIN_
, MAX_
);
144 UPerfFunction
* CharPerformanceTest::TestIsAlphaNumeric()
146 return new CharPerfFunction(isAlphaNumeric
, MIN_
, MAX_
);
150 * This test may be different since c lib has a type PUNCT and it is printable.
151 * iswgraph is not used for testing since it is a subset of iswprint with the
152 * exception of returning true for white spaces. no match found in icu4c.
154 UPerfFunction
* CharPerformanceTest::TestIsPrint()
156 return new CharPerfFunction(isPrint
, MIN_
, MAX_
);
159 UPerfFunction
* CharPerformanceTest::TestIsControl()
161 return new CharPerfFunction(isControl
, MIN_
, MAX_
);
164 UPerfFunction
* CharPerformanceTest::TestToLower()
166 return new CharPerfFunction(toLower
, MIN_
, MAX_
);
169 UPerfFunction
* CharPerformanceTest::TestToUpper()
171 return new CharPerfFunction(toUpper
, MIN_
, MAX_
);
174 UPerfFunction
* CharPerformanceTest::TestIsWhiteSpace()
176 return new CharPerfFunction(isWhiteSpace
, MIN_
, MAX_
);
179 UPerfFunction
* CharPerformanceTest::TestStdLibIsAlpha()
181 return new StdLibCharPerfFunction(StdLibIsAlpha
, (wchar_t)MIN_
,
185 UPerfFunction
* CharPerformanceTest::TestStdLibIsUpper()
187 return new StdLibCharPerfFunction(StdLibIsUpper
, (wchar_t)MIN_
,
191 UPerfFunction
* CharPerformanceTest::TestStdLibIsLower()
193 return new StdLibCharPerfFunction(StdLibIsLower
, (wchar_t)MIN_
,
197 UPerfFunction
* CharPerformanceTest::TestStdLibIsDigit()
199 return new StdLibCharPerfFunction(StdLibIsDigit
, (wchar_t)MIN_
,
203 UPerfFunction
* CharPerformanceTest::TestStdLibIsSpace()
205 return new StdLibCharPerfFunction(StdLibIsSpace
, (wchar_t)MIN_
,
209 UPerfFunction
* CharPerformanceTest::TestStdLibIsAlphaNumeric()
211 return new StdLibCharPerfFunction(StdLibIsAlphaNumeric
, (wchar_t)MIN_
,
216 * This test may be different since c lib has a type PUNCT and it is printable.
217 * iswgraph is not used for testing since it is a subset of iswprint with the
218 * exception of returning true for white spaces. no match found in icu4c.
220 UPerfFunction
* CharPerformanceTest::TestStdLibIsPrint()
222 return new StdLibCharPerfFunction(StdLibIsPrint
, (wchar_t)MIN_
,
226 UPerfFunction
* CharPerformanceTest::TestStdLibIsControl()
228 return new StdLibCharPerfFunction(StdLibIsControl
, (wchar_t)MIN_
,
232 UPerfFunction
* CharPerformanceTest::TestStdLibToLower()
234 return new StdLibCharPerfFunction(StdLibToLower
, (wchar_t)MIN_
,
238 UPerfFunction
* CharPerformanceTest::TestStdLibToUpper()
240 return new StdLibCharPerfFunction(StdLibToUpper
, (wchar_t)MIN_
,
244 UPerfFunction
* CharPerformanceTest::TestStdLibIsWhiteSpace()
246 return new StdLibCharPerfFunction(StdLibIsWhiteSpace
, (wchar_t)MIN_
,