2 **********************************************************************
3 * Copyright (C) 2016 and later: Unicode, Inc. and others.
4 * License & terms of use: http://www.unicode.org/copyright.html#License
5 **********************************************************************
6 **********************************************************************
7 * Copyright (c) 2002-2006, International Business Machines
8 * Corporation and others. All Rights Reserved.
9 **********************************************************************
10 **********************************************************************
15 #include "unicode/uchar.h"
17 #include "unicode/uperf.h"
23 typedef void (*CharPerfFn)(UChar32 ch);
24 typedef void (*StdLibCharPerfFn)(wchar_t ch);
26 class CharPerfFunction : public UPerfFunction
29 virtual void call(UErrorCode* status)
31 for (UChar32 i = MIN_; i < MAX_; i ++) {
36 virtual long getOperationsPerIteration()
40 CharPerfFunction(CharPerfFn func, UChar32 min, UChar32 max)
53 class StdLibCharPerfFunction : public UPerfFunction
56 virtual void call(UErrorCode* status)
58 // note wchar_t is unsigned, it will revert to 0 once it reaches
60 for (wchar_t i = MIN_; i < MAX_; i ++) {
65 virtual long getOperationsPerIteration()
70 StdLibCharPerfFunction(StdLibCharPerfFn func, wchar_t min, wchar_t max)
77 ~StdLibCharPerfFunction()
82 StdLibCharPerfFn m_fn_;
87 class CharPerformanceTest : public UPerfTest
90 CharPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status);
91 ~CharPerformanceTest();
92 virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,
95 UPerfFunction* TestIsAlpha();
96 UPerfFunction* TestIsUpper();
97 UPerfFunction* TestIsLower();
98 UPerfFunction* TestIsDigit();
99 UPerfFunction* TestIsSpace();
100 UPerfFunction* TestIsAlphaNumeric();
101 UPerfFunction* TestIsPrint();
102 UPerfFunction* TestIsControl();
103 UPerfFunction* TestToLower();
104 UPerfFunction* TestToUpper();
105 UPerfFunction* TestIsWhiteSpace();
106 UPerfFunction* TestStdLibIsAlpha();
107 UPerfFunction* TestStdLibIsUpper();
108 UPerfFunction* TestStdLibIsLower();
109 UPerfFunction* TestStdLibIsDigit();
110 UPerfFunction* TestStdLibIsSpace();
111 UPerfFunction* TestStdLibIsAlphaNumeric();
112 UPerfFunction* TestStdLibIsPrint();
113 UPerfFunction* TestStdLibIsControl();
114 UPerfFunction* TestStdLibToLower();
115 UPerfFunction* TestStdLibToUpper();
116 UPerfFunction* TestStdLibIsWhiteSpace();
123 inline void isAlpha(UChar32 ch)
128 inline void isUpper(UChar32 ch)
133 inline void isLower(UChar32 ch)
138 inline void isDigit(UChar32 ch)
143 inline void isSpace(UChar32 ch)
148 inline void isAlphaNumeric(UChar32 ch)
154 * This test may be different since c lib has a type PUNCT and it is printable.
155 * iswgraph is not used for testing since it is a subset of iswprint with the
156 * exception of returning true for white spaces. no match found in icu4c.
158 inline void isPrint(UChar32 ch)
163 inline void isControl(UChar32 ch)
168 inline void toLower(UChar32 ch)
173 inline void toUpper(UChar32 ch)
178 inline void isWhiteSpace(UChar32 ch)
183 inline void StdLibIsAlpha(wchar_t ch)
188 inline void StdLibIsUpper(wchar_t ch)
193 inline void StdLibIsLower(wchar_t ch)
198 inline void StdLibIsDigit(wchar_t ch)
203 inline void StdLibIsSpace(wchar_t ch)
208 inline void StdLibIsAlphaNumeric(wchar_t ch)
214 * This test may be different since c lib has a type PUNCT and it is printable.
215 * iswgraph is not used for testing since it is a subset of iswprint with the
216 * exception of returning true for white spaces. no match found in icu4c.
218 inline void StdLibIsPrint(wchar_t ch)
223 inline void StdLibIsControl(wchar_t ch)
228 inline void StdLibToLower(wchar_t ch)
233 inline void StdLibToUpper(wchar_t ch)
238 inline void StdLibIsWhiteSpace(wchar_t ch)