OLD | NEW |
1 /* | 1 /* |
2 ********************************************************************** | 2 ********************************************************************** |
3 * Copyright (C) 2007, International Business Machines | 3 * Copyright (C) 2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ********************************************************************** | 5 ********************************************************************** |
6 * file name: unisetperf.cpp | 6 * file name: unisetperf.cpp |
7 * encoding: US-ASCII | 7 * encoding: US-ASCII |
8 * tab size: 8 (not used) | 8 * tab size: 8 (not used) |
9 * indentation:4 | 9 * indentation:4 |
10 * | 10 * |
11 * created on: 2007jan31 | 11 * created on: 2007jan31 |
12 * created by: Markus Scherer | 12 * created by: Markus Scherer |
13 */ | 13 */ |
14 | 14 |
15 #include <stdio.h> | 15 #include <stdio.h> |
16 #include <stdlib.h> | 16 #include <stdlib.h> |
17 #include <string.h> | 17 #include <string.h> |
18 #include "unicode/uperf.h" | 18 #include "unicode/uperf.h" |
19 #include "unicode/uniset.h" | 19 #include "unicode/uniset.h" |
20 #include "unicode/unistr.h" | 20 #include "unicode/unistr.h" |
21 #include "uoptions.h" | 21 #include "uoptions.h" |
22 | 22 #include "cmemory.h" // for UPRV_LENGTHOF |
23 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
24 | 23 |
25 // Command-line options specific to unisetperf. | 24 // Command-line options specific to unisetperf. |
26 // Options do not have abbreviations: Force readable command lines. | 25 // Options do not have abbreviations: Force readable command lines. |
27 // (Using U+0001 for abbreviation characters.) | 26 // (Using U+0001 for abbreviation characters.) |
28 enum { | 27 enum { |
29 SET_PATTERN, | 28 SET_PATTERN, |
30 FAST_TYPE, | 29 FAST_TYPE, |
31 UNISETPERF_OPTIONS_COUNT | 30 UNISETPERF_OPTIONS_COUNT |
32 }; | 31 }; |
33 | 32 |
34 static UOption options[UNISETPERF_OPTIONS_COUNT]={ | 33 static UOption options[UNISETPERF_OPTIONS_COUNT]={ |
35 UOPTION_DEF("pattern", '\x01', UOPT_REQUIRES_ARG), | 34 UOPTION_DEF("pattern", '\x01', UOPT_REQUIRES_ARG), |
36 UOPTION_DEF("type", '\x01', UOPT_REQUIRES_ARG) | 35 UOPTION_DEF("type", '\x01', UOPT_REQUIRES_ARG) |
37 }; | 36 }; |
38 | 37 |
39 static const char *const unisetperf_usage = | 38 static const char *const unisetperf_usage = |
40 "\t--pattern UnicodeSet pattern for instantiation.\n" | 39 "\t--pattern UnicodeSet pattern for instantiation.\n" |
41 "\t Default: [:ID_Continue:]\n" | 40 "\t Default: [:ID_Continue:]\n" |
42 "\t--type Type of UnicodeSet: slow fast\n" | 41 "\t--type Type of UnicodeSet: slow fast\n" |
43 "\t Default: slow\n"; | 42 "\t Default: slow\n"; |
44 | 43 |
45 // Test object with setup data. | 44 // Test object with setup data. |
46 class UnicodeSetPerformanceTest : public UPerfTest { | 45 class UnicodeSetPerformanceTest : public UPerfTest { |
47 public: | 46 public: |
48 UnicodeSetPerformanceTest(int32_t argc, const char *argv[], UErrorCode &stat
us) | 47 UnicodeSetPerformanceTest(int32_t argc, const char *argv[], UErrorCode &stat
us) |
49 : UPerfTest(argc, argv, options, LENGTHOF(options), unisetperf_usage
, status), | 48 : UPerfTest(argc, argv, options, UPRV_LENGTHOF(options), unisetperf_
usage, status), |
50 utf8(NULL), utf8Length(0), countInputCodePoints(0), spanCount(0) { | 49 utf8(NULL), utf8Length(0), countInputCodePoints(0), spanCount(0) { |
51 if (U_SUCCESS(status)) { | 50 if (U_SUCCESS(status)) { |
52 UnicodeString pattern=UnicodeString(options[SET_PATTERN].value, -1,
US_INV).unescape(); | 51 UnicodeString pattern=UnicodeString(options[SET_PATTERN].value, -1,
US_INV).unescape(); |
53 set.applyPattern(pattern, status); | 52 set.applyPattern(pattern, status); |
54 prefrozen=set; | 53 prefrozen=set; |
55 if(0==strcmp(options[FAST_TYPE].value, "fast")) { | 54 if(0==strcmp(options[FAST_TYPE].value, "fast")) { |
56 set.freeze(); | 55 set.freeze(); |
57 } | 56 } |
58 | 57 |
59 int32_t inputLength; | 58 int32_t inputLength; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 } | 431 } |
433 | 432 |
434 if (test.run() == FALSE){ | 433 if (test.run() == FALSE){ |
435 fprintf(stderr, "FAILED: Tests could not be run, please check the " | 434 fprintf(stderr, "FAILED: Tests could not be run, please check the " |
436 "arguments.\n"); | 435 "arguments.\n"); |
437 return 1; | 436 return 1; |
438 } | 437 } |
439 | 438 |
440 return 0; | 439 return 0; |
441 } | 440 } |
OLD | NEW |