1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Copyright (c) 2002-2006, International Business Machines 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru********************************************************************** 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/ 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef _NORMPERF_H 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define _NORMPERF_H 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/unorm.h" 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/ustring.h" 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uperf.h" 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <stdlib.h> 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// Stubs for Windows API functions when building on UNIXes. 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if defined(U_WINDOWS) 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// do nothing 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define _UNICODE 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef int DWORD; 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int FoldStringW(DWORD dwMapFlags, const UChar* lpSrcStr,int cchSrc, UChar* lpDestStr,int cchDest); 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define DEST_BUFFER_CAPACITY 6000 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef int32_t (*NormFn)(const UChar* src,int32_t srcLen, UChar* dest,int32_t dstLen, int32_t options, UErrorCode* status); 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef int32_t (*QuickCheckFn)(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status); 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass QuickCheckPerfFunction : public UPerfFunction{ 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ULine* lines; 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t numLines; 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru QuickCheckFn fn; 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UNormalizationMode mode; 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t retVal; 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool uselen; 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UChar* src; 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t srcLen; 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool line_mode; 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t options; 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(line_mode==TRUE){ 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(uselen){ 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int32_t i = 0; i< numLines; i++){ 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru retVal = (*fn)(lines[i].name,lines[i].len,mode, options, status); 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int32_t i = 0; i< numLines; i++){ 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru retVal = (*fn)(lines[i].name,-1,mode, options, status); 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(uselen){ 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru retVal = (*fn)(src,srcLen,mode, options, status); 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru retVal = (*fn)(src,-1,mode, options, status); 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(){ 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(line_mode==TRUE){ 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t totalChars=0; 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int32_t i =0; i< numLines; i++){ 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru totalChars+= lines[i].len; 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return totalChars; 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru QuickCheckPerfFunction(QuickCheckFn func, ULine* srcLines,int32_t srcNumLines, UNormalizationMode _mode, int32_t opts, UBool _uselen) : options(opts) { 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru fn = func; 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru lines = srcLines; 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru numLines = srcNumLines; 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uselen = _uselen; 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mode = _mode; 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = NULL; 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = 0; 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru line_mode = TRUE; 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru QuickCheckPerfFunction(QuickCheckFn func, const UChar* source,int32_t sourceLen, UNormalizationMode _mode, int32_t opts, UBool _uselen) : options(opts) { 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru fn = func; 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru lines = NULL; 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru numLines = 0; 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uselen = _uselen; 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru mode = _mode; 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = source; 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = sourceLen; 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru line_mode = FALSE; 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass NormPerfFunction : public UPerfFunction{ 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ULine* lines; 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t numLines; 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar dest[DEST_BUFFER_CAPACITY]; 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* pDest; 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t destLen; 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NormFn fn; 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t retVal; 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool uselen; 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const UChar* src; 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t srcLen; 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UBool line_mode; 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t options; 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void call(UErrorCode* status){ 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(line_mode==TRUE){ 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(uselen){ 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int32_t i = 0; i< numLines; i++){ 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru retVal = (*fn)(lines[i].name,lines[i].len,pDest,destLen, options, status); 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int32_t i = 0; i< numLines; i++){ 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru retVal = (*fn)(lines[i].name,-1,pDest,destLen, options, status); 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(uselen){ 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru retVal = (*fn)(src,srcLen,pDest,destLen, options, status); 130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru retVal = (*fn)(src,-1,pDest,destLen, options, status); 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual long getOperationsPerIteration(){ 136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(line_mode ==TRUE){ 137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t totalChars=0; 138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru for(int32_t i =0; i< numLines; i++){ 139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru totalChars+= lines[i].len; 140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return totalChars; 142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru }else{ 143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return srcLen; 144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NormPerfFunction(NormFn func, int32_t opts, ULine* srcLines,int32_t srcNumLines,UBool _uselen) : options(opts) { 147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru fn = func; 148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru lines = srcLines; 149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru numLines = srcNumLines; 150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uselen = _uselen; 151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru destLen = DEST_BUFFER_CAPACITY; 152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pDest = dest; 153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = NULL; 154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = 0; 155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru line_mode = TRUE; 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NormPerfFunction(NormFn func, int32_t opts, const UChar* source,int32_t sourceLen,UBool _uselen) : options(opts) { 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru fn = func; 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru lines = NULL; 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru numLines = 0; 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru uselen = _uselen; 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru destLen = sourceLen*3; 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru pDest = (UChar*) malloc(destLen * U_SIZEOF_UCHAR); 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru src = source; 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru srcLen = sourceLen; 166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru line_mode = FALSE; 167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ~NormPerfFunction(){ 169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if(dest != pDest){ 170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru free(pDest); 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass NormalizerPerformanceTest : public UPerfTest{ 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate: 179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ULine* NFDFileLines; 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ULine* NFCFileLines; 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* NFDBuffer; 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* NFCBuffer; 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* origBuffer; 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t origBufferLen; 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t NFDBufferLen; 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t NFCBufferLen; 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t options; 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void normalizeInput(ULine* dest,const UChar* src ,int32_t srcLen,UNormalizationMode mode, int32_t options); 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UChar* normalizeInput(int32_t& len, const UChar* src ,int32_t srcLen,UNormalizationMode mode, int32_t options); 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru NormalizerPerformanceTest(int32_t argc, const char* argv[], UErrorCode& status); 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ~NormalizerPerformanceTest(); 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,const char* &name, char* par = NULL); 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* NFC performance */ 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_NFC_NFD_Text(); 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_NFC_NFC_Text(); 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_NFC_Orig_Text(); 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* NFD performance */ 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_NFD_NFD_Text(); 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_NFD_NFC_Text(); 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_NFD_Orig_Text(); 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* FCD performance */ 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_FCD_NFD_Text(); 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_FCD_NFC_Text(); 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestICU_FCD_Orig_Text(); 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /*Win NFC performance */ 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWin_NFC_NFD_Text(); 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWin_NFC_NFC_Text(); 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWin_NFC_Orig_Text(); 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* Win NFD performance */ 218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWin_NFD_NFD_Text(); 219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWin_NFD_NFC_Text(); 220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestWin_NFD_Orig_Text(); 221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* Quick check performance */ 223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_NFC_NFD_Text(); 224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_NFC_NFC_Text(); 225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_NFC_Orig_Text(); 226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_NFD_NFD_Text(); 228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_NFD_NFC_Text(); 229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_NFD_Orig_Text(); 230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_FCD_NFD_Text(); 232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_FCD_NFC_Text(); 233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestQC_FCD_Orig_Text(); 234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /* IsNormalized performnace */ 236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_NFC_NFD_Text(); 237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_NFC_NFC_Text(); 238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_NFC_Orig_Text(); 239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_NFD_NFD_Text(); 241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_NFD_NFC_Text(); 242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_NFD_Orig_Text(); 243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_FCD_NFD_Text(); 245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_FCD_NFC_Text(); 246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UPerfFunction* TestIsNormalized_FCD_Orig_Text(); 247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//--------------------------------------------------------------------------------------- 251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// Platform / ICU version specific proto-types 252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//--------------------------------------------------------------------------------------- 253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if (U_ICU_VERSION_MAJOR_NUM > 1 ) || ((U_ICU_VERSION_MAJOR_NUM == 1 )&&(U_ICU_VERSION_MINOR_NUM > 8) && (U_ICU_VERSION_PATCHLEVEL_NUM >=1)) 256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormNFD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UNORM_NFD, options,dest,dstLen,status); 259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormNFC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UNORM_NFC, options,dest,dstLen,status); 263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormNFKD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UNORM_NFKD, options,dest,dstLen,status); 267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormNFKC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UNORM_NFKC, options,dest,dstLen,status); 270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormFCD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UNORM_FCD, options,dest,dstLen,status); 274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUQuickCheck(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){ 277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if (U_ICU_VERSION_MAJOR_NUM > 2 ) || ((U_ICU_VERSION_MAJOR_NUM == 2 )&&(U_ICU_VERSION_MINOR_NUM >= 6)) 278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_quickCheckWithOptions(src,srcLen,mode, options, status); 279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else 280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_quickCheck(src,srcLen,mode,status); 281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUIsNormalized(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){ 284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_isNormalized(src,srcLen,mode,status); 285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else 289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormNFD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UCOL_DECOMP_CAN, options,dest,dstLen,status); 292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormNFC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UCOL_COMPOSE_CAN, options,dest,dstLen,status); 296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormNFKD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UCOL_DECOMP_COMPAT, options,dest,dstLen,status); 300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormNFKC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UCOL_COMPOSE_COMPAT, options,dest,dstLen,status); 303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUNormFCD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_normalize(src,srcLen,UNORM_FCD, options,dest,dstLen,status); 307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUQuickCheck(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){ 310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return unorm_quickCheck(src,srcLen,mode,status); 311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t ICUIsNormalized(const UChar* src,int32_t srcLen, UNormalizationMode mode, int32_t options, UErrorCode* status){ 314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0; 315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if defined(U_WINDOWS) 319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t WinNormNFD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return FoldStringW(MAP_COMPOSITE,src,srcLen,dest,dstLen); 322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t WinNormNFC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return FoldStringW(MAP_PRECOMPOSED,src,srcLen,dest,dstLen); 326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t WinNormNFKD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return FoldStringW(MAP_COMPOSITE+MAP_FOLDCZONE,src,srcLen,dest,dstLen); 330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t WinNormNFKC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return FoldStringW(MAP_FOLDCZONE,src,srcLen,dest,dstLen); 333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else 335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t WinNormNFD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0 ; 337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t WinNormNFC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0; 341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t WinNormNFKD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0; 345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint32_t WinNormNFKC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, int32_t options, UErrorCode* status) { 347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0; 348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif // NORMPERF_H 353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 354