]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/perf/strsrchperf/strsrchperf.h
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / test / perf / strsrchperf / strsrchperf.h
index 6f2281c5855e74f3c1031294f6d3579e629cab79..a68ab3a1b06486b5a88cf8296db847e067fec0b3 100644 (file)
@@ -1,26 +1,17 @@
 /********************************************************************
  * COPYRIGHT:
- * Copyright (C) 2008-2009 IBM, Inc.   All Rights Reserved.
+ * Copyright (C) 2008-2012 IBM, Inc.   All Rights Reserved.
  *
  ********************************************************************/
 #ifndef _STRSRCHPERF_H
 #define _STRSRCHPERF_H
 
-#include "unicode/ubrk.h"
 #include "unicode/usearch.h"
-#include "unicode/colldata.h"
-#include "unicode/bmsearch.h"
 #include "unicode/uperf.h"
 #include <stdlib.h>
 #include <stdio.h>
 
-#define TEST_BOYER_MOORE_SEARCH
-
-#ifdef TEST_BOYER_MOORE_SEARCH
-typedef void (*StrSrchFn) (BoyerMooreSearch * bms, const UChar *src, int32_t srcLen, const UChar *pttrn, int32_t pttrnLen, UErrorCode *status);
-#else
 typedef void (*StrSrchFn)(UStringSearch* srch, const UChar* src,int32_t srcLen, const UChar* pttrn, int32_t pttrnLen, UErrorCode* status);
-#endif
 
 class StringSearchPerfFunction : public UPerfFunction {
 private:
@@ -29,39 +20,17 @@ private:
     int32_t srcLen;
     const UChar* pttrn;
     int32_t pttrnLen;
-#ifdef TEST_BOYER_MOORE_SEARCH
-    BoyerMooreSearch *bms;
-#else
     UStringSearch* srch;
-#endif
     
 public:
     virtual void call(UErrorCode* status) {
-#ifdef TEST_BOYER_MOORE_SEARCH
-        (*fn)(bms, src, srcLen, pttrn, pttrnLen, status);
-#else
         (*fn)(srch, src, srcLen, pttrn, pttrnLen, status);
-#endif
     }
     
     virtual long getOperationsPerIteration() {
-#if 0
-        return (long)(srcLen/pttrnLen);
-#else
         return (long) srcLen;
-#endif
     }
     
-#ifdef TEST_BOYER_MOORE_SEARCH
-    StringSearchPerfFunction(StrSrchFn func, BoyerMooreSearch *search, const UChar *source, int32_t sourceLen, const UChar *pattern, int32_t patternLen) {
-        fn       = func;
-        src      = source;
-        srcLen   = sourceLen;
-        pttrn    = pattern;
-        pttrnLen = patternLen;
-        bms      = search;
-    }
-#else
     StringSearchPerfFunction(StrSrchFn func, UStringSearch* search, const UChar* source,int32_t sourceLen, const UChar* pattern, int32_t patternLen) {
         fn = func;
         src = source;
@@ -70,7 +39,6 @@ public:
         pttrnLen = patternLen;
         srch = search;
     }
-#endif
 };
 
 class StringSearchPerformanceTest : public UPerfTest {
@@ -79,42 +47,17 @@ private:
     int32_t srcLen;
     UChar* pttrn;
     int32_t pttrnLen;
-#ifdef TEST_BOYER_MOORE_SEARCH
-    UnicodeString *targetString;
-    BoyerMooreSearch *bms;
-#else
     UStringSearch* srch;
-#endif
     
 public:
     StringSearchPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status);
     ~StringSearchPerformanceTest();
     virtual UPerfFunction* runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = NULL);
-    
     UPerfFunction* Test_ICU_Forward_Search();
-
     UPerfFunction* Test_ICU_Backward_Search();
 };
 
 
-#ifdef TEST_BOYER_MOORE_SEARCH
-void ICUForwardSearch(BoyerMooreSearch *bms, const UChar *source, int32_t sourceLen, const UChar *pattern, int32_t patternLen, UErrorCode * /*status*/) { 
-    int32_t offset = 0, start = -1, end = -1;
-
-    while (bms->search(offset, start, end)) {
-        offset = end;
-    }
-}
-
-void ICUBackwardSearch(BoyerMooreSearch *bms, const UChar *source, int32_t sourceLen, const UChar *pattern, int32_t patternLen, UErrorCode * /*status*/) { 
-    int32_t offset = 0, start = -1, end = -1;
-
-    /* NOTE: No Boyer-Moore backward search yet... */
-    while (bms->search(offset, start, end)) {
-        offset = end;
-    }
-}
-#else
 void ICUForwardSearch(UStringSearch *srch, const UChar* source, int32_t sourceLen, const UChar* pattern, int32_t patternLen, UErrorCode* status) {
     int32_t match;
     
@@ -132,6 +75,5 @@ void ICUBackwardSearch(UStringSearch *srch, const UChar* source, int32_t sourceL
         match = usearch_previous(srch, status);
     }
 }
-#endif
 
 #endif /* _STRSRCHPERF_H */