1 #/** 2 # ******************************************************************************* 3 # * Copyright (C) 2002-2014, 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 "run perl collationperf.pl\n"; 20 print "Running performance tests...\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 if ($^O eq "MSWin32") { 41 $classPath = "out\\lib\\icu4j-perf-tests.jar;..\\icu4j.jar"; 42 } else { 43 $classPath = "out/lib/icu4j-perf-tests.jar:../icu4j.jar"; 44 } 45 46 # 47 # Outer loop runs through the locales to test 48 # (Edit this list dirctly to make changes) 49 # 50 foreach $locale ( 51 "en_US", 52 "da_DK", 53 "de_DE", 54 "de__PHONEBOOK", 55 "fr_FR", 56 "ja_JP", 57 "zh_CN", 58 "zh_TW", 59 "zh__PINYIN", 60 "ko_KR", 61 "ru_RU", 62 "th", 63 ) 64 { 65 # 66 # Inner loop runs over the set of data files specified for each locale. 67 # (Edit the %datafiles initialization, above, to make changes. 68 # 69 $ff = $dataFiles{$locale}; 70 @ff = split(/[\s]+/, $ff); 71 foreach $data (@ff) { 72 73 # 74 # Run ICU Test for this (locale, data file) pair. 75 # 76 $iStrCol = `java -classpath $classPath com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -binsearch`; 77 $iStrCol =~s/[,\s]*//g; # whack off the leading " ," in the returned result. 78 doKeyTimes("java -classpath $classPath com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -keygen", 79 $iKeyGen, $iKeyLen); 80 81 82 # 83 # Run Windows test for this (locale, data file) pair. Only do if 84 # we are not on Windows 98/ME and we hava a windows langID 85 # for the locale. 86 # 87 $wStrCol = $wKeyGen = $wKeyLen = 0; 88 $wStrCol = `java -classpath $classPath com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -binsearch -java`; 89 $wStrCol =~s/[,\s]*//g; # whack off the leading " ," in the returned result. 90 doKeyTimes("java -classpath $classPath com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -keygen -java", 91 $wKeyGen, $wKeyLen); 92 93 $collDiff = $keyGenDiff = $keyLenDiff = 0; 94 if ($wKeyLen > 0) { 95 $collDiff = (($wStrCol - $iStrCol) / $iStrCol) * 100; 96 $keyGenDiff = (($wKeyGen - $iKeyGen) / $iKeyGen) * 100; 97 $keyLenDiff = (($wKeyLen - $iKeyLen) / $iKeyLen) * 100; 98 } 99 100 # 101 # Write the line of results for this (locale, data file). 102 # 103 write; 104 } 105 } 106 107 # 108 # doKeyGenTimes($Command_to_run, $time, $key_length) 109 # Do a key-generation test and return the time and key length/char values. 110 # 111 sub doKeyTimes($$$) { 112 # print "$_[0]\n"; 113 local($x) = `$_[0]`; # execute the collperf command. 114 ($_[1], $_[2]) = split(/\,/, $x); # collperf returns "time, keylength" string. 115 } 116 117 118 # 119 # Output Formats ... 120 # 121 # 122 format STDOUT_TOP = 123 -------- ICU -------- ------ JAVA ------- (JAVA - ICU)/ICU 124 Locale Data file strcoll keygen keylen strcoll keygen keylen coll keygen keylen 125 ------------------------------------------------------------------------------------------------------------ 126 . 127 128 format STDOUT = 129 @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<| @###### @#### @#.## |@##### @##### @#.## | @###% @###% @###% 130 $locale, $data, $iStrCol, $iKeyGen, $iKeyLen, $wStrCol, $wKeyGen, $wKeyLen, $collDiff, $keyGenDiff, $keyLenDiff 131 . 132