mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-05 21:45:37 +00:00
ICU-23061 Performance test for Lowercase transliterator; introduce JMH
JMH is the OpenJDK microbenchmark harness. It is a standardized tool with many integrations and provides a lot of out-of-the-box functionality. No existing perf-tests are changed https://github.com/openjdk/jmh
This commit is contained in:
parent
12fea708b7
commit
94ec9ffea8
3 changed files with 97 additions and 0 deletions
|
@ -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