- virtual long getEventsPerIteration(){
- int loops = LOOPS;
- if (catICU) { delete catICU;}
- if (catStd) { delete catStd;}
-
- if (bCatenatePrealloc) {
-
- int to_alloc = loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN);
- catICU = new UnicodeString(to_alloc,'a',0);
- //catICU = new UnicodeString();
-
- catStd = new stlstring();
- //catStd -> reserve(loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN));
- catStd -> reserve(110000000);
- } else {
- catICU = new UnicodeString();
- catStd = new stlstring();
- }
-
- return -1;
+ virtual long getEventsPerIteration(){
+ int loops = LOOPS;
+ if (catICU) { delete catICU;}
+ if (catStd) { delete catStd;}
+
+ if (bCatenatePrealloc) {
+
+ int to_alloc = loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN);
+ catICU = new UnicodeString(to_alloc,'a',0);
+ //catICU = new UnicodeString();
+
+ catStd = new stlstring();
+ //catStd -> reserve(loops * MAXNUMLINES * (MAXSRCLEN + catenate_STRLEN));
+ catStd -> reserve(110000000);
+ } else {
+ catICU = new UnicodeString();
+ catStd = new stlstring();
+ }
+
+ return -1;
- wsrc_ = NULL;
- wsrcLen_ = 0;
- fnType_ = Fn_STD;
-
- uS0_=NULL;
- ubulk_=NULL;
- sbulk_=NULL;
-
- //fillin wlines_[], sS0_[]
- prepareLinesForStd();
- }
-
- StringPerfFunction(ICUStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
- {
-
- fn1_ = func;
- lines_=NULL;
- wlines_=NULL;
- numLines_=0;
- uselen_=uselen;
- line_mode_=FALSE;
- src_ = new UChar[sourceLen];
- memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
+ wsrc_ = NULL;
+ wsrcLen_ = 0;
+ fnType_ = Fn_STD;
+
+ uS0_=NULL;
+ ubulk_=NULL;
+ sbulk_=NULL;
+
+ //fillin wlines_[], sS0_[]
+ prepareLinesForStd();
+ }
+
+ StringPerfFunction(ICUStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
+ {
+
+ fn1_ = func;
+ lines_=NULL;
+ wlines_=NULL;
+ numLines_=0;
+ uselen_=uselen;
+ line_mode_=FALSE;
+ src_ = new UChar[sourceLen];
+ memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
- wsrc_ = NULL;
- wsrcLen_ = 0;
- fnType_ = Fn_ICU;
-
- uS0_=NULL;
- sS0_=NULL;
- ubulk_=new UnicodeString(src_,srcLen_);
- sbulk_=NULL;
- }
-
- StringPerfFunction(StdStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
- {
-
- fn2_ = func;
- lines_=NULL;
- wlines_=NULL;
- numLines_=0;
- uselen_=uselen;
- line_mode_=FALSE;
- src_ = new UChar[sourceLen];
- memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
+ wsrc_ = NULL;
+ wsrcLen_ = 0;
+ fnType_ = Fn_ICU;
+
+ uS0_=NULL;
+ sS0_=NULL;
+ ubulk_=new UnicodeString(src_,srcLen_);
+ sbulk_=NULL;
+ }
+
+ StringPerfFunction(StdStringPerfFn func, UChar* source, int32_t sourceLen, UBool uselen)
+ {
+
+ fn2_ = func;
+ lines_=NULL;
+ wlines_=NULL;
+ numLines_=0;
+ uselen_=uselen;
+ line_mode_=FALSE;
+ src_ = new UChar[sourceLen];
+ memcpy(src_, source, sourceLen * U_SIZEOF_UCHAR);
- wchar_t* wcs;
-
- sS0_=new stlstring[numLines_];
- for(int32_t i=0; i<numLines_; i++) {
- if(uselen_) {
- wcs = u_strToWCS(ws, wcap, &wl, lines_[i].name, lines_[i].len, &err);
- memcpy(wlines_[i].name, wcs, wl * sizeof(wchar_t));
- wlines_[i].len = wl;
- sS0_[i]=stlstring(wlines_[i].name, wlines_[i].len);
- } else {
- wcs = u_strToWCS(ws, wcap, &wl, lines_[i].name, lines_[i].len-1, &err);
- memcpy(wlines_[i].name, wcs, wl*sizeof(wchar_t));
- wlines_[i].len = wl;
- sS0_[i]=stlstring(wlines_[i].name, wlines_[i].len+1);
- }
-
- if (U_FAILURE(err)) {
- return;
- }
- }
-
- }
-
- void prepareBulkForStd(void)
- {
- UErrorCode err=U_ZERO_ERROR;
-
- const UChar* uSrc = src_;
- int32_t uSrcLen = srcLen_;
- wchar_t* wDest = NULL;
- int32_t wDestLen = 0;
- int32_t reqLen= 0 ;
-
- if(uselen_) {
- /* pre-flight*/
- u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen,&err);
-
- if(err == U_BUFFER_OVERFLOW_ERROR){
- err=U_ZERO_ERROR;
- wDest =(wchar_t*) malloc(sizeof(wchar_t) * (reqLen));
- wDestLen = reqLen;
- u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen,&err);
- }
-
- if (U_SUCCESS(err)) {
- wsrc_ = wDest;
- wsrcLen_ = wDestLen;
- sbulk_=new stlstring(wsrc_,wsrcLen_);
- }
-
- } else {
- /* pre-flight*/
- u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen-1,&err);
-
- if(err == U_BUFFER_OVERFLOW_ERROR){
- err=U_ZERO_ERROR;
- wDest =(wchar_t*) malloc(sizeof(wchar_t) * (reqLen+1));
- wDestLen = reqLen+1;
- u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen-1,&err);
- }
-
- if (U_SUCCESS(err)) {
- wsrc_ = wDest;
- wsrcLen_ = wDestLen;
- sbulk_=new stlstring(wsrc_);
- }
- }
-
- //free(wDest);
- }
+ wchar_t* wcs;
+
+ sS0_=new stlstring[numLines_];
+ for(int32_t i=0; i<numLines_; i++) {
+ if(uselen_) {
+ wcs = u_strToWCS(ws, wcap, &wl, lines_[i].name, lines_[i].len, &err);
+ memcpy(wlines_[i].name, wcs, wl * sizeof(wchar_t));
+ wlines_[i].len = wl;
+ sS0_[i]=stlstring(wlines_[i].name, wlines_[i].len);
+ } else {
+ wcs = u_strToWCS(ws, wcap, &wl, lines_[i].name, lines_[i].len-1, &err);
+ memcpy(wlines_[i].name, wcs, wl*sizeof(wchar_t));
+ wlines_[i].len = wl;
+ sS0_[i]=stlstring(wlines_[i].name, wlines_[i].len+1);
+ }
+
+ if (U_FAILURE(err)) {
+ return;
+ }
+ }
+
+ }
+
+ void prepareBulkForStd(void)
+ {
+ UErrorCode err=U_ZERO_ERROR;
+
+ const UChar* uSrc = src_;
+ int32_t uSrcLen = srcLen_;
+ wchar_t* wDest = NULL;
+ int32_t wDestLen = 0;
+ int32_t reqLen= 0 ;
+
+ if(uselen_) {
+ /* pre-flight*/
+ u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen,&err);
+
+ if(err == U_BUFFER_OVERFLOW_ERROR){
+ err=U_ZERO_ERROR;
+ wDest =(wchar_t*) malloc(sizeof(wchar_t) * (reqLen));
+ wDestLen = reqLen;
+ u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen,&err);
+ }
+
+ if (U_SUCCESS(err)) {
+ wsrc_ = wDest;
+ wsrcLen_ = wDestLen;
+ sbulk_=new stlstring(wsrc_,wsrcLen_);
+ }
+
+ } else {
+ /* pre-flight*/
+ u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen-1,&err);
+
+ if(err == U_BUFFER_OVERFLOW_ERROR){
+ err=U_ZERO_ERROR;
+ wDest =(wchar_t*) malloc(sizeof(wchar_t) * (reqLen+1));
+ wDestLen = reqLen+1;
+ u_strToWCS(wDest,wDestLen,&reqLen,uSrc,uSrcLen-1,&err);
+ }
+
+ if (U_SUCCESS(err)) {
+ wsrc_ = wDest;
+ wsrcLen_ = wDestLen;
+ sbulk_=new stlstring(wsrc_);
+ }
+ }
+
+ //free(wDest);
+ }
- StringPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status);
- ~StringPerformanceTest();
- virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,
- const char *&name,
- char *par = NULL);
- UPerfFunction* TestCtor();
- UPerfFunction* TestCtor1();
- UPerfFunction* TestCtor2();
- UPerfFunction* TestCtor3();
- UPerfFunction* TestAssign();
- UPerfFunction* TestAssign1();
- UPerfFunction* TestAssign2();
- UPerfFunction* TestGetch();
- UPerfFunction* TestCatenate();
- UPerfFunction* TestScan();
- UPerfFunction* TestScan1();
- UPerfFunction* TestScan2();
-
- UPerfFunction* TestStdLibCtor();
- UPerfFunction* TestStdLibCtor1();
- UPerfFunction* TestStdLibCtor2();
- UPerfFunction* TestStdLibCtor3();
- UPerfFunction* TestStdLibAssign();
- UPerfFunction* TestStdLibAssign1();
- UPerfFunction* TestStdLibAssign2();
- UPerfFunction* TestStdLibGetch();
- UPerfFunction* TestStdLibCatenate();
- UPerfFunction* TestStdLibScan();
- UPerfFunction* TestStdLibScan1();
- UPerfFunction* TestStdLibScan2();
+ StringPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status);
+ ~StringPerformanceTest();
+ virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec,
+ const char *&name,
+ char *par = NULL);
+ UPerfFunction* TestCtor();
+ UPerfFunction* TestCtor1();
+ UPerfFunction* TestCtor2();
+ UPerfFunction* TestCtor3();
+ UPerfFunction* TestAssign();
+ UPerfFunction* TestAssign1();
+ UPerfFunction* TestAssign2();
+ UPerfFunction* TestGetch();
+ UPerfFunction* TestCatenate();
+ UPerfFunction* TestScan();
+ UPerfFunction* TestScan1();
+ UPerfFunction* TestScan2();
+
+ UPerfFunction* TestStdLibCtor();
+ UPerfFunction* TestStdLibCtor1();
+ UPerfFunction* TestStdLibCtor2();
+ UPerfFunction* TestStdLibCtor3();
+ UPerfFunction* TestStdLibAssign();
+ UPerfFunction* TestStdLibAssign1();
+ UPerfFunction* TestStdLibAssign2();
+ UPerfFunction* TestStdLibGetch();
+ UPerfFunction* TestStdLibCatenate();
+ UPerfFunction* TestStdLibScan();
+ UPerfFunction* TestStdLibScan1();
+ UPerfFunction* TestStdLibScan2();