X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/test/perf/ustrperf/stringperf.h diff --git a/icuSources/test/perf/ustrperf/stringperf.h b/icuSources/test/perf/ustrperf/stringperf.h index f3b83ad0..8dc316f3 100644 --- a/icuSources/test/perf/ustrperf/stringperf.h +++ b/icuSources/test/perf/ustrperf/stringperf.h @@ -1,25 +1,28 @@ /* ********************************************************************** -* Copyright (c) 2002-2004, International Business Machines +* Copyright (c) 2002-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** -********************************************************************** */ #ifndef _STRINGPERF_H #define _STRINGPERF_H -#include - -#include "uperf.h" +#include "cmemory.h" #include "unicode/utypes.h" #include "unicode/unistr.h" +#include "unicode/uperf.h" + +#include +#include +#include + typedef std::wstring stlstring; /* Define all constants for test case operations */ #define MAXNUMLINES 40000 //Max number of lines in a test data file #define MAXSRCLEN 20 //Max length of one line. maybe a larger number, but it need more mem -#define LOOPS 100 //Iterations +#define LOOPS 100 //Iterations //#define LOOPS 10 #define catenate_STRLEN 2 @@ -61,385 +64,385 @@ class StringPerfFunction : public UPerfFunction { public: - 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; } - virtual void call(UErrorCode* status) - { + virtual void call(UErrorCode* status) + { if(line_mode_==TRUE){ if(uselen_){ for(int32_t i = 0; i< numLines_; i++){ - if (fnType_==Fn_ICU) { - (*fn1_)(lines_[i].name,lines_[i].len,uS0_[i]); - } else { - (*fn2_)(wlines_[i].name,wlines_[i].len,sS0_[i]); - } + if (fnType_==Fn_ICU) { + (*fn1_)(lines_[i].name,lines_[i].len,uS0_[i]); + } else { + (*fn2_)(wlines_[i].name,wlines_[i].len,sS0_[i]); + } } }else{ for(int32_t i = 0; i< numLines_; i++){ if (fnType_==Fn_ICU) { - (*fn1_)(lines_[i].name,-1,uS0_[i]); - } else { - (*fn2_)(wlines_[i].name,-1,sS0_[i]); - } + (*fn1_)(lines_[i].name,-1,uS0_[i]); + } else { + (*fn2_)(wlines_[i].name,-1,sS0_[i]); + } } } }else{ if(uselen_){ - if (fnType_==Fn_ICU) { - (*fn1_)(src_,srcLen_,*ubulk_); - } else { - (*fn2_)(wsrc_,wsrcLen_,*sbulk_); - } + if (fnType_==Fn_ICU) { + (*fn1_)(src_,srcLen_,*ubulk_); + } else { + (*fn2_)(wsrc_,wsrcLen_,*sbulk_); + } }else{ - if (fnType_==Fn_ICU) { - (*fn1_)(src_,-1,*ubulk_); - } else { - (*fn2_)(wsrc_,-1,*sbulk_); - } + if (fnType_==Fn_ICU) { + (*fn1_)(src_,-1,*ubulk_); + } else { + (*fn2_)(wsrc_,-1,*sbulk_); + } } } - } + } - virtual long getOperationsPerIteration() - { + virtual long getOperationsPerIteration() + { if(line_mode_==TRUE){ return numLines_; }else{ return 1; } - } - - StringPerfFunction(ICUStringPerfFn func, ULine* srcLines, int32_t srcNumLines, UBool uselen) - { - - fn1_ = func; - lines_=srcLines; - wlines_=NULL; - numLines_=srcNumLines; - uselen_=uselen; - line_mode_=TRUE; + } + + StringPerfFunction(ICUStringPerfFn func, ULine* srcLines, int32_t srcNumLines, UBool uselen) + { + + fn1_ = func; + lines_=srcLines; + wlines_=NULL; + numLines_=srcNumLines; + uselen_=uselen; + line_mode_=TRUE; src_ = NULL; srcLen_ = 0; - wsrc_ = NULL; - wsrcLen_ = 0; - fnType_ = Fn_ICU; - - uS0_=new UnicodeString[numLines_]; - for(int32_t i=0; i