ICU-2118 Normalizer performance test
X-SVN-Rev: 10078
This commit is contained in:
parent
5494469d5b
commit
a0e48eea1f
89
icu4c/source/test/perf/normperf/Makefile.in
Normal file
89
icu4c/source/test/perf/normperf/Makefile.in
Normal file
@ -0,0 +1,89 @@
|
||||
## Makefile.in for ICU - test/collperf
|
||||
## Copyright (c) 2001, International Business Machines Corporation and
|
||||
## others. All Rights Reserved.
|
||||
|
||||
## Source directory information
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
include $(top_builddir)/icudefs.mk
|
||||
|
||||
## Platform-specific setup
|
||||
include @platform_make_fragment@
|
||||
|
||||
## Build directory information
|
||||
subdir = test/normperf
|
||||
|
||||
## Extra files to remove for 'make clean'
|
||||
CLEANFILES = *~ $(DEPS)
|
||||
|
||||
## Target information
|
||||
TARGET = normperf
|
||||
|
||||
DEFS = @DEFS@
|
||||
CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n
|
||||
CFLAGS = @CFLAGS@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
ENABLE_RPATH = @ENABLE_RPATH@
|
||||
ifeq ($(ENABLE_RPATH),YES)
|
||||
RPATHLDFLAGS = $(LD_RPATH)$(LD_RPATH_PRE)$(libdir)
|
||||
endif
|
||||
LDFLAGS = @LDFLAGS@ $(RPATHLDFLAGS)
|
||||
LIBS = $(LIBICUI18N) $(LIBICUUC) @LIBS@ @LIB_M@
|
||||
|
||||
OBJECTS = normperf.o
|
||||
|
||||
DEPS = $(OBJECTS:.o=.d)
|
||||
|
||||
## List of phony targets
|
||||
.PHONY : all all-local install install-local clean clean-local \
|
||||
distclean distclean-local dist dist-local check check-local
|
||||
|
||||
## Clear suffix list
|
||||
.SUFFIXES :
|
||||
|
||||
## List of standard targets
|
||||
all: all-local
|
||||
install: install-local
|
||||
clean: clean-local
|
||||
distclean : distclean-local
|
||||
dist: dist-local
|
||||
check: all check-local
|
||||
|
||||
all-local: $(TARGET)
|
||||
|
||||
install-local:
|
||||
|
||||
dist-local:
|
||||
|
||||
clean-local:
|
||||
test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
|
||||
$(RMV) $(OBJECTS) $(TARGET)
|
||||
|
||||
distclean-local: clean-local
|
||||
$(RMV) Makefile
|
||||
|
||||
check-local: all-local
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
$(TARGET) : $(OBJECTS)
|
||||
$(LINK.cc) -o $@ $^ $(LIBS)
|
||||
|
||||
invoke:
|
||||
ICU_DATA=$${ICU_DATA:-$(top_builddir)/data/} TZ=PST8PDT $(INVOKE) $(INVOCATION)
|
||||
|
||||
ifeq (,$(MAKECMDGOALS))
|
||||
-include $(DEPS)
|
||||
else
|
||||
ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
|
||||
ifneq ($(patsubst %install,,$(MAKECMDGOALS)),)
|
||||
-include $(DEPS)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
479
icu4c/source/test/perf/normperf/normperf.cpp
Normal file
479
icu4c/source/test/perf/normperf/normperf.cpp
Normal file
@ -0,0 +1,479 @@
|
||||
#include "normperf.h"
|
||||
|
||||
|
||||
UPerfFunction* NormalizerPerformanceTest::runIndexedTest(int32_t index, UBool exec,const char* &name, char* par) {
|
||||
switch (index) {
|
||||
TESTCASE(0,TestICU_NFC_NFD_Text);
|
||||
TESTCASE(1,TestICU_NFC_NFC_Text);
|
||||
TESTCASE(2,TestICU_NFC_Orig_Text);
|
||||
|
||||
TESTCASE(3,TestICU_NFD_NFD_Text);
|
||||
TESTCASE(4,TestICU_NFD_NFC_Text);
|
||||
TESTCASE(5,TestICU_NFD_Orig_Text);
|
||||
|
||||
TESTCASE(6,TestICU_FCD_NFD_Text);
|
||||
TESTCASE(7,TestICU_FCD_NFC_Text);
|
||||
TESTCASE(8,TestICU_FCD_Orig_Text);
|
||||
|
||||
TESTCASE(9,TestWin_NFC_NFD_Text);
|
||||
TESTCASE(10,TestWin_NFC_NFC_Text);
|
||||
TESTCASE(11,TestWin_NFC_Orig_Text);
|
||||
|
||||
TESTCASE(12,TestWin_NFD_NFD_Text);
|
||||
TESTCASE(13,TestWin_NFD_NFC_Text);
|
||||
TESTCASE(14,TestWin_NFD_Orig_Text);
|
||||
|
||||
TESTCASE(15,TestQC_NFC_NFD_Text);
|
||||
TESTCASE(16,TestQC_NFC_NFC_Text);
|
||||
TESTCASE(17,TestQC_NFC_Orig_Text);
|
||||
|
||||
TESTCASE(18,TestQC_NFD_NFD_Text);
|
||||
TESTCASE(19,TestQC_NFD_NFC_Text);
|
||||
TESTCASE(20,TestQC_NFD_Orig_Text);
|
||||
|
||||
TESTCASE(21,TestQC_FCD_NFD_Text);
|
||||
TESTCASE(22,TestQC_FCD_NFC_Text);
|
||||
TESTCASE(23,TestQC_FCD_Orig_Text);
|
||||
|
||||
TESTCASE(24,TestIsNormalized_NFC_NFD_Text);
|
||||
TESTCASE(25,TestIsNormalized_NFC_NFC_Text);
|
||||
TESTCASE(26,TestIsNormalized_NFC_Orig_Text);
|
||||
|
||||
TESTCASE(27,TestIsNormalized_NFD_NFD_Text);
|
||||
TESTCASE(28,TestIsNormalized_NFD_NFC_Text);
|
||||
TESTCASE(29,TestIsNormalized_NFD_Orig_Text);
|
||||
|
||||
TESTCASE(30,TestIsNormalized_FCD_NFD_Text);
|
||||
TESTCASE(31,TestIsNormalized_FCD_NFC_Text);
|
||||
TESTCASE(32,TestIsNormalized_FCD_Orig_Text);
|
||||
|
||||
default:
|
||||
name = "";
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
void NormalizerPerformanceTest::normalizeInput(ULine* dest,const UChar* src ,int32_t srcLen,UNormalizationMode mode){
|
||||
int32_t reqLen = 0;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
for(;;){
|
||||
/* pure pre-flight */
|
||||
reqLen=unorm_normalize(src,srcLen,mode,0,NULL,0,&status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
dest->name = new UChar[reqLen+1];
|
||||
reqLen= unorm_normalize(src,srcLen,mode,0,dest->name,reqLen+1,&status);
|
||||
dest->len=reqLen;
|
||||
break;
|
||||
}else if(U_FAILURE(status)){
|
||||
printf("Could not normalize input. Error: %s", u_errorName(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
UChar* NormalizerPerformanceTest::normalizeInput(int32_t& len, const UChar* src ,int32_t srcLen,UNormalizationMode mode){
|
||||
int32_t reqLen = 0;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UChar* dest = NULL;
|
||||
for(;;){
|
||||
/* pure pre-flight */
|
||||
reqLen=unorm_normalize(src,srcLen,mode,0,NULL,0,&status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR){
|
||||
status=U_ZERO_ERROR;
|
||||
dest = new UChar[reqLen+1];
|
||||
reqLen= unorm_normalize(src,srcLen,mode,0,dest,reqLen+1,&status);
|
||||
len=reqLen;
|
||||
break;
|
||||
}else if(U_FAILURE(status)){
|
||||
printf("Could not normalize input. Error: %s", u_errorName(status));
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
NormalizerPerformanceTest::NormalizerPerformanceTest(int32_t argc, const char* argv[], UErrorCode& status)
|
||||
: UPerfTest(argc,argv,status){
|
||||
NFDBuffer = NULL;
|
||||
NFCBuffer = NULL;
|
||||
NFDBufferLen = 0;
|
||||
NFCBufferLen = 0;
|
||||
NFDFileLines = NULL;
|
||||
NFCFileLines = NULL;
|
||||
|
||||
if(status== U_ILLEGAL_ARGUMENT_ERROR){
|
||||
fprintf(stderr,gUsageString, "normperf");
|
||||
return;
|
||||
}
|
||||
|
||||
if(U_FAILURE(status)){
|
||||
fprintf(stderr, "FAILED to create UPerfTest object. Error: %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
if(line_mode){
|
||||
ULine* filelines = getLines(status);
|
||||
if(U_FAILURE(status)){
|
||||
fprintf(stderr, "FAILED to read lines from file and create UPerfTest object. Error: %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
NFDFileLines = new ULine[numLines];
|
||||
NFCFileLines = new ULine[numLines];
|
||||
|
||||
for(int32_t i=0;i<numLines;i++){
|
||||
normalizeInput(&NFDFileLines[i],filelines[i].name,filelines[i].len,UNORM_NFD);
|
||||
normalizeInput(&NFCFileLines[i],filelines[i].name,filelines[i].len,UNORM_NFC);
|
||||
|
||||
}
|
||||
}else if(bulk_mode){
|
||||
int32_t srcLen = 0;
|
||||
const UChar* src = getBuffer(srcLen,status);
|
||||
NFDBufferLen = 0;
|
||||
NFCBufferLen = 0;
|
||||
|
||||
if(U_FAILURE(status)){
|
||||
fprintf(stderr, "FAILED to read buffer from file and create UPerfTest object. Error: %s\n", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
NFCBuffer = normalizeInput(NFDBufferLen,src,srcLen,UNORM_NFD);
|
||||
NFDBuffer = normalizeInput(NFCBufferLen,src,srcLen,UNORM_NFC);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NormalizerPerformanceTest::~NormalizerPerformanceTest(){
|
||||
delete[] NFDFileLines;
|
||||
delete[] NFCFileLines;
|
||||
delete[] NFDBuffer;
|
||||
delete[] NFCBuffer;
|
||||
}
|
||||
|
||||
// Test NFC Performance
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_NFC_NFD_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func= new NormPerfFunction(ICUNormNFC,NFDFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func= new NormPerfFunction(ICUNormNFC,NFDBuffer, NFDBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_NFC_NFC_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFC,NFCFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func= new NormPerfFunction(ICUNormNFC,NFCBuffer, NFCBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_NFC_Orig_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFC,lines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFC,buffer, bufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
// Test NFD Performance
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_NFD_NFD_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFD,NFDFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFD,NFDBuffer,NFDBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_NFD_NFC_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFD,NFCFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFD,NFCBuffer,NFCBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_NFD_Orig_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFD,lines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormNFD,buffer,bufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
// Test FCD Performance
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_FCD_NFD_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormFCD,NFDFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormFCD,NFDBuffer,NFDBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_FCD_NFC_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormFCD,NFCFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormFCD,NFCBuffer,NFCBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestICU_FCD_Orig_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormFCD,lines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(ICUNormFCD,buffer,bufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
// Test Win NFC Performance
|
||||
UPerfFunction* NormalizerPerformanceTest::TestWin_NFC_NFD_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFC,NFDFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFC,NFDBuffer,NFDBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestWin_NFC_NFC_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFC,NFCFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFC,NFCBuffer,NFCBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestWin_NFC_Orig_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFC,lines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFC,buffer,bufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
// Test Win NFD Performance
|
||||
UPerfFunction* NormalizerPerformanceTest::TestWin_NFD_NFD_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFD,NFDFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFD,NFDBuffer,NFDBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestWin_NFD_NFC_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFD,NFCFileLines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFD,NFCBuffer,NFCBufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestWin_NFD_Orig_Text(){
|
||||
if(line_mode){
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFD,lines,numLines, uselen);
|
||||
return func;
|
||||
}else{
|
||||
NormPerfFunction* func = new NormPerfFunction(WinNormNFD,buffer,bufferLen, uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
// Test Quick Check Performance
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_NFC_NFD_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFDFileLines, numLines, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFDBuffer, NFDBufferLen, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_NFC_NFC_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFCFileLines, numLines, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFCBuffer, NFCBufferLen, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_NFC_Orig_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,lines, numLines, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,buffer, bufferLen, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_NFD_NFD_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFDFileLines, numLines, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFDBuffer, NFDBufferLen, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_NFD_NFC_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFCFileLines, numLines, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFCBuffer, NFCBufferLen, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_NFD_Orig_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,lines, numLines, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,buffer, bufferLen, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_FCD_NFD_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFDFileLines, numLines, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFDBuffer, NFDBufferLen, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_FCD_NFC_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFCFileLines, numLines, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,NFCBuffer, NFCBufferLen, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestQC_FCD_Orig_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,lines, numLines, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUQuickCheck,buffer, bufferLen, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
// Test isNormalized Performance
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_NFC_NFD_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFDFileLines, numLines, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFDBuffer, NFDBufferLen, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_NFC_NFC_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFCFileLines, numLines, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFCBuffer, NFCBufferLen, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_NFC_Orig_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,lines, numLines, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,buffer, bufferLen, UNORM_NFC,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_NFD_NFD_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFDFileLines, numLines, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFDBuffer, NFDBufferLen, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_NFD_NFC_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFCFileLines, numLines, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFCBuffer, NFCBufferLen, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_NFD_Orig_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,lines, numLines, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,buffer, bufferLen, UNORM_NFD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_FCD_NFD_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFDFileLines, numLines, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFDBuffer, NFDBufferLen, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_FCD_NFC_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFCFileLines, numLines, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,NFCBuffer, NFCBufferLen, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
UPerfFunction* NormalizerPerformanceTest::TestIsNormalized_FCD_Orig_Text(){
|
||||
if(line_mode){
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,lines, numLines, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}else{
|
||||
QuickCheckPerfFunction* func = new QuickCheckPerfFunction(ICUIsNormalized,buffer, bufferLen, UNORM_FCD,uselen);
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[]){
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
NormalizerPerformanceTest test(argc, argv, status);
|
||||
if(U_FAILURE(status)){
|
||||
return status;
|
||||
}
|
||||
if(test.run()==FALSE){
|
||||
fprintf(stderr,"FAILED: Tests could not be run please check the arguments.\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
107
icu4c/source/test/perf/normperf/normperf.dsp
Normal file
107
icu4c/source/test/perf/normperf/normperf.dsp
Normal file
@ -0,0 +1,107 @@
|
||||
# Microsoft Developer Studio Project File - Name="normperf" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=normperf - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "normperf.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "normperf.mak" CFG="normperf - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "normperf - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "normperf - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "normperf - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
MTL=midl.exe
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "normperf - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
MTL=midl.exe
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /G6 /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\include" /I "..\..\tools\ctestfw" /I "..\..\common" /I "..\..\i18n" /I "..\..\tools\toolutil" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_UNICODE" /FR /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 icuucd.lib icuind.lib icutud.lib winmm.lib kernel32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\lib\\"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "normperf - Win32 Release"
|
||||
# Name "normperf - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\normperf.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\normperf.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
353
icu4c/source/test/perf/normperf/normperf.h
Normal file
353
icu4c/source/test/perf/normperf/normperf.h
Normal file
@ -0,0 +1,353 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2002, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
**********************************************************************
|
||||
*/
|
||||
#ifndef _NORMPERF_H
|
||||
#define _NORMPERF_H
|
||||
|
||||
#include "uperf.h"
|
||||
#include "unicode/unorm.h"
|
||||
#include "unicode/ustring.h"
|
||||
|
||||
// Stubs for Windows API functions when building on UNIXes.
|
||||
//
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||
// do nothing
|
||||
#else
|
||||
#define _UNICODE
|
||||
typedef int DWORD;
|
||||
inline int FoldStringW(DWORD dwMapFlags, const UChar* lpSrcStr,int cchSrc, UChar* lpDestStr,int cchDest);
|
||||
#endif
|
||||
|
||||
#define DEST_BUFFER_CAPACITY 6000
|
||||
typedef int32_t (*NormFn)(const UChar* src,int32_t srcLen, UChar* dest,int32_t dstLen, UErrorCode* status);
|
||||
typedef int32_t (*QuickCheckFn)(const UChar* src,int32_t srcLen, UNormalizationMode mode, UErrorCode* status);
|
||||
|
||||
class QuickCheckPerfFunction : public UPerfFunction{
|
||||
private:
|
||||
ULine* lines;
|
||||
int32_t numLines;
|
||||
UErrorCode status;
|
||||
QuickCheckFn fn;
|
||||
UNormalizationMode mode;
|
||||
int32_t retVal;
|
||||
UBool uselen;
|
||||
const UChar* src;
|
||||
int32_t srcLen;
|
||||
UBool line_mode;
|
||||
public:
|
||||
virtual void call(){
|
||||
if(line_mode==TRUE){
|
||||
if(uselen){
|
||||
for(int32_t i = 0; i< numLines; i++){
|
||||
retVal = (*fn)(lines[i].name,lines[i].len,mode,&status);
|
||||
}
|
||||
}else{
|
||||
for(int32_t i = 0; i< numLines; i++){
|
||||
retVal = (*fn)(lines[i].name,-1,mode,&status);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(uselen){
|
||||
for(int32_t i = 0; i< numLines; i++){
|
||||
retVal = (*fn)(src,srcLen,mode,&status);
|
||||
}
|
||||
}else{
|
||||
for(int32_t i = 0; i< numLines; i++){
|
||||
retVal = (*fn)(src,-1,mode,&status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
virtual long getOperationsPerIteration(){
|
||||
if(line_mode==TRUE){
|
||||
int32_t totalChars=0;
|
||||
for(int32_t i =0; i< numLines; i++){
|
||||
totalChars+= lines[i].len;
|
||||
}
|
||||
return totalChars;
|
||||
}else{
|
||||
return srcLen;
|
||||
}
|
||||
}
|
||||
virtual long getEventsPerIteration(){
|
||||
return -1;
|
||||
}
|
||||
UErrorCode getStatus(){
|
||||
return status;
|
||||
}
|
||||
QuickCheckPerfFunction(QuickCheckFn func, ULine* srcLines,int32_t srcNumLines, UNormalizationMode _mode, UBool _uselen){
|
||||
fn = func;
|
||||
lines = srcLines;
|
||||
numLines = srcNumLines;
|
||||
uselen = _uselen;
|
||||
mode = _mode;
|
||||
status = U_ZERO_ERROR;
|
||||
src = NULL;
|
||||
srcLen = 0;
|
||||
line_mode = TRUE;
|
||||
}
|
||||
QuickCheckPerfFunction(QuickCheckFn func, const UChar* source,int32_t sourceLen, UNormalizationMode _mode, UBool _uselen){
|
||||
fn = func;
|
||||
lines = NULL;
|
||||
numLines = 0;
|
||||
uselen = _uselen;
|
||||
mode = _mode;
|
||||
status = U_ZERO_ERROR;
|
||||
src = source;
|
||||
srcLen = sourceLen;
|
||||
line_mode = FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class NormPerfFunction : public UPerfFunction{
|
||||
private:
|
||||
ULine* lines;
|
||||
int32_t numLines;
|
||||
UChar dest[DEST_BUFFER_CAPACITY];
|
||||
int32_t destLen;
|
||||
UErrorCode status;
|
||||
NormFn fn;
|
||||
int32_t retVal;
|
||||
UBool uselen;
|
||||
const UChar* src;
|
||||
int32_t srcLen;
|
||||
UBool line_mode;
|
||||
|
||||
public:
|
||||
virtual void call(){
|
||||
if(line_mode==TRUE){
|
||||
if(uselen){
|
||||
for(int32_t i = 0; i< numLines; i++){
|
||||
retVal = (*fn)(lines[i].name,lines[i].len,dest,destLen,&status);
|
||||
}
|
||||
}else{
|
||||
for(int32_t i = 0; i< numLines; i++){
|
||||
retVal = (*fn)(lines[i].name,-1,dest,destLen,&status);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(uselen){
|
||||
retVal = (*fn)(src,srcLen,dest,destLen,&status);
|
||||
}else{
|
||||
retVal = (*fn)(src,-1,dest,destLen,&status);
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual long getOperationsPerIteration(){
|
||||
if(line_mode ==TRUE){
|
||||
int32_t totalChars=0;
|
||||
for(int32_t i =0; i< numLines; i++){
|
||||
totalChars+= lines[i].len;
|
||||
}
|
||||
return totalChars;
|
||||
}else{
|
||||
return srcLen;
|
||||
}
|
||||
}
|
||||
virtual long getEventsPerIteration(){
|
||||
return -1;
|
||||
}
|
||||
UErrorCode getStatus(){
|
||||
return status;
|
||||
}
|
||||
NormPerfFunction(NormFn func,ULine* srcLines,int32_t srcNumLines,UBool _uselen){
|
||||
fn = func;
|
||||
lines = srcLines;
|
||||
numLines = srcNumLines;
|
||||
uselen = _uselen;
|
||||
destLen = DEST_BUFFER_CAPACITY;
|
||||
status = U_ZERO_ERROR;
|
||||
src = NULL;
|
||||
srcLen = 0;
|
||||
line_mode = TRUE;
|
||||
}
|
||||
NormPerfFunction(NormFn func,const UChar* source,int32_t sourceLen,UBool _uselen){
|
||||
fn = func;
|
||||
lines = NULL;
|
||||
numLines = 0;
|
||||
uselen = _uselen;
|
||||
destLen = DEST_BUFFER_CAPACITY;
|
||||
status = U_ZERO_ERROR;
|
||||
src = source;
|
||||
srcLen = sourceLen;
|
||||
line_mode = FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
class NormalizerPerformanceTest : public UPerfTest{
|
||||
private:
|
||||
ULine* NFDFileLines;
|
||||
ULine* NFCFileLines;
|
||||
UChar* NFDBuffer;
|
||||
UChar* NFCBuffer;
|
||||
int32_t NFDBufferLen;
|
||||
int32_t NFCBufferLen;
|
||||
|
||||
void normalizeInput(ULine* dest,const UChar* src ,int32_t srcLen,UNormalizationMode mode);
|
||||
UChar* normalizeInput(int32_t& len, const UChar* src ,int32_t srcLen,UNormalizationMode mode);
|
||||
|
||||
public:
|
||||
|
||||
NormalizerPerformanceTest(int32_t argc, const char* argv[], UErrorCode& status);
|
||||
~NormalizerPerformanceTest();
|
||||
virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,const char* &name, char* par = NULL);
|
||||
/* NFC performance */
|
||||
UPerfFunction* TestICU_NFC_NFD_Text();
|
||||
UPerfFunction* TestICU_NFC_NFC_Text();
|
||||
UPerfFunction* TestICU_NFC_Orig_Text();
|
||||
|
||||
/* NFD performance */
|
||||
UPerfFunction* TestICU_NFD_NFD_Text();
|
||||
UPerfFunction* TestICU_NFD_NFC_Text();
|
||||
UPerfFunction* TestICU_NFD_Orig_Text();
|
||||
|
||||
/* FCD performance */
|
||||
UPerfFunction* TestICU_FCD_NFD_Text();
|
||||
UPerfFunction* TestICU_FCD_NFC_Text();
|
||||
UPerfFunction* TestICU_FCD_Orig_Text();
|
||||
|
||||
/*Win NFC performance */
|
||||
UPerfFunction* TestWin_NFC_NFD_Text();
|
||||
UPerfFunction* TestWin_NFC_NFC_Text();
|
||||
UPerfFunction* TestWin_NFC_Orig_Text();
|
||||
|
||||
/* Win NFD performance */
|
||||
UPerfFunction* TestWin_NFD_NFD_Text();
|
||||
UPerfFunction* TestWin_NFD_NFC_Text();
|
||||
UPerfFunction* TestWin_NFD_Orig_Text();
|
||||
|
||||
/* Quick check performance */
|
||||
UPerfFunction* TestQC_NFC_NFD_Text();
|
||||
UPerfFunction* TestQC_NFC_NFC_Text();
|
||||
UPerfFunction* TestQC_NFC_Orig_Text();
|
||||
|
||||
UPerfFunction* TestQC_NFD_NFD_Text();
|
||||
UPerfFunction* TestQC_NFD_NFC_Text();
|
||||
UPerfFunction* TestQC_NFD_Orig_Text();
|
||||
|
||||
UPerfFunction* TestQC_FCD_NFD_Text();
|
||||
UPerfFunction* TestQC_FCD_NFC_Text();
|
||||
UPerfFunction* TestQC_FCD_Orig_Text();
|
||||
|
||||
/* IsNormalized performnace */
|
||||
UPerfFunction* TestIsNormalized_NFC_NFD_Text();
|
||||
UPerfFunction* TestIsNormalized_NFC_NFC_Text();
|
||||
UPerfFunction* TestIsNormalized_NFC_Orig_Text();
|
||||
|
||||
UPerfFunction* TestIsNormalized_NFD_NFD_Text();
|
||||
UPerfFunction* TestIsNormalized_NFD_NFC_Text();
|
||||
UPerfFunction* TestIsNormalized_NFD_Orig_Text();
|
||||
|
||||
UPerfFunction* TestIsNormalized_FCD_NFD_Text();
|
||||
UPerfFunction* TestIsNormalized_FCD_NFC_Text();
|
||||
UPerfFunction* TestIsNormalized_FCD_Orig_Text();
|
||||
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
// Platform / ICU version specific proto-types
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#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))
|
||||
|
||||
int32_t ICUNormNFD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UNORM_NFD,0,dest,dstLen,status);
|
||||
}
|
||||
|
||||
int32_t ICUNormNFC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UNORM_NFC,0,dest,dstLen,status);
|
||||
}
|
||||
|
||||
int32_t ICUNormNFKD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UNORM_NFKD,0,dest,dstLen,status);
|
||||
}
|
||||
int32_t ICUNormNFKC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UNORM_NFKC,0,dest,dstLen,status);
|
||||
}
|
||||
|
||||
int32_t ICUNormFCD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UNORM_FCD,0,dest,dstLen,status);
|
||||
}
|
||||
|
||||
int32_t ICUQuickCheck(const UChar* src,int32_t srcLen, UNormalizationMode mode, UErrorCode* status){
|
||||
return unorm_quickCheck(src,srcLen,mode,status);
|
||||
}
|
||||
int32_t ICUIsNormalized(const UChar* src,int32_t srcLen, UNormalizationMode mode, UErrorCode* status){
|
||||
return unorm_isNormalized(src,srcLen,mode,status);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
int32_t ICUNormNFD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UCOL_DECOMP_CAN,0,dest,dstLen,status);
|
||||
}
|
||||
|
||||
int32_t ICUNormNFC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UCOL_COMPOSE_CAN,0,dest,dstLen,status);
|
||||
}
|
||||
|
||||
int32_t ICUNormNFKD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UCOL_DECOMP_COMPAT,0,dest,dstLen,status);
|
||||
}
|
||||
int32_t ICUNormNFKC(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UCOL_COMPOSE_COMPAT,0,dest,dstLen,status);
|
||||
}
|
||||
|
||||
int32_t ICUNormFCD(const UChar* src, int32_t srcLen,UChar* dest, int32_t dstLen,UErrorCode* status) {
|
||||
return unorm_normalize(src,srcLen,UNORM_FCD,0,dest,dstLen,status);
|
||||
}
|
||||
|
||||
int32_t ICUQuickCheck(const UChar* src,int32_t srcLen, UNormalizationMode mode, UErrorCode* status){
|
||||
return unorm_quickCheck(src,srcLen,mode,status);
|
||||
}
|
||||
|
||||
int32_t ICUIsNormalized(const UChar* src,int32_t srcLen, UNormalizationMode mode, UErrorCode* status){
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
||||
|
||||
int32_t WinNormNFD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, UErrorCode* status) {
|
||||
return FoldStringW(MAP_COMPOSITE,src,srcLen,dest,dstLen);
|
||||
}
|
||||
|
||||
int32_t WinNormNFC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, UErrorCode* status) {
|
||||
return FoldStringW(MAP_PRECOMPOSED,src,srcLen,dest,dstLen);
|
||||
}
|
||||
|
||||
int32_t WinNormNFKD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, UErrorCode* status) {
|
||||
return FoldStringW(MAP_COMPOSITE+MAP_FOLDCZONE,src,srcLen,dest,dstLen);
|
||||
}
|
||||
int32_t WinNormNFKC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, UErrorCode* status) {
|
||||
return FoldStringW(MAP_FOLDCZONE,src,srcLen,dest,dstLen);
|
||||
}
|
||||
#else
|
||||
int32_t WinNormNFD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, UErrorCode* status) {
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int32_t WinNormNFC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, UErrorCode* status) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t WinNormNFKD(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, UErrorCode* status) {
|
||||
return 0;
|
||||
}
|
||||
int32_t WinNormNFKC(const UChar* src, int32_t srcLen, UChar* dest, int32_t dstLen, UErrorCode* status) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // NORMPERF_H
|
Loading…
Reference in New Issue
Block a user