]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/icu/dev/test/perf/collationperf.pl
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / icu / dev / test / perf / collationperf.pl
1 #/**\r
2 # *******************************************************************************\r
3 # * Copyright (C) 2002-2004, International Business Machines Corporation and    *\r
4 # * others. All Rights Reserved.                                                *\r
5 # *******************************************************************************\r
6 # */\r
7 #\r
8 #  ICU and Windows Collation performance test script\r
9 #      Used in conjunction with the collperf test program.\r
10 #      This script defines the locales and data files to be tested,\r
11 #        runs the collperf program, and formats and prints the results.\r
12 #\r
13 #        7 June 2001   Andy Heninger\r
14 #\r
15 #  ICU4J and Java Collator performance test script\r
16 #  2002-09-25 modified by Richard Liang\r
17 \r
18 print "To run this performance test\n";\r
19 print "cd to the ICU4J root directory, one directory below src\n";\r
20 print "run perl src\\com\\ibm\\icu\\dev\\test\\perf\\collationperf.pl\n";\r
21 \r
22 #\r
23 # Map defines the set of data files to run in each locale\r
24 #\r
25 %dataFiles = (\r
26    "en_US",         "TestNames_Latin.txt",\r
27    "da_DK",         "TestNames_Latin.txt",\r
28    "de_DE",         "TestNames_Latin.txt",\r
29    "de__PHONEBOOK", "TestNames_Latin.txt",\r
30    "fr_FR",         "TestNames_Latin.txt",\r
31    "ja_JP",         "TestNames_Latin.txt TestNames_Japanese_h.txt TestNames_Japanese_k.txt TestNames_Asian.txt",\r
32    "zh_CN",         "TestNames_Latin.txt TestNames_Chinese.txt",\r
33    "zh_TW",         "TestNames_Latin.txt TestNames_Chinese.txt",\r
34    "zh__PINYIN",    "TestNames_Latin.txt TestNames_Chinese.txt",\r
35    "ru_RU",         "TestNames_Latin.txt TestNames_Russian.txt",\r
36    "th",            "TestNames_Latin.txt TestNames_Thai.txt",\r
37    "ko_KR",         "TestNames_Latin.txt TestNames_Korean.txt",\r
38    );\r
39 \r
40 \r
41 #\r
42 #  Outer loop runs through the locales to test\r
43 #     (Edit this list dirctly to make changes)\r
44 #\r
45    foreach $locale (\r
46            "en_US",\r
47            "da_DK",\r
48            "de_DE",\r
49            "de__PHONEBOOK",\r
50            "fr_FR",\r
51            "ja_JP",\r
52        "zh_CN",\r
53            "zh_TW",\r
54            "zh__PINYIN",\r
55        "ko_KR",\r
56            "ru_RU",\r
57            "th",\r
58                    )\r
59        {\r
60        #\r
61        # Inner loop runs over the set of data files specified for each locale.\r
62        #    (Edit the %datafiles initialization, above, to make changes.\r
63        #\r
64        $ff = $dataFiles{$locale};\r
65        @ff = split(/[\s]+/, $ff);\r
66        foreach $data (@ff) {\r
67 \r
68           #\r
69           # Run ICU Test for this (locale, data file) pair.\r
70           #\r
71           $iStrCol = `java -classpath classes com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file src/com/ibm/icu/dev/test/perf/data/collation/$data -locale $locale -loop 1000 -binsearch`;\r
72           $iStrCol =~s/[,\s]*//g;  # whack off the leading "  ," in the returned result.\r
73           doKeyTimes("java -classpath classes com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file src/com/ibm/icu/dev/test/perf/data/collation/$data -locale $locale -loop 1000 -keygen",\r
74                      $iKeyGen, $iKeyLen);\r
75 \r
76 \r
77           #\r
78           # Run Windows test for this (locale, data file) pair.  Only do if\r
79           #    we are not on Windows 98/ME and we hava a windows langID\r
80           #    for the locale.\r
81           #\r
82           $wStrCol = $wKeyGen = $wKeyLen = 0;\r
83           $wStrCol = `java -classpath classes com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file src/com/ibm/icu/dev/test/perf/data/collation/$data -locale $locale -loop 1000 -binsearch -java`;\r
84           $wStrCol =~s/[,\s]*//g;  # whack off the leading "  ," in the returned result.\r
85           doKeyTimes("java -classpath classes com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file src/com/ibm/icu/dev/test/perf/data/collation/$data -locale $locale -loop 1000 -keygen -java",\r
86                      $wKeyGen, $wKeyLen);\r
87                      \r
88           $collDiff = $keyGenDiff = $keyLenDiff = 0;\r
89           if ($wKeyLen > 0) {\r
90               $collDiff   = (($wStrCol - $iStrCol) / $iStrCol) * 100;\r
91               $keyGenDiff = (($wKeyGen - $iKeyGen) / $iKeyGen) * 100;\r
92               $keyLenDiff = (($wKeyLen - $iKeyLen) / $iKeyLen) * 100;\r
93           }\r
94 \r
95          #\r
96          #  Write the line of results for this (locale, data file).\r
97          #\r
98          write;\r
99     }\r
100  }\r
101 \r
102 #\r
103 #  doKeyGenTimes($Command_to_run, $time, $key_length)\r
104 #       Do a key-generation test and return the time and key length/char values.\r
105 #\r
106 sub doKeyTimes($$$) {\r
107    # print "$_[0]\n";\r
108    local($x) = `$_[0]`;                  # execute the collperf command.\r
109    ($_[1], $_[2]) = split(/\,/, $x);     # collperf returns "time, keylength" string.\r
110 }\r
111 \r
112 \r
113 #\r
114 #  Output Formats ...\r
115 #\r
116 #\r
117 format STDOUT_TOP =\r
118                                       -------- ICU --------   ------ JAVA -------      (JAVA - ICU)/ICU\r
119 Locale     Data file                  strcoll keygen  keylen  strcoll keygen  keylen    coll  keygen  keylen\r
120 ------------------------------------------------------------------------------------------------------------\r
121 .\r
122 \r
123 format STDOUT =\r
124 @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<| @######  @####   @#.##  |@##### @#####   @#.## | @###%  @###%   @###%\r
125 $locale, $data, $iStrCol, $iKeyGen, $iKeyLen, $wStrCol, $wKeyGen, $wKeyLen, $collDiff, $keyGenDiff, $keyLenDiff\r
126 .\r