8000 ICU-23061 Performance test for Lowercase transliterator; introduce JMH · unicode-org/icu@3463237 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3463237

Browse files
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
1 parent 12fea70 commit 3463237

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

icu4j/perf-tests/README.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ COLLATION TESTS
4343
The collation tests run only on the command line with tabular output:
4444
perl collationperf.pl |& tee collation_output.txt
4545

46+
JMH
47+
Some performance tests run using OpenJDK JMH. These may be launched with:
48+
java -jar perf-tests/target/jmh-benchmarks.jar
4649

4750
OTHER COMMAND LINE TESTS
4851
Additional tests are run from the command line, each producing an HTML

icu4j/perf-tests/pom.xml

Lines changed: 61 additions & 0 deletions
68
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
<properties>
1717
<module-name>perf_tests</module-name>
18+
<jmh.version>1.37</jmh.version>
1819
</properties>
1920

2021
<dependencies>
@@ -43,6 +44,66 @@
4344
<artifactId>commons-cli</artifactId>
4445
<version>${commons-cli.version}</version>
4546
</dependency>
47+
<dependency>
48+
<groupId>org.openjdk.jmh</groupId>
49+
<artifactId>jmh-core</artifactId>
50+
<version>${jmh.version}</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.openjdk.jmh</groupId>
54+
<artifactId>jmh-generator-annprocess</artifactId>
55+
<version>${jmh.version}</version>
56+
<scope>provided</scope>
57+
</dependency>
4658
</dependencies>
4759

60+
<build>
61+
<plugins>
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-compiler-plugin</artifactId>
65+
<configuration>
66+
<annotationProcessors>
67+
<annotationProcessor>org.openjdk.jmh.generators.BenchmarkProcessor</annotationProcessor>
+
</annotationProcessors>
69+
</configuration>
70+
</plugin>
71+
<plugin>
72+
<groupId>org.apache.maven.plugins</groupId>
73+
<artifactId>maven-shade-plugin</artifactId>
74+
<executions>
75+
<execution>
76+
<phase>package</phase>
77+
<goals>
78+
<goal>shade</goal>
79+
</goals>
80+
<configuration>
81+
<finalName>jmh-benchmarks</finalName>
82+
<transformers>
83+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
84+
<mainClass>org.openjdk.jmh.Main</mainClass>
85+
</transformer>
86+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
87+
</transformers>
88+
<filters>
89+
<filter>
90+
<!-- Shading signed JARs will fail without this.
91+
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
92+
-->
93+
<artifact>*:*</artifact>
94+
<excludes>
95+
<exclude>META-INF/*.SF</exclude>
96+
<exclude>META-INF/*.DSA</exclude>
97+
<exclude>META-INF/*.RSA</exclude>
98+
</excludes>
99+
</filter>
100+
</filters>
101+
</configuration>
102+
</execution>
103+
</executions>
104+
</plugin>
105+
</plugins>
106+
</build>
107+
108+
>>>>>>> 268eab27ea (ICU-23061 Performance test for Lowercase transliterator; introduce JMH)
48109
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// © 2016 and later: Unicode, Inc. and others.
2+
// License & terms of use: http://www.unicode.org/copyright.html
3+
/*
4+
**********************************************************************
5+
* Copyright (c) 2002-2008, International Business Machines *
6+
* Corporation and others. All Rights Reserved. *
7+
**********************************************************************
8+
*/
9+
package com.ibm.icu.dev.test.perf;
10+
11+
import java.util.concurrent.TimeUnit;
12+
13+
import com.ibm.icu.text.Transliterator;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Mode;
17+
import org.openjdk.jmh.annotations.OutputTimeUnit;
18+
19+
@BenchmarkMode(Mode.Throughput)
20+
@OutputTimeUnit(TimeUnit.MILLISECONDS)
21+
public class LowercaseTransliteratorPerf {
22+
23+
static final Transliterator LOWER = Transliterator.getInstance("Lower");
24+
25+
@Benchmark
26+
public String testShort() {
27+
return LOWER.transliterate("Cat");
28+
}
29+
30+
@Benchmark
31+
public String testSentence() {
32+
return LOWER.transliterate("The Quick Brown Fox Jumped Over The Lazy Dog");
33+
}
34+
35+
}

0 commit comments

Comments
 (0)
0