mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 15:42:14 +00:00
Merge 94ec9ffea8
into 770c4b8042
This commit is contained in:
commit
dc39348252
4 changed files with 101 additions and 6 deletions
icu4j
main/translit/src/main/java/com/ibm/icu/text
perf-tests
|
@ -42,8 +42,6 @@ class LowercaseTransliterator extends Transliterator{
|
|||
private final ULocale locale;
|
||||
|
||||
private final UCaseProps csp;
|
||||
private ReplaceableContextIterator iter;
|
||||
private StringBuilder result;
|
||||
private int caseLocale;
|
||||
|
||||
/**
|
||||
|
@ -54,8 +52,6 @@ class LowercaseTransliterator extends Transliterator{
|
|||
super(_ID, null);
|
||||
locale = loc;
|
||||
csp=UCaseProps.INSTANCE;
|
||||
iter=new ReplaceableContextIterator();
|
||||
result = new StringBuilder();
|
||||
caseLocale = UCaseProps.getCaseLocale(locale);
|
||||
}
|
||||
|
||||
|
@ -63,7 +59,7 @@ class LowercaseTransliterator extends Transliterator{
|
|||
* Implements {@link Transliterator#handleTransliterate}.
|
||||
*/
|
||||
@Override
|
||||
protected synchronized void handleTransliterate(Replaceable text,
|
||||
protected void handleTransliterate(Replaceable text,
|
||||
Position offsets, boolean isIncremental) {
|
||||
if(csp==null) {
|
||||
return;
|
||||
|
@ -73,8 +69,10 @@ class LowercaseTransliterator extends Transliterator{
|
|||
return;
|
||||
}
|
||||
|
||||
ReplaceableContextIterator iter = new ReplaceableContextIterator();
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
iter.setText(text);
|
||||
result.setLength(0);
|
||||
int c, delta;
|
||||
|
||||
// Walk through original string
|
||||
|
|
|
@ -43,6 +43,9 @@ COLLATION TESTS
|
|||
The collation tests run only on the command line with tabular output:
|
||||
perl collationperf.pl |& tee collation_output.txt
|
||||
|
||||
JMH
|
||||
Some performance tests run using OpenJDK JMH. These may be launched with:
|
||||
java -jar perf-tests/target/jmh-benchmarks.jar
|
||||
|
||||
OTHER COMMAND LINE TESTS
|
||||
Additional tests are run from the command line, each producing an HTML
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
<properties>
|
||||
<module-name>perf_tests</module-name>
|
||||
<jmh.version>1.37</jmh.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -43,6 +44,64 @@
|
|||
<artifactId>commons-cli</artifactId>
|
||||
<version>${commons-cli.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>${jmh.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>${jmh.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessors>
|
||||
<annotationProcessor>org.openjdk.jmh.generators.BenchmarkProcessor</annotationProcessor>
|
||||
</annotationProcessors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<finalName>jmh-benchmarks</finalName>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>org.openjdk.jmh.Main</mainClass>
|
||||
</transformer>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
<!-- Shading signed JARs will fail without this.
|
||||
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
|
||||
-->
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// © 2016 and later: Unicode, Inc. and others.
|
||||
// License & terms of use: http://www.unicode.org/copyright.html
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2002-2008, International Business Machines *
|
||||
* Corporation and others. All Rights Reserved. *
|
||||
**********************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.perf;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||
import org.openjdk.jmh.annotations.Mode;
|
||||
import org.openjdk.jmh.annotations.OutputTimeUnit;
|
||||
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
public class LowercaseTransliteratorPerf {
|
||||
|
||||
static final Transliterator LOWER = Transliterator.getInstance("Lower");
|
||||
|
||||
@Benchmark
|
||||
public String testShort() {
|
||||
return LOWER.transliterate("Cat");
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public String testSentence() {
|
||||
return LOWER.transliterate("The Quick Brown Fox Jumped Over The Lazy Dog");
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue