Skip to content

Commit

Permalink
ICU-21391 Make test/perf compile
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang authored and sffc committed Nov 16, 2020
1 parent f48165d commit ceeb53a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 68 deletions.
106 changes: 53 additions & 53 deletions icu4c/source/test/perf/collationperf/collperf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;



Expand Down Expand Up @@ -233,27 +233,27 @@ 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;
case OptSpec::NUM:
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;
}
Expand All @@ -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;
}

//---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1229,14 +1229,14 @@ class UCharFile {
};

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;
}
//
Expand Down Expand Up @@ -1279,7 +1279,7 @@ UChar UCharFile::get() {
c = cL | (cH << 8);
if (cH == EOF) {
c = 0;
fEof = TRUE;
fEof = true;
}
break;
}
Expand All @@ -1291,7 +1291,7 @@ UChar UCharFile::get() {
c = cL | (cH << 8);
if (cL == EOF) {
c = 0;
fEof = TRUE;
fEof = true;
}
break;
}
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/test/perf/howExpensiveIs/howExpensiveIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class NumFmtInt64Test : public HowExpensiveTest {
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:
Expand All @@ -512,7 +512,7 @@ class NumFmtInt64Test : public HowExpensiveTest {
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;
}
Expand Down
6 changes: 3 additions & 3 deletions icu4c/source/test/perf/howExpensiveIs/sieve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down
Loading

0 comments on commit ceeb53a

Please sign in to comment.