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