]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/perf/collationperf/CollPerf.pl
2 # ********************************************************************
4 # * Copyright (c) 2002-2008, International Business Machines Corporation and
5 # * others. All Rights Reserved.
6 # ********************************************************************
8 require "../perldriver/Common.pl";
10 use lib
'../perldriver';
14 $p = $ICUPathLatest . "/collationperf/$WindowsPlatform/Release/collationperf.exe";
17 $p = $ICUPathLatest . "/collationperf/collperf";
42 my $filePath = $CollationDataPath . "/";
43 my $filePrefix = "TestNames_";
45 $filePrefix."Latin.txt",
46 $filePrefix."Latin.txt",
47 $filePrefix."Latin.txt",
48 $filePrefix."Latin.txt",
49 $filePrefix."Latin.txt",
50 $filePrefix."Japanese_h.txt",
51 $filePrefix."Japanese_k.txt",
52 $filePrefix."Asian.txt",
53 $filePrefix."Latin.txt",
54 $filePrefix."Chinese.txt",
55 $filePrefix."Simplified_Chinese.txt",
56 $filePrefix."Latin.txt",
57 $filePrefix."Chinese.txt",
58 $filePrefix."Latin.txt",
59 $filePrefix."Korean.txt",
60 $filePrefix."Latin.txt",
61 $filePrefix."Russian.txt",
62 $filePrefix."Latin.txt",
63 $filePrefix."Thai.txt"
69 for ( $n = 0 ; $n < @data ; $n++ ) {
72 $resultICU = @locale[$n].",".@data[$n].",";
73 $resultNIX = @locale[$n].",".@data[$n].",";
74 @resultFIN[$n] = @locale[$n].",".@data[$n].",";
77 my @icu = `$p -locale @locale[$n] -loop 1000 -file $filePath@data[$n] -qsort`;
78 my @nix = `$p -locale @locale[$n] -unix -loop 1000 -file $filePath@data[$n] -qsort`;
80 my @icua = split( ' = ', $icu[2] );
81 my @icub = split( ' ', $icua[1] );
82 my @nixa = split( ' = ', $nix[2] );
83 my @nixb = split( ' ', $nixa[1] );
85 $resultICU = $resultICU.$icub[0].",";
86 $resultNIX = $resultNIX.$nixb[0].",";
89 @icu = `$p -locale @locale[$n] -loop 1000 -file $filePath@data[$n] -keygen`;
90 @nix = `$p -locale @locale[$n] -unix -loop 1000 -file $filePath@data[$n] -keygen`;
92 @icua = split( ' = ', $icu[2] );
93 @icub = split( ' ', $icua[1] );
94 @nixa = split( ' = ', $nix[2] );
95 @nixb = split( ' ', $nixa[1] );
97 $resultICU = $resultICU.$icub[0].",";
98 $resultNIX = $resultNIX.$nixb[0].",";
101 @icua = split( ' = ', $icu[3] );
102 @nixa = split( ' = ', $nix[3] );
107 $resultICU = $resultICU.$icua[1].",";
108 $resultNIX = $resultNIX.$nixa[1].",";
114 for ( $i = 0 ; $i < 3 ; $i++ ) {
116 @resultSplitICU = split( ',', $resultICU );
117 @resultSplitNIX = split( ',', $resultNIX );
118 if ( @resultSplitICU[ 2 + $i ] > 0 ) {
119 $percent = substr((((
120 @resultSplitNIX[ 2 + $i ] - @resultSplitICU[ 2 + $i ]) / @resultSplitICU[ 2 + $i ]) * 100),
123 @resultPER[$n] = @resultPER[$n].$percent."%,";
127 for ( $j = 0 ; $j < 3 ; $j++ ) {
128 @resultFIN[$n] = @resultFIN[$n].@resultSplitICU[ 2 + $j ].",";
132 for ( $j = 0 ; $j < 3 ; $j++ ) {
133 @resultFIN[$n] = @resultFIN[$n].@resultSplitNIX[ 2 + $j ].",";
136 #store Percent result
137 @resultFIN[$n] = @resultFIN[$n].@resultPER[$n];
140 # Print the results in a HTML page
145 # This subroutine creates the web page and prints out the results in a table
147 my $title = "Collation: ICU " . $ICULatestVersion . " vs GLIBC";
148 my $html = localtime;
149 $html =~ s/://g; # ':' illegal
150 $html =~ s/\s*\d+$//; # delete year
151 $html =~ s/^\w+\s*//; # delete dow
152 $html = "CollationPerformance $html.html";
153 $html = "../results/" . $html;
155 open( HTML
, ">$html" ) or die "Can't write to $html: $!";
157 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
158 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
159 <html xmlns="http://www.w3.org/1999/xhtml">
161 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
162 <title>Collation: ICU4C vs. glibc</title>
163 <link rel="stylesheet" href="../icu.css" type="text/css" />
166 <!--#include virtual="../ssi/header.html" -->
169 print HTML
"<h2>Collation: ICU4C ".$ICULatestVersion." vs. GLIBC</h2>\n";
172 <p>The performance test takes a locale and creates a RuleBasedCollator with
173 default options. A large list of names is used as data in each test, where the
174 names vary according to language. Each Collation operation over the whole list
175 is repeated 1000 times. The percentage values in the final column are the most
176 useful. They measure differences, where positive is better for ICU4C, and
177 negative is better for the compared implementation.</p>
179 <table border="1" cellspacing="0" cellpadding="4">
181 <th align="left">Operation</th>
182 <th align="left">Units</th>
183 <th align="left">Description</th>
188 <td>Timing for string collation, an incremental compare of strings.</td>
193 <td>Timing for generation of sort keys, used to 'precompile' information so
194 that subsequent operations can use binary comparison.</td>
199 <td>The average length of the generated sort keys, in bytes per character
200 (Unicode/ISO 10646 code point). Generally this is the important field for sort
201 key performance, since it directly impacts the time necessary for binary
202 comparison, and the overhead of memory usage and retrieval time for sort
210 <h3><i>Notes</i></h3>
212 <li>As with all performance measurements, the results will vary according to
213 the hardware and compiler. The strcoll operation is particularly sensitive; we
214 have found that even slight changes in code alignment can produce 10%
216 <li>For more information on incremental vs. sort key comparison, the importance
217 of multi-level sorting, and other features of collation, see <a href=
218 "http://www.unicode.org/reports/tr10/">Unicode Collation (UCA)</a>.</li>
219 <li>For general information on ICU collation see <a href=
220 "/userguide/Collate_Intro.html">User Guide</a>.</li>
221 <li>For information on APIs, see <a href="/apiref/icu4c/ucol_8h.html">C</a>,
222 <a href="/apiref/icu4c/classCollator.html">C++</a>, or <a href=
223 "/apiref/icu4j/com/ibm/icu/text/Collator.html">Java</a>.</li>
225 <!--#include virtual="../ssi/footer.html" -->
231 close(HTML
) or die "Can't close $html: $!";
234 # This subroutine formats and prints the table.
238 <table border="1" cellspacing="0" cellpadding="4">
240 <td align="left"><b>Locale</b></td>
241 <td align="left"><b>Data file</b></td>
242 <td align="left"><b>strcoll</b> <i>(ICU)</i></td>
243 <td align="left"><b>keygen</b> <i>(ICU)</i></td>
244 <td align="left"><b>keylen</b> <i>(ICU)</i></td>
245 <td align="left"><b>strcoll</b> <i>(GLIBC)</i></td>
246 <td align="left"><b>keygen</b> <i>(GLIBC)</i></td>
247 <td align="left"><b>keylen</b> <i>(GLIBC)</i></td>
248 <td align="left"><b>strcoll</b> <i>(GLIBC-ICU)/ICU)</i></td>
249 <td align="left"><b>keygen</b> <i>(GLIBC-ICU)/ICU)</i></td>
250 <td align="left"><b>keylen</b> <i>(GLIBC-ICU)/ICU)</i></td>
254 for ( $n = 0 ; $n < @resultFIN ; $n++ ) {
256 my @parsed = split( ',', @resultFIN[$n] );
257 for ( $i = 0 ; $i < @parsed ; $i++ ) {
258 my $value = @parsed[$i];
259 print HTML
"<td align=\"center\">";
261 if ( $value =~ m/^[-]/ ) {
262 print HTML
"<font color=\"red\">$value</font>";
271 print HTML
"</tr>\n";