File: collationperf.pl

package info (click to toggle)
icu4j-49 49.1-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 60,184 kB
  • ctags: 28,724
  • sloc: java: 270,873; xml: 4,623; perl: 3,097; makefile: 15; sh: 11
file content (126 lines) | stat: -rw-r--r-- 5,100 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#/**
# *******************************************************************************
# * Copyright (C) 2002-2004, International Business Machines Corporation and    *
# * others. All Rights Reserved.                                                *
# *******************************************************************************
# */
#
#  ICU and Windows Collation performance test script
#      Used in conjunction with the collperf test program.
#      This script defines the locales and data files to be tested,
#        runs the collperf program, and formats and prints the results.
#
#        7 June 2001   Andy Heninger
#
#  ICU4J and Java Collator performance test script
#  2002-09-25 modified by Richard Liang

print "To run this performance test\n";
print "cd to the ICU4J root directory, one directory below src\n";
print "run perl src\\com\\ibm\\icu\\dev\\test\\perf\\collationperf.pl\n";

#
# Map defines the set of data files to run in each locale
#
%dataFiles = (
   "en_US",         "TestNames_Latin.txt",
   "da_DK",         "TestNames_Latin.txt",
   "de_DE",         "TestNames_Latin.txt",
   "de__PHONEBOOK", "TestNames_Latin.txt",
   "fr_FR",         "TestNames_Latin.txt",
   "ja_JP",         "TestNames_Latin.txt TestNames_Japanese_h.txt TestNames_Japanese_k.txt TestNames_Asian.txt",
   "zh_CN",         "TestNames_Latin.txt TestNames_Chinese.txt",
   "zh_TW",         "TestNames_Latin.txt TestNames_Chinese.txt",
   "zh__PINYIN",    "TestNames_Latin.txt TestNames_Chinese.txt",
   "ru_RU", 	    "TestNames_Latin.txt TestNames_Russian.txt",
   "th",            "TestNames_Latin.txt TestNames_Thai.txt",
   "ko_KR",         "TestNames_Latin.txt TestNames_Korean.txt",
   );


#
#  Outer loop runs through the locales to test
#     (Edit this list dirctly to make changes)
#
   foreach $locale (
	   "en_US",
	   "da_DK",
	   "de_DE",
	   "de__PHONEBOOK",
	   "fr_FR",
	   "ja_JP",
       "zh_CN",
	   "zh_TW",
	   "zh__PINYIN",
       "ko_KR",
	   "ru_RU",
	   "th",
                   )
       {
       #
       # Inner loop runs over the set of data files specified for each locale.
       #    (Edit the %datafiles initialization, above, to make changes.
       #
       $ff = $dataFiles{$locale};
       @ff = split(/[\s]+/, $ff);
       foreach $data (@ff) {

          #
          # Run ICU Test for this (locale, data file) pair.
          #
          $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`;
          $iStrCol =~s/[,\s]*//g;  # whack off the leading "  ," in the returned result.
          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",
                     $iKeyGen, $iKeyLen);


          #
          # Run Windows test for this (locale, data file) pair.  Only do if
          #    we are not on Windows 98/ME and we hava a windows langID
          #    for the locale.
          #
          $wStrCol = $wKeyGen = $wKeyLen = 0;
          $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`;
          $wStrCol =~s/[,\s]*//g;  # whack off the leading "  ," in the returned result.
          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",
                     $wKeyGen, $wKeyLen);
                     
          $collDiff = $keyGenDiff = $keyLenDiff = 0;
          if ($wKeyLen > 0) {
              $collDiff   = (($wStrCol - $iStrCol) / $iStrCol) * 100;
              $keyGenDiff = (($wKeyGen - $iKeyGen) / $iKeyGen) * 100;
              $keyLenDiff = (($wKeyLen - $iKeyLen) / $iKeyLen) * 100;
          }

         #
         #  Write the line of results for this (locale, data file).
         #
         write;
    }
 }

#
#  doKeyGenTimes($Command_to_run, $time, $key_length)
#       Do a key-generation test and return the time and key length/char values.
#
sub doKeyTimes($$$) {
   # print "$_[0]\n";
   local($x) = `$_[0]`;                  # execute the collperf command.
   ($_[1], $_[2]) = split(/\,/, $x);     # collperf returns "time, keylength" string.
}


#
#  Output Formats ...
#
#
format STDOUT_TOP =
                                      -------- ICU --------   ------ JAVA -------      (JAVA - ICU)/ICU
Locale     Data file                  strcoll keygen  keylen  strcoll keygen  keylen    coll  keygen  keylen
------------------------------------------------------------------------------------------------------------
.

format STDOUT =
@<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<| @######  @####   @#.##  |@##### @#####   @#.## | @###%  @###%   @###%
$locale, $data, $iStrCol, $iKeyGen, $iKeyLen, $wStrCol, $wKeyGen, $wKeyLen, $collDiff, $keyGenDiff, $keyLenDiff
.