+static char intermediate[OUTPUT_CAPACITY];
+
+static int32_t utf8Length, encodedLength, outputLength, countInputCodePoints;
+
+static int32_t fromUCallbackCount;
+
+// Command-line options specific to utfperf.
+// Options do not have abbreviations: Force readable command lines.
+// (Using U+0001 for abbreviation characters.)
+enum {
+ CHARSET,
+ CHUNK_LENGTH,
+ PIVOT_LENGTH,
+ UTFPERF_OPTIONS_COUNT
+};
+
+static UOption options[UTFPERF_OPTIONS_COUNT]={
+ UOPTION_DEF("charset", '\x01', UOPT_REQUIRES_ARG),
+ UOPTION_DEF("chunk", '\x01', UOPT_REQUIRES_ARG),
+ UOPTION_DEF("pivot", '\x01', UOPT_REQUIRES_ARG)
+};
+
+static const char *const utfperf_usage =
+ "\t--charset Charset for which to test performance, e.g. windows-1251.\n"
+ "\t Default: UTF-8\n"
+ "\t--chunk Length (in bytes) of charset output chunks. [4096]\n"
+ "\t--pivot Length (in UChars) of the UTF-16 pivot buffer, if applicable.\n"
+ "\t [1024]\n";
+
+// Test object.
+class UtfPerformanceTest : public UPerfTest{
+public:
+ UtfPerformanceTest(int32_t argc, const char *argv[], UErrorCode &status)
+ : UPerfTest(argc, argv, options, UPRV_LENGTHOF(options), utfperf_usage, status) {
+ if (U_SUCCESS(status)) {
+ charset = options[CHARSET].value;
+
+ chunkLength = atoi(options[CHUNK_LENGTH].value);
+ if (chunkLength < 1 || OUTPUT_CAPACITY < chunkLength) {
+ fprintf(stderr, "error: chunk length must be 1..%ld\n", (long)OUTPUT_CAPACITY);
+ status = U_ILLEGAL_ARGUMENT_ERROR;
+ }