X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/46f4442e9a5a4f3b98b7c1083586332f6a8a99a4..57a6839dcb3bba09e8228b822b290604668416fe:/icuSources/test/perf/strsrchperf/strsrchperf.cpp diff --git a/icuSources/test/perf/strsrchperf/strsrchperf.cpp b/icuSources/test/perf/strsrchperf/strsrchperf.cpp index 4d899211..1c70316b 100644 --- a/icuSources/test/perf/strsrchperf/strsrchperf.cpp +++ b/icuSources/test/perf/strsrchperf/strsrchperf.cpp @@ -1,6 +1,6 @@ /******************************************************************** * COPYRIGHT: - * Copyright (C) 2008 IBM, Inc. All Rights Reserved. + * Copyright (C) 2008-2012 IBM, Inc. All Rights Reserved. * ********************************************************************/ /** @@ -22,7 +22,8 @@ StringSearchPerformanceTest::StringSearchPerformanceTest(int32_t argc, const cha } /* Get the Text */ src = getBuffer(srcLen, status); - + +#if 0 /* Get a word to find. Do this by selecting a random word with a word breakiterator. */ UBreakIterator* brk = ubrk_open(UBRK_WORD, locale, src, srcLen, &status); if(U_FAILURE(status)){ @@ -38,9 +39,29 @@ StringSearchPerformanceTest::StringSearchPerformanceTest(int32_t argc, const cha } pttrn = temp; /* store word in pttrn */ ubrk_close(brk); +#else + /* The first line of the file contains the pattern */ + start = 0; + + for(end = start; ; end += 1) { + UChar ch = src[end]; + + if (ch == 0x000A || ch == 0x000D || ch == 0x2028) { + break; + } + } + + pttrnLen = end - start; + UChar* temp = (UChar*)malloc(sizeof(UChar)*(pttrnLen)); + for (int i = 0; i < pttrnLen; i++) { + temp[i] = src[start++]; + } + pttrn = temp; /* store word in pttrn */ +#endif /* Create the StringSearch object to be use in performance test. */ srch = usearch_open(pttrn, pttrnLen, src, srcLen, locale, NULL, &status); + if(U_FAILURE(status)){ fprintf(stderr, "FAILED to create UPerfTest object. Error: %s\n", u_errorName(status)); return;