Skip to content

Commit

Permalink
ICU-21757 Replace UOption with commons-cli in perf-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mihnita committed May 3, 2024
1 parent 1c7d7f9 commit 69cb085
Show file tree
Hide file tree
Showing 14 changed files with 391 additions and 312 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/icu_merge_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ jobs:
git status
cd perf-tests;
mkdir -p perf/results/j_unicodesetperf/${{ matrix.perf }};
java -cp ./target/*:../tools/misc/target/*:../main/core/target/* com.ibm.icu.dev.test.perf.UnicodeSetPerf ${{ matrix.perf }} -a -t 2 -p 4 [:Lt:] | tee perf/results/j_unicodesetperf/${{ matrix.perf }}/output.txt
java -cp ./target/*:./target/dependency/* com.ibm.icu.dev.test.perf.UnicodeSetPerf ${{ matrix.perf }} -a -t 2 -p 4 [:Lt:] | tee perf/results/j_unicodesetperf/${{ matrix.perf }}/output.txt
- name: Store performance test results
uses: gregtatum/github-action-benchmark@d3f06f738e9612988d575db23fae5ca0008d3d12
Expand Down Expand Up @@ -413,7 +413,7 @@ jobs:
mvn ${SHARED_MVN_ARGS} verify -DskipITs -DskipTests;
cd perf-tests;
mkdir -p perf/results/j_ucharacterperf;
java -cp ./target/*:../tools/misc/target/*:../main/core/target/* com.ibm.icu.dev.test.perf.UCharacterPerf -a -t 2 -p 4 0 ffff | tee perf/results/j_ucharacterperf/output.txt
java -cp ./target/*:./target/dependency/* com.ibm.icu.dev.test.perf.UCharacterPerf -a -t 2 -p 4 0 ffff | tee perf/results/j_ucharacterperf/output.txt
- name: Store performance test results
uses: gregtatum/github-action-benchmark@d3f06f738e9612988d575db23fae5ca0008d3d12
Expand Down Expand Up @@ -481,7 +481,7 @@ jobs:
# tests over 180 secs. minimizes the possibility of push conflicts when storing
# tests results in the data branch.
sleep $(($RANDOM % 180));
java -cp ./target/*:../tools/misc/target/*:../main/core/target/* com.ibm.icu.dev.test.perf.DecimalFormatPerformanceTest ${{ matrix.perf }} -a -t 2 -p 4 -L ${{ matrix.locale }} "#,###.##" "1.234,56" -r 1 | tee perf/results/j_decimalformatperf/${{ matrix.locale }}/${{ matrix.perf }}/output.txt
java -cp ./target/*:./target/dependency/* com.ibm.icu.dev.test.perf.DecimalFormatPerformanceTest ${{ matrix.perf }} -a -t 2 -p 4 -L ${{ matrix.locale }} "#,###.##" "1.234,56" -r 1 | tee perf/results/j_decimalformatperf/${{ matrix.locale }}/${{ matrix.perf }}/output.txt
- name: Store performance test results
uses: gregtatum/github-action-benchmark@d3f06f738e9612988d575db23fae5ca0008d3d12
Expand Down Expand Up @@ -552,7 +552,7 @@ jobs:
# tests over 180 secs. minimizes the possibility of push conflicts when storing
# tests results in the data branch.
sleep $(($RANDOM % 180));
java -cp ./target/*:../tools/misc/target/*:../main/core/target/* com.ibm.icu.dev.test.perf.NormalizerPerformanceTest ${{ matrix.perf }} -a -t 2 -p 4 -f $DATA_FILE_PATH/${{ matrix.source_text }}.txt -e UTF-8 ${{ matrix.mode }} | tee perf/results/j_normperf/${{ matrix.source_text }}/${{ matrix.perf }}/output.txt
java -cp ./target/*:./target/dependency/* com.ibm.icu.dev.test.perf.NormalizerPerformanceTest ${{ matrix.perf }} -a -t 2 -p 4 -f $DATA_FILE_PATH/${{ matrix.source_text }}.txt -e UTF-8 ${{ matrix.mode }} | tee perf/results/j_normperf/${{ matrix.source_text }}/${{ matrix.perf }}/output.txt
cat perf/results/j_normperf/${{ matrix.source_text }}/${{ matrix.perf }}/output.txt
- name: Store performance test results
Expand Down Expand Up @@ -691,7 +691,7 @@ jobs:
# tests over 180 secs. minimizes the possibility of push conflicts when storing
# tests results in the data branch.
sleep $(($RANDOM % 180));
java -cp ./target/*:../tools/misc/target/*:../main/core/target/*:../main/charset/target/* com.ibm.icu.dev.test.perf.ConverterPerformanceTest ${{ matrix.perf }} -a -t 2 -p 4 -f $DATA_FILE_PATH/${{ matrix.source_text }}.txt -e UTF-8 -T ${{ matrix.test_enc }} | tee perf/results/j_converterperf/${{ matrix.source_text }}/${{ matrix.test_enc }}/${{ matrix.perf }}/output.txt
java -cp ./target/*:./target/dependency/*:../main/charset/target/* com.ibm.icu.dev.test.perf.ConverterPerformanceTest ${{ matrix.perf }} -a -t 2 -p 4 -f $DATA_FILE_PATH/${{ matrix.source_text }}.txt -e UTF-8 -T ${{ matrix.test_enc }} | tee perf/results/j_converterperf/${{ matrix.source_text }}/${{ matrix.test_enc }}/${{ matrix.perf }}/output.txt
- name: Store performance test results
uses: gregtatum/github-action-benchmark@d3f06f738e9612988d575db23fae5ca0008d3d12
Expand Down Expand Up @@ -777,7 +777,7 @@ jobs:
# tests over 180 secs. minimizes the possibility of push conflicts when storing
# tests results in the data branch.
sleep $(($RANDOM % 180));
java -cp ./target/*:../tools/misc/target/*:../main/core/target/* com.ibm.icu.dev.test.perf.DateFormatPerformanceTest ${{ matrix.perf }} -a -t 2 -p 4 -L ${{ matrix.locale }} ${{ env.PARM }} -r 1 | tee perf/results/j_dateformatperf/${{ matrix.locale }}/${{ matrix.perf }}/${{ env.DDIR }}/output.txt
java -cp ./target/*:./target/dependency/* com.ibm.icu.dev.test.perf.DateFormatPerformanceTest ${{ matrix.perf }} -a -t 2 -p 4 -L ${{ matrix.locale }} ${{ env.PARM }} -r 1 | tee perf/results/j_dateformatperf/${{ matrix.locale }}/${{ matrix.perf }}/${{ env.DDIR }}/output.txt
- name: Store performance test results
uses: gregtatum/github-action-benchmark@d3f06f738e9612988d575db23fae5ca0008d3d12
Expand Down
2 changes: 2 additions & 0 deletions icu4j/perf-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Wildcards
perf *.html
9 changes: 6 additions & 3 deletions icu4j/perf-tests/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ but require reworking to locate, compile, and run different versions.

Note: To run the performance test for ICU4J as a part of continuous build, you will
need to set up Perl with the following modules:
a) Statistics/Distribution.pm
a) Statistics/Distributions.pm
b) Statistics/Descriptive.pm
c) XML/LibXML.pm

CONTINUOUS BUILD:
To run a set of performance tests defined in file perlftests.pl, use this command:
ant continuous-build
To run a set of performance tests defined in file perlftests.pl, use these commands:
cd <icu_root>/icu4j
mvn install -DskipTests -DskipITs
cd perf-tests
... run tests from here ...

Output is created in perf.xml. This output contains results comparing ICU and JDK for the
following operations
Expand Down
40 changes: 0 additions & 40 deletions icu4j/perf-tests/build.xml

This file was deleted.

15 changes: 9 additions & 6 deletions icu4j/perf-tests/collationperf.pl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env perl
#/**
# * © 2016 and later: Unicode, Inc. and others.
# * License & terms of use: http:https://www.unicode.org/copyright.html
Expand Down Expand Up @@ -39,10 +40,12 @@
"ko_KR", "TestNames_Latin.txt TestNames_Korean.txt",
);

my $OS=$^O;
my $CLASSPATH;
if ($^O eq "MSWin32") {
$classPath = "out\\lib\\icu4j-perf-tests.jar;..\\icu4j.jar";
$CLASSPATH = './target/*;./target/dependency/*';
} else {
$classPath = "out/lib/icu4j-perf-tests.jar:../icu4j.jar";
$CLASSPATH = './target/*:./target/dependency/*';
}

#
Expand Down Expand Up @@ -75,9 +78,9 @@
#
# Run ICU Test for this (locale, data file) pair.
#
$iStrCol = `java -classpath $classPath com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -binsearch`;
$iStrCol = `java -classpath $CLASSPATH com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -binsearch`;
$iStrCol =~s/[,\s]*//g; # whack off the leading " ," in the returned result.
doKeyTimes("java -classpath $classPath com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -keygen",
doKeyTimes("java -classpath $CLASSPATH com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -keygen",
$iKeyGen, $iKeyLen);


Expand All @@ -87,9 +90,9 @@
# for the locale.
#
$wStrCol = $wKeyGen = $wKeyLen = 0;
$wStrCol = `java -classpath $classPath com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -binsearch -java`;
$wStrCol = `java -classpath $CLASSPATH com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -binsearch -java`;
$wStrCol =~s/[,\s]*//g; # whack off the leading " ," in the returned result.
doKeyTimes("java -classpath $classPath com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -keygen -java",
doKeyTimes("java -classpath $CLASSPATH com.ibm.icu.dev.test.perf.CollationPerformanceTest -terse -file data/collation/$data -locale $locale -loop 1000 -keygen -java",
$wKeyGen, $wKeyLen);

$collDiff = $keyGenDiff = $keyLenDiff = 0;
Expand Down
12 changes: 9 additions & 3 deletions icu4j/perf-tests/converterperf.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/perl
#!/usr/bin/env perl
# * © 2016 and later: Unicode, Inc. and others.
# * License & terms of use: http:https://www.unicode.org/copyright.html
# *******************************************************************************
Expand All @@ -16,7 +16,13 @@
# Test class
my $TESTCLASS = 'com.ibm.icu.dev.test.perf.ConverterPerformanceTest';

my $CLASSES = './out/bin:../tools/misc/out/bin/:../icu4j.jar:../icu4j-charset.jar';
my $OS=$^O;
my $CLASSPATH;
if ($^O eq "MSWin32") {
$CLASSPATH = './target/*;./target/dependency/*';
} else {
$CLASSPATH = './target/*:./target/dependency/*';
}

# Methods to be tested. Each pair represents a test method and
# a baseline method which is used for comparison.
Expand Down Expand Up @@ -301,7 +307,7 @@ sub callJava {
my $fileName = $SOURCEDIR.@$pat[0] ;
my $n = ($n < 0) ? "-t ".(-$n) : "-i ".$n;

my $cmd = "java -classpath $CLASSES $TESTCLASS $method $n -p $passes -f $fileName -e @$pat[1] -T @$pat[2]";
my $cmd = "java -classpath $CLASSPATH $TESTCLASS $method $n -p $passes -f $fileName -e @$pat[1] -T @$pat[2]";
print "[$cmd]\n"; # for debugging
open(PIPE, "$cmd|") or die "Can't run \"$cmd\"";
my @out;
Expand Down
12 changes: 9 additions & 3 deletions icu4j/perf-tests/dateformatperf.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/perl
#!/usr/bin/env perl
# * © 2016 and later: Unicode, Inc. and others.
# * License & terms of use: http:https://www.unicode.org/copyright.html
# *******************************************************************************
Expand All @@ -16,7 +16,13 @@
# Test class
my $TESTCLASS = 'com.ibm.icu.dev.test.perf.DateFormatPerformanceTest';

my $CLASSES = './out/bin:../tools/misc/out/bin/:../icu4j.jar';
my $OS=$^O;
my $CLASSPATH;
if ($^O eq "MSWin32") {
$CLASSPATH = './target/*;./target/dependency/*';
} else {
$CLASSPATH = './target/*:./target/dependency/*';
}

# Methods to be tested. Each pair represents a test method and
# a baseline method which is used for comparison.
Expand Down Expand Up @@ -283,7 +289,7 @@ sub callJava {

my $n = ($n < 0) ? "-t ".(-$n) : "-i ".$n;

my $cmd = "java -classpath $CLASSES $TESTCLASS $method $n -p $passes -L @$pat[0] \"@$pat[1]\" \"@$pat[2]\" -r $THREADS";
my $cmd = "java -classpath $CLASSPATH $TESTCLASS $method $n -p $passes -L @$pat[0] \"@$pat[1]\" \"@$pat[2]\" -r $THREADS";
print "[$cmd]\n"; # for debugging
open(PIPE, "$cmd|") or die "Can't run \"$cmd\"";
my @out;
Expand Down
12 changes: 9 additions & 3 deletions icu4j/perf-tests/decimalformatperf.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/perl
#!/usr/bin/env perl
# * © 2016 and later: Unicode, Inc. and others.
# * License & terms of use: http:https://www.unicode.org/copyright.html
# *******************************************************************************
Expand All @@ -16,7 +16,13 @@
# Test class
my $TESTCLASS = 'com.ibm.icu.dev.test.perf.DecimalFormatPerformanceTest';

my $CLASSES = './out/bin:../tools/misc/out/bin/:../icu4j.jar';
my $OS=$^O;
my $CLASSPATH;
if ($^O eq "MSWin32") {
$CLASSPATH = './target/*;./target/dependency/*';
} else {
$CLASSPATH = './target/*:./target/dependency/*';
}

# Methods to be tested. Each pair represents a test method and
# a baseline method which is used for comparison.
Expand Down Expand Up @@ -278,7 +284,7 @@ sub callJava {

my $n = ($n < 0) ? "-t ".(-$n) : "-i ".$n;

my $cmd = "java -classpath $CLASSES $TESTCLASS $method $n -p $passes -L @$pat[0] \"@$pat[1]\" \"@$pat[2]\" -r $THREADS";
my $cmd = "java -classpath $CLASSPATH $TESTCLASS $method $n -p $passes -L @$pat[0] \"@$pat[1]\" \"@$pat[2]\" -r $THREADS";
print "[$cmd]\n"; # for debugging
open(PIPE, "$cmd|") or die "Can't run \"$cmd\"";
my @out;
Expand Down
12 changes: 9 additions & 3 deletions icu4j/perf-tests/normperf.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/perl
#!/usr/bin/env perl
# * © 2016 and later: Unicode, Inc. and others.
# * License & terms of use: http:https://www.unicode.org/copyright.html
# *******************************************************************************
Expand All @@ -16,7 +16,13 @@
# Test class
my $TESTCLASS = 'com.ibm.icu.dev.test.perf.NormalizerPerformanceTest';

my $CLASSES = './out/bin:../tools/misc/out/bin/:../icu4j.jar';
my $OS=$^O;
my $CLASSPATH;
if ($^O eq "MSWin32") {
$CLASSPATH = './target/*;./target/dependency/*';
} else {
$CLASSPATH = './target/*:./target/dependency/*';
}

# Methods to be tested. Each pair represents a test method and
# a baseline method which is used for comparison.
Expand Down Expand Up @@ -333,7 +339,7 @@ sub callJava {
my $fileName = $SOURCEDIR . @$pat[0] ;
my $n = ($n < 0) ? "-t ".(-$n) : "-i ".$n;

my $cmd = "java -classpath $CLASSES $TESTCLASS $method $n -p $passes -f $fileName -e @$pat[1] -@$pat[2]";
my $cmd = "java -classpath $CLASSPATH $TESTCLASS $method $n -p $passes -f $fileName -e @$pat[1] -@$pat[2]";
print "[$cmd]\n"; # for debugging
open(PIPE, "$cmd|") or die "Can't run \"$cmd\"";
my @out;
Expand Down
11 changes: 6 additions & 5 deletions icu4j/perf-tests/perftests.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/perl
#!/usr/bin/env perl
# * © 2016 and later: Unicode, Inc. and others.
# * License & terms of use: http:https://www.unicode.org/copyright.html
# *******************************************************************************
Expand All @@ -11,14 +11,15 @@
# Assume we are running within the icu4j root directory
use lib '.';
use Dataset;
my $OS=$^O;

my $OS=$^O;
my $CLASSPATH;
if ($OS eq "linux" || $OS eq "darwin") {
$CLASSPATH="../icu4j.jar:../tools/misc/out/lib/icu4j-tools.jar:out/bin";
if ($^O eq "MSWin32") {
$CLASSPATH = './target/*;./target/dependency/*';
} else {
$CLASSPATH="../icu4j.jar;../tools/misc/out/lib/icu4j-tools.jar;out/bin";
$CLASSPATH = './target/*:./target/dependency/*';
}

#---------------------------------------------------------------------

# Methods to be tested. Each pair represents a test method and
Expand Down
21 changes: 21 additions & 0 deletions icu4j/perf-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,31 @@
<artifactId>tools_misc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<!-- Copy dependencies by default, so that everythign is easier to run
without having to explicitly list all kind of folders in classpath.
Just use `./target/*` and `./target/dependency/*`
-->
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<!-- We don't want to deploy this to Maven -->
Expand Down

0 comments on commit 69cb085

Please sign in to comment.