]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/perf/charperf/charperf.h
2 **********************************************************************
3 * Copyright (c) 2002-2006, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 **********************************************************************
11 #include "unicode/uchar.h"
13 #include "unicode/uperf.h"
19 typedef void (*CharPerfFn
)(UChar32 ch
);
20 typedef void (*StdLibCharPerfFn
)(wchar_t ch
);
22 class CharPerfFunction
: public UPerfFunction
25 virtual void call(UErrorCode
* status
)
27 for (UChar32 i
= MIN_
; i
< MAX_
; i
++) {
32 virtual long getOperationsPerIteration()
36 CharPerfFunction(CharPerfFn func
, UChar32 min
, UChar32 max
)
49 class StdLibCharPerfFunction
: public UPerfFunction
52 virtual void call(UErrorCode
* status
)
54 // note wchar_t is unsigned, it will revert to 0 once it reaches
56 for (wchar_t i
= MIN_
; i
< MAX_
; i
++) {
61 virtual long getOperationsPerIteration()
66 StdLibCharPerfFunction(StdLibCharPerfFn func
, wchar_t min
, wchar_t max
)
73 ~StdLibCharPerfFunction()
78 StdLibCharPerfFn m_fn_
;
83 class CharPerformanceTest
: public UPerfTest
86 CharPerformanceTest(int32_t argc
, const char *argv
[], UErrorCode
&status
);
87 ~CharPerformanceTest();
88 virtual UPerfFunction
* runIndexedTest(int32_t index
, UBool exec
,
91 UPerfFunction
* TestIsAlpha();
92 UPerfFunction
* TestIsUpper();
93 UPerfFunction
* TestIsLower();
94 UPerfFunction
* TestIsDigit();
95 UPerfFunction
* TestIsSpace();
96 UPerfFunction
* TestIsAlphaNumeric();
97 UPerfFunction
* TestIsPrint();
98 UPerfFunction
* TestIsControl();
99 UPerfFunction
* TestToLower();
100 UPerfFunction
* TestToUpper();
101 UPerfFunction
* TestIsWhiteSpace();
102 UPerfFunction
* TestStdLibIsAlpha();
103 UPerfFunction
* TestStdLibIsUpper();
104 UPerfFunction
* TestStdLibIsLower();
105 UPerfFunction
* TestStdLibIsDigit();
106 UPerfFunction
* TestStdLibIsSpace();
107 UPerfFunction
* TestStdLibIsAlphaNumeric();
108 UPerfFunction
* TestStdLibIsPrint();
109 UPerfFunction
* TestStdLibIsControl();
110 UPerfFunction
* TestStdLibToLower();
111 UPerfFunction
* TestStdLibToUpper();
112 UPerfFunction
* TestStdLibIsWhiteSpace();
119 inline void isAlpha(UChar32 ch
)
124 inline void isUpper(UChar32 ch
)
129 inline void isLower(UChar32 ch
)
134 inline void isDigit(UChar32 ch
)
139 inline void isSpace(UChar32 ch
)
144 inline void isAlphaNumeric(UChar32 ch
)
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 inline void isPrint(UChar32 ch
)
159 inline void isControl(UChar32 ch
)
164 inline void toLower(UChar32 ch
)
169 inline void toUpper(UChar32 ch
)
174 inline void isWhiteSpace(UChar32 ch
)
179 inline void StdLibIsAlpha(wchar_t ch
)
184 inline void StdLibIsUpper(wchar_t ch
)
189 inline void StdLibIsLower(wchar_t ch
)
194 inline void StdLibIsDigit(wchar_t ch
)
199 inline void StdLibIsSpace(wchar_t ch
)
204 inline void StdLibIsAlphaNumeric(wchar_t ch
)
210 * This test may be different since c lib has a type PUNCT and it is printable.
211 * iswgraph is not used for testing since it is a subset of iswprint with the
212 * exception of returning true for white spaces. no match found in icu4c.
214 inline void StdLibIsPrint(wchar_t ch
)
219 inline void StdLibIsControl(wchar_t ch
)
224 inline void StdLibToLower(wchar_t ch
)
229 inline void StdLibToUpper(wchar_t ch
)
234 inline void StdLibIsWhiteSpace(wchar_t ch
)