1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/********************************************************************
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * COPYRIGHT:
383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius * Copyright (C) 2001-2011 International Business Machines Corporation
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and others. All Rights Reserved.
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru ********************************************************************/
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/********************************************************************************
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* File ubrkperf.cpp
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Modification History:
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*        Name                     Description
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*     Vladimir Weinstein          First Version, based on collperf
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*********************************************************************************
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "ubrkperf.h"
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "uoptions.h"
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <stdio.h>
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if 0
2483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#if U_PLATFORM_IS_DARWIN_BASED
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <ApplicationServices/ApplicationServices.h>
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruenum{
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  kUCTextBreakAllMask = (kUCTextBreakClusterMask | kUCTextBreakWordMask | kUCTextBreakLineMask)
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    };
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUCTextBreakType breakTypes[4] = {kUCTextBreakCharMask, kUCTextBreakClusterMask, kUCTextBreakWordMask, kUCTextBreakLineMask};
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruTextBreakLocatorRef breakRef;
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUCTextBreakType macBreakType;
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid createMACBrkIt() {
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  OSStatus status = noErr;
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  LocaleRef lref;
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  status = LocaleRefFromLocaleString(opt_locale, &lref);
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  status = UCCreateTextBreakLocator(lref, 0, kUCTextBreakAllMask, (TextBreakLocatorRef*)&breakRef);
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  if(opt_char == TRUE) {
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    macBreakType = kUCTextBreakClusterMask;
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  } else if(opt_word == TRUE) {
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    macBreakType = kUCTextBreakWordMask;
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  } else if(opt_line == TRUE) {
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    macBreakType = kUCTextBreakLineMask;
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  } else if(opt_sentence == TRUE) {
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // error
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // brkit = BreakIterator::createSentenceInstance(opt_locale, status);
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  } else {
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // default is character iterator
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    macBreakType = kUCTextBreakClusterMask;
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      }
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid doForwardTest() {
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  if (opt_terse == FALSE) {
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    printf("Doing the forward test\n");
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  }
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  int32_t noBreaks = 0;
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  int32_t i = 0;
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  unsigned long startTime = timeGetTime();
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  unsigned long elapsedTime = 0;
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  if(opt_icu) {
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    createICUBrkIt();
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    brkit->setText(text);
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    brkit->first();
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (opt_terse == FALSE) {
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      printf("Warmup\n");
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    while(brkit->next() != BreakIterator::DONE) {
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      noBreaks++;
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (opt_terse == FALSE) {
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      printf("Measure\n");
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    startTime = timeGetTime();
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i = 0; i < opt_loopCount; i++) {
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      brkit->first();
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      while(brkit->next() != BreakIterator::DONE) {
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      }
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    elapsedTime = timeGetTime()-startTime;
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  } else if(opt_mac) {
8683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius#if U_PLATFORM_IS_DARWIN_BASED
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    createMACBrkIt();
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UniChar* filePtr = text;
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    OSStatus status = noErr;
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UniCharCount startOffset = 0, breakOffset = 0, numUniChars = textSize;
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    startOffset = 0;
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    //printf("\t---Search forward--\n");
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    while (startOffset < numUniChars)
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru	status = UCFindTextBreak(breakRef, macBreakType, kUCTextBreakLeadingEdgeMask, filePtr, numUniChars,
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                               startOffset, &breakOffset);
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      //require_action(status == noErr, EXIT, printf( "**UCFindTextBreak failed: startOffset %d, status %d\n", (int)startOffset, (int)status));
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      //require_action((breakOffset <= numUniChars),EXIT, printf("**UCFindTextBreak breakOffset too big: startOffset %d, breakOffset %d\n", (int)startOffset, (int)breakOffset));
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      // Output break
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      //printf("\t%d\n", (int)breakOffset);
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      // Increment counters
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru	noBreaks++;
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      startOffset = breakOffset;
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    startTime = timeGetTime();
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for(i = 0; i < opt_loopCount; i++) {
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      startOffset = 0;
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      while (startOffset < numUniChars)
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru	{
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru	  status = UCFindTextBreak(breakRef, macBreakType, kUCTextBreakLeadingEdgeMask, filePtr, numUniChars,
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru				   startOffset, &breakOffset);
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru	  // Increment counters
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru	  startOffset = breakOffset;
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru	}
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    elapsedTime = timeGetTime()-startTime;
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UCDisposeTextBreakLocator(&breakRef);
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  }
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  if (opt_terse == FALSE) {
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  int32_t loopTime = (int)(float(1000) * ((float)elapsedTime/(float)opt_loopCount));
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      int32_t timePerCU = (int)(float(1000) * ((float)loopTime/(float)textSize));
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      int32_t timePerBreak = (int)(float(1000) * ((float)loopTime/(float)noBreaks));
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      printf("forward break iteration average loop time %d\n", loopTime);
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      printf("number of code units %d average time per code unit %d\n", textSize, timePerCU);
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      printf("number of breaks %d average time per break %d\n", noBreaks, timePerBreak);
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  } else {
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      printf("time=%d\nevents=%d\nsize=%d\n", elapsedTime, noBreaks, textSize);
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  }
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUPerfFunction* BreakIteratorPerformanceTest::TestICUForward()
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  return new ICUForward(locale, m_mode_, m_file_, m_fileLen_);
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUPerfFunction* BreakIteratorPerformanceTest::TestICUIsBound()
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  return new ICUIsBound(locale, m_mode_, m_file_, m_fileLen_);
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUPerfFunction* BreakIteratorPerformanceTest::TestDarwinForward()
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  return NULL;
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUPerfFunction* BreakIteratorPerformanceTest::TestDarwinIsBound()
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru  return NULL;
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUPerfFunction* BreakIteratorPerformanceTest::runIndexedTest(int32_t index, UBool exec,
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru												   const char *&name,
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru												   char* par)
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    switch (index) {
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        TESTCASE(0, TestICUForward);
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru		TESTCASE(1, TestICUIsBound);
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru		TESTCASE(2, TestDarwinForward);
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru		TESTCASE(3, TestDarwinIsBound);
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        default:
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            name = "";
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            return NULL;
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return NULL;
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruUOption options[]={
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                      UOPTION_DEF( "mode",        'm', UOPT_REQUIRES_ARG)
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                  };
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruBreakIteratorPerformanceTest::BreakIteratorPerformanceTest(int32_t argc, const char* argv[], UErrorCode& status)
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru: UPerfTest(argc,argv,status),
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querum_mode_(NULL),
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querum_file_(NULL),
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querum_fileLen_(0)
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    _remainingArgc = u_parseArgs(_remainingArgc, (char**)argv, (int32_t)(sizeof(options)/sizeof(options[0])), options);
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(options[0].doesOccur) {
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      m_mode_ = options[0].value;
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      switch(options[0].value[0]) {
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      case 'w' :
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      case 'c' :
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      case 's' :
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      case 'l' :
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      default:
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        status = U_ILLEGAL_ARGUMENT_ERROR;
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      }
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } else {
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru      status = U_ILLEGAL_ARGUMENT_ERROR;
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    m_file_ = getBuffer(m_fileLen_, status);
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(status== U_ILLEGAL_ARGUMENT_ERROR){
21785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho       fprintf(stderr, gUsageString, "ubrkperf");
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru       fprintf(stderr, "\t-m or --mode        Required mode for breakiterator: char, word, line or sentence\n");
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru       return;
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status)){
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        fprintf(stderr, "FAILED to create UPerfTest object. Error: %s\n", u_errorName(status));
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return;
226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruBreakIteratorPerformanceTest::~BreakIteratorPerformanceTest()
230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//----------------------------------------------------------------------------------------
235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//
236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//    Main   --  process command line, read in and pre-process the test file,
237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//                 call other functions to do the actual tests.
238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//
239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//----------------------------------------------------------------------------------------
240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruint main(int argc, const char** argv) {
241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UErrorCode status = U_ZERO_ERROR;
242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    BreakIteratorPerformanceTest test(argc, argv, status);
243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(U_FAILURE(status)){
244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return status;
245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if(test.run()==FALSE){
247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        fprintf(stderr,"FAILED: Tests could not be run please check the arguments.\n");
248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return -1;
249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return 0;
251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
252