From: Frank Tang Date: Thu, 12 Nov 2020 06:41:28 +0000 (-0800) Subject: ICU-21391 Make test/perf compile X-Git-Tag: cldr/2020-12-03b~5^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ceeb53ac786e3a9bcd2520af1d57f227b8baab90;p=icu ICU-21391 Make test/perf compile --- diff --git a/icu4c/source/test/perf/collationperf/collperf.cpp b/icu4c/source/test/perf/collationperf/collperf.cpp index 2617d205e15..a1d85561bcd 100644 --- a/icu4c/source/test/perf/collationperf/collperf.cpp +++ b/icu4c/source/test/perf/collationperf/collperf.cpp @@ -110,31 +110,31 @@ char * opt_fName = 0; const char * opt_locale = "en_US"; int opt_langid = 0; // Defaults to value corresponding to opt_locale. char * opt_rules = 0; -UBool opt_help = FALSE; +UBool opt_help = false; int opt_loopCount = 1; int opt_iLoopCount = 1; -UBool opt_terse = FALSE; -UBool opt_qsort = FALSE; -UBool opt_binsearch = FALSE; -UBool opt_icu = TRUE; -UBool opt_win = FALSE; // Run with Windows native functions. -UBool opt_unix = FALSE; // Run with UNIX strcoll, strxfrm functions. -UBool opt_uselen = FALSE; -UBool opt_usekeys = FALSE; -UBool opt_strcmp = FALSE; -UBool opt_strcmpCPO = FALSE; -UBool opt_norm = FALSE; -UBool opt_keygen = FALSE; -UBool opt_french = FALSE; -UBool opt_frenchoff = FALSE; -UBool opt_shifted = FALSE; -UBool opt_lower = FALSE; -UBool opt_upper = FALSE; -UBool opt_case = FALSE; +UBool opt_terse = false; +UBool opt_qsort = false; +UBool opt_binsearch = false; +UBool opt_icu = true; +UBool opt_win = false; // Run with Windows native functions. +UBool opt_unix = false; // Run with UNIX strcoll, strxfrm functions. +UBool opt_uselen = false; +UBool opt_usekeys = false; +UBool opt_strcmp = false; +UBool opt_strcmpCPO = false; +UBool opt_norm = false; +UBool opt_keygen = false; +UBool opt_french = false; +UBool opt_frenchoff = false; +UBool opt_shifted = false; +UBool opt_lower = false; +UBool opt_upper = false; +UBool opt_case = false; int opt_level = 0; -UBool opt_keyhist = FALSE; -UBool opt_itertest = FALSE; -UBool opt_dump = FALSE; +UBool opt_keyhist = false; +UBool opt_itertest = false; +UBool opt_dump = false; @@ -233,13 +233,13 @@ UBool ProcessOptions(int argc, const char **argv, OptSpec opts[]) if (strcmp(pOpt->name, pArgName) == 0) { switch (pOpt->type) { case OptSpec::FLAG: - *(UBool *)(pOpt->pVar) = TRUE; + *(UBool *)(pOpt->pVar) = true; break; case OptSpec::STRING: argNum ++; if (argNum >= argc) { fprintf(stderr, "value expected for \"%s\" option.\n", pOpt->name); - return FALSE; + return false; } *(const char **)(pOpt->pVar) = argv[argNum]; break; @@ -247,13 +247,13 @@ UBool ProcessOptions(int argc, const char **argv, OptSpec opts[]) argNum ++; if (argNum >= argc) { fprintf(stderr, "value expected for \"%s\" option.\n", pOpt->name); - return FALSE; + return false; } char *endp; i = strtol(argv[argNum], &endp, 0); if (endp == argv[argNum]) { fprintf(stderr, "integer value expected for \"%s\" option.\n", pOpt->name); - return FALSE; + return false; } *(int *)(pOpt->pVar) = i; } @@ -263,10 +263,10 @@ UBool ProcessOptions(int argc, const char **argv, OptSpec opts[]) if (pOpt->name == 0) { fprintf(stderr, "Unrecognized option \"%s\"\n", pArgName); - return FALSE; + return false; } } -return TRUE; +return true; } //--------------------------------------------------------------------------------------- @@ -425,7 +425,7 @@ void doKeyGen() unsigned long elapsedTime = timeGetTime() - startTime; int ns = (int)(float(1000000) * (float)elapsedTime / (float)(adj_loopCount*gNumFileLines)); - if (opt_terse == FALSE) { + if (opt_terse == false) { printf("Sort Key Generation: total # of keys = %d\n", loops*gNumFileLines); printf("Sort Key Generation: time per key = %d ns\n", ns); } @@ -448,7 +448,7 @@ void doKeyGen() } } - if (opt_terse == FALSE) { + if (opt_terse == false) { printf("Key Length / character = %f\n", (float)totalKeyLen / (float)totalChars); } else { printf("%f, ", (float)totalKeyLen / (float)totalChars); @@ -610,7 +610,7 @@ void doBinarySearch() r = CompareStringW(gWinLCID, 0, (gSortedLines[line])->name, lineLen, (gSortedLines[guess])->name, guessLen); } if (r == 0) { - if (opt_terse == FALSE) { + if (opt_terse == false) { fprintf(stderr, "Error returned from Windows CompareStringW.\n"); } exit(-1); @@ -679,7 +679,7 @@ void doBinarySearch() } int ns = (int)(float(1000000) * (float)elapsedTime / (float)gCount); - if (opt_terse == FALSE) { + if (opt_terse == false) { printf("binary search: total # of string compares = %d\n", gCount); printf("binary search: compares per loop = %d\n", gCount / loops); printf("binary search: time per compare = %d ns\n", ns); @@ -763,7 +763,7 @@ void doQSort() { unsigned long elapsedTime = timeGetTime() - startTime; int ns = (int)(float(1000000) * (float)elapsedTime / (float)gCount); - if (opt_terse == FALSE) { + if (opt_terse == false) { printf("qsort: total # of string compares = %d\n", gCount); printf("qsort: time per compare = %d ns\n", ns); } else { @@ -925,7 +925,7 @@ void doForwardIterTest(UBool haslen) { int count5 = 5; strindex = 0; ucol_setOffset(iter, strindex, &error); - while (TRUE) { + while (true) { if (ucol_next(iter, &error) == UCOL_NULLORDER) { break; } @@ -954,7 +954,7 @@ void doForwardIterTest(UBool haslen) { int count5 = 5; strindex = 0; ucol_setOffset(iter, strindex, &error); - while (TRUE) { + while (true) { tempgCount ++; count5 --; if (count5 == 0) { @@ -1088,7 +1088,7 @@ void doBackwardIterTest(UBool haslen) { int count5 = 5; strindex = 5; ucol_setOffset(iter, strindex, &error); - while (TRUE) { + while (true) { if (ucol_previous(iter, &error) == UCOL_NULLORDER) { break; } @@ -1117,7 +1117,7 @@ void doBackwardIterTest(UBool haslen) { int count5 = 5; strindex = 5; ucol_setOffset(iter, strindex, &error); - while (TRUE) { + while (true) { tempgCount ++; count5 --; if (count5 == 0) { @@ -1229,14 +1229,14 @@ private: }; UCharFile::UCharFile(const char * fileName) { - fEof = FALSE; - fError = FALSE; + fEof = false; + fError = false; fName = fileName; fFile = fopen(fName, "rb"); fPending2ndSurrogate = 0; if (fFile == NULL) { fprintf(stderr, "Can not open file \"%s\"\n", opt_fName); - fError = TRUE; + fError = true; return; } // @@ -1279,7 +1279,7 @@ UChar UCharFile::get() { c = cL | (cH << 8); if (cH == EOF) { c = 0; - fEof = TRUE; + fEof = true; } break; } @@ -1291,7 +1291,7 @@ UChar UCharFile::get() { c = cL | (cH << 8); if (cL == EOF) { c = 0; - fEof = TRUE; + fEof = true; } break; } @@ -1306,7 +1306,7 @@ UChar UCharFile::get() { int ch = fgetc(fFile); // Note: c and ch are separate cause eof test doesn't work on UChar type. if (ch == EOF) { c = 0; - fEof = TRUE; + fEof = true; break; } @@ -1324,7 +1324,7 @@ UChar UCharFile::get() { else if (ch >= 0xC0) {nBytes=2;} else { fprintf(stderr, "utf-8 encoded file contains corrupt data.\n"); - fError = TRUE; + fError = true; return 0; } @@ -1335,7 +1335,7 @@ UChar UCharFile::get() { bytes[i] = fgetc(fFile); if (bytes[i] < 0x80 || bytes[i] >= 0xc0) { fprintf(stderr, "utf-8 encoded file contains corrupt data.\n"); - fError = TRUE; + fError = true; return 0; } } @@ -1426,14 +1426,14 @@ UCollator *openRulesCollator() { // //---------------------------------------------------------------------------------------- int main(int argc, const char** argv) { - if (ProcessOptions(argc, argv, opts) != TRUE || opt_help || opt_fName == 0) { + if (ProcessOptions(argc, argv, opts) != true || opt_help || opt_fName == 0) { printf(gUsageString); exit (1); } // Make sure that we've only got one API selected. - if (opt_unix || opt_win) opt_icu = FALSE; - if (opt_unix) opt_win = FALSE; + if (opt_unix || opt_win) opt_icu = false; + if (opt_unix) opt_win = false; // // Set up an ICU collator @@ -1451,10 +1451,10 @@ int main(int argc, const char** argv) { return -1; } } - if (status==U_USING_DEFAULT_WARNING && opt_terse==FALSE) { + if (status==U_USING_DEFAULT_WARNING && opt_terse==false) { fprintf(stderr, "Warning, U_USING_DEFAULT_WARNING for %s\n", opt_locale); } - if (status==U_USING_FALLBACK_WARNING && opt_terse==FALSE) { + if (status==U_USING_FALLBACK_WARNING && opt_terse==false) { fprintf(stderr, "Warning, U_USING_FALLBACK_ERROR for %s\n", opt_locale); } @@ -1589,16 +1589,16 @@ int main(int argc, const char** argv) { buf[column++] = c; if (column >= 1023) { - static UBool warnFlag = TRUE; + static UBool warnFlag = true; if (warnFlag) { fprintf(stderr, "Warning - file line longer than 1023 chars truncated.\n"); - warnFlag = FALSE; + warnFlag = false; } column--; } } - if (opt_terse == FALSE) { + if (opt_terse == false) { printf("file \"%s\", %d lines.\n", opt_fName, gNumFileLines); } diff --git a/icu4c/source/test/perf/howExpensiveIs/howExpensiveIs.cpp b/icu4c/source/test/perf/howExpensiveIs/howExpensiveIs.cpp index c7771bb9b89..7fe13cbeeb6 100644 --- a/icu4c/source/test/perf/howExpensiveIs/howExpensiveIs.cpp +++ b/icu4c/source/test/perf/howExpensiveIs/howExpensiveIs.cpp @@ -500,7 +500,7 @@ protected: case kApplyPattern: { UNumberFormat *fmt = unum_open(UNUM_DECIMAL, NULL, -1, TEST_LOCALE, 0, &setupStatus); - unum_applyPattern(fmt, FALSE, fPat.getTerminatedBuffer(), -1, NULL, &setupStatus); + unum_applyPattern(fmt, false, fPat.getTerminatedBuffer(), -1, NULL, &setupStatus); return fmt; } case kGroupOff: @@ -512,7 +512,7 @@ protected: case kApplyGroupOff: { UNumberFormat *fmt = unum_open(UNUM_DECIMAL, NULL, -1, TEST_LOCALE, 0, &setupStatus); - unum_applyPattern(fmt, FALSE, fPat.getTerminatedBuffer(), -1, NULL, &setupStatus); + unum_applyPattern(fmt, false, fPat.getTerminatedBuffer(), -1, NULL, &setupStatus); unum_setAttribute(fmt, UNUM_GROUPING_USED, UNUM_NO); return fmt; } diff --git a/icu4c/source/test/perf/howExpensiveIs/sieve.cpp b/icu4c/source/test/perf/howExpensiveIs/sieve.cpp index 87138424b80..0478b6d6bf2 100644 --- a/icu4c/source/test/perf/howExpensiveIs/sieve.cpp +++ b/icu4c/source/test/perf/howExpensiveIs/sieve.cpp @@ -190,12 +190,12 @@ U_CAPI double uprv_getMeanTime(double *times, uint32_t *timeCount, double *margi return meanTime; } -UBool calcSieveTime = FALSE; +UBool calcSieveTime = false; double meanSieveTime = 0.0; double meanSieveME = 0.0; U_CAPI double uprv_getSieveTime(double *marginOfError) { - if(calcSieveTime==FALSE) { + if(!calcSieveTime) { #define SAMPLES 50 uint32_t samples = SAMPLES; double times[SAMPLES]; @@ -208,7 +208,7 @@ U_CAPI double uprv_getSieveTime(double *marginOfError) { } meanSieveTime = uprv_getMeanTime(times, &samples,&meanSieveME); - calcSieveTime=TRUE; + calcSieveTime=true; } if(marginOfError!=NULL) { *marginOfError = meanSieveME; diff --git a/icu4c/source/test/perf/normperf/normperf.h b/icu4c/source/test/perf/normperf/normperf.h index ac9e2499c79..b29a7bc99c1 100644 --- a/icu4c/source/test/perf/normperf/normperf.h +++ b/icu4c/source/test/perf/normperf/normperf.h @@ -47,7 +47,7 @@ private: public: virtual void call(UErrorCode* status){ - if(line_mode==TRUE){ + if(line_mode){ if(uselen){ for(int32_t i = 0; i< numLines; i++){ retVal = (*fn)(lines[i].name,lines[i].len,mode, options, status); @@ -68,7 +68,7 @@ public: } virtual long getOperationsPerIteration(){ - if(line_mode==TRUE){ + if(line_mode){ int32_t totalChars=0; for(int32_t i =0; i< numLines; i++){ totalChars+= lines[i].len; @@ -86,7 +86,7 @@ public: mode = _mode; src = NULL; srcLen = 0; - line_mode = TRUE; + line_mode = true; } QuickCheckPerfFunction(QuickCheckFn func, const UChar* source,int32_t sourceLen, UNormalizationMode _mode, int32_t opts, UBool _uselen) : options(opts) { fn = func; @@ -96,7 +96,7 @@ public: mode = _mode; src = source; srcLen = sourceLen; - line_mode = FALSE; + line_mode = false; } }; @@ -118,7 +118,7 @@ private: public: virtual void call(UErrorCode* status){ - if(line_mode==TRUE){ + if(line_mode){ if(uselen){ for(int32_t i = 0; i< numLines; i++){ retVal = (*fn)(lines[i].name,lines[i].len,pDest,destLen, options, status); @@ -137,7 +137,7 @@ public: } } virtual long getOperationsPerIteration(){ - if(line_mode ==TRUE){ + if(line_mode){ int32_t totalChars=0; for(int32_t i =0; i< numLines; i++){ totalChars+= lines[i].len; @@ -156,7 +156,7 @@ public: pDest = dest; src = NULL; srcLen = 0; - line_mode = TRUE; + line_mode = true; } NormPerfFunction(NormFn func, int32_t opts, const UChar* source,int32_t sourceLen,UBool _uselen) : options(opts) { fn = func; @@ -167,7 +167,7 @@ public: pDest = (UChar*) malloc(destLen * U_SIZEOF_UCHAR); src = source; srcLen = sourceLen; - line_mode = FALSE; + line_mode = false; } ~NormPerfFunction(){ if(dest != pDest){ diff --git a/icu4c/source/test/perf/normperf/simplenormperf.cpp b/icu4c/source/test/perf/normperf/simplenormperf.cpp index b6865ba1eca..2f7341b71f6 100644 --- a/icu4c/source/test/perf/normperf/simplenormperf.cpp +++ b/icu4c/source/test/perf/normperf/simplenormperf.cpp @@ -255,7 +255,7 @@ double NormalizeUTF16::call(int32_t iterations, int32_t pieceLength) { UErrorCode errorCode = U_ZERO_ERROR; utimer_getTime(&startTime); for (int32_t i = 0; i < iterations; ++i) { - piece.setTo(FALSE, s + start, pieceLength); + piece.setTo(false, s + start, pieceLength); norm2.normalize(piece, dest, errorCode); start = (start + pieceLength) % limit; } diff --git a/icu4c/source/test/perf/usetperf/bitset.cpp b/icu4c/source/test/perf/usetperf/bitset.cpp index a489a8578f7..71da112f2ba 100644 --- a/icu4c/source/test/perf/usetperf/bitset.cpp +++ b/icu4c/source/test/perf/usetperf/bitset.cpp @@ -35,7 +35,7 @@ UBool BitSet::get(int32_t bitIndex) const { uint32_t longIndex = bitIndex >> 5; int32_t bitInLong = bitIndex & 0x1F; return (longIndex < len) ? (((data[longIndex] >> bitInLong) & 1) != 0) - : FALSE; + : false; } void BitSet::set(int32_t bitIndex) {