diff --git a/icu4j/perf-tests/README.txt b/icu4j/perf-tests/README.txt index d26f3fdafa54..7e96f9f87e3c 100644 --- a/icu4j/perf-tests/README.txt +++ b/icu4j/perf-tests/README.txt @@ -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 diff --git a/icu4j/perf-tests/pom.xml b/icu4j/perf-tests/pom.xml index f47e93729c2b..462144645404 100644 --- a/icu4j/perf-tests/pom.xml +++ b/icu4j/perf-tests/pom.xml @@ -15,6 +15,7 @@ perf_tests + 1.37 @@ -43,12 +44,23 @@ commons-cli ${commons-cli.version} + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + provided + - @@ -63,6 +75,49 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + + org.openjdk.jmh.generators.BenchmarkProcessor + + + + + org.apache.maven.plugins + maven-shade-plugin + + + package + + shade + + + jmh-benchmarks + + + org.openjdk.jmh.Main + + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + diff --git a/icu4j/perf-tests/src/main/java/com/ibm/icu/dev/test/perf/LowercaseTransliteratorPerf.java b/icu4j/perf-tests/src/main/java/com/ibm/icu/dev/test/perf/LowercaseTransliteratorPerf.java new file mode 100644 index 000000000000..12a7f40c0a73 --- /dev/null +++ b/icu4j/perf-tests/src/main/java/com/ibm/icu/dev/test/perf/LowercaseTransliteratorPerf.java @@ -0,0 +1,27 @@ +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"); + } + +}