ICU-21051 Add Locale::createCanonical performance test
This commit is contained in:
parent
0101e2632c
commit
cad3903cc2
3
icu4c/source/configure
vendored
3
icu4c/source/configure
vendored
@ -7999,7 +7999,7 @@ echo "CXXFLAGS=$CXXFLAGS"
|
||||
|
||||
|
||||
# output the Makefiles
|
||||
ac_config_files="$ac_config_files icudefs.mk Makefile data/pkgdataMakefile config/Makefile.inc config/icu.pc config/pkgdataMakefile data/Makefile stubdata/Makefile common/Makefile i18n/Makefile layoutex/Makefile io/Makefile extra/Makefile extra/uconv/Makefile extra/uconv/pkgdataMakefile extra/scrptrun/Makefile tools/Makefile tools/ctestfw/Makefile tools/toolutil/Makefile tools/makeconv/Makefile tools/genrb/Makefile tools/genccode/Makefile tools/gencmn/Makefile tools/gencnval/Makefile tools/gendict/Makefile tools/gentest/Makefile tools/gennorm2/Makefile tools/genbrk/Makefile tools/gensprep/Makefile tools/icuinfo/Makefile tools/icupkg/Makefile tools/icuswap/Makefile tools/pkgdata/Makefile tools/tzcode/Makefile tools/gencfu/Makefile tools/escapesrc/Makefile test/Makefile test/compat/Makefile test/testdata/Makefile test/testdata/pkgdataMakefile test/hdrtst/Makefile test/intltest/Makefile test/cintltst/Makefile test/iotest/Makefile test/letest/Makefile test/perf/Makefile test/perf/collationperf/Makefile test/perf/collperf/Makefile test/perf/collperf2/Makefile test/perf/dicttrieperf/Makefile test/perf/ubrkperf/Makefile test/perf/charperf/Makefile test/perf/convperf/Makefile test/perf/normperf/Makefile test/perf/DateFmtPerf/Makefile test/perf/howExpensiveIs/Makefile test/perf/strsrchperf/Makefile test/perf/unisetperf/Makefile test/perf/usetperf/Makefile test/perf/ustrperf/Makefile test/perf/utfperf/Makefile test/perf/utrie2perf/Makefile test/perf/leperf/Makefile test/fuzzer/Makefile samples/Makefile samples/date/Makefile samples/cal/Makefile samples/layout/Makefile"
|
||||
ac_config_files="$ac_config_files icudefs.mk Makefile data/pkgdataMakefile config/Makefile.inc config/icu.pc config/pkgdataMakefile data/Makefile stubdata/Makefile common/Makefile i18n/Makefile layoutex/Makefile io/Makefile extra/Makefile extra/uconv/Makefile extra/uconv/pkgdataMakefile extra/scrptrun/Makefile tools/Makefile tools/ctestfw/Makefile tools/toolutil/Makefile tools/makeconv/Makefile tools/genrb/Makefile tools/genccode/Makefile tools/gencmn/Makefile tools/gencnval/Makefile tools/gendict/Makefile tools/gentest/Makefile tools/gennorm2/Makefile tools/genbrk/Makefile tools/gensprep/Makefile tools/icuinfo/Makefile tools/icupkg/Makefile tools/icuswap/Makefile tools/pkgdata/Makefile tools/tzcode/Makefile tools/gencfu/Makefile tools/escapesrc/Makefile test/Makefile test/compat/Makefile test/testdata/Makefile test/testdata/pkgdataMakefile test/hdrtst/Makefile test/intltest/Makefile test/cintltst/Makefile test/iotest/Makefile test/letest/Makefile test/perf/Makefile test/perf/collationperf/Makefile test/perf/collperf/Makefile test/perf/collperf2/Makefile test/perf/dicttrieperf/Makefile test/perf/ubrkperf/Makefile test/perf/charperf/Makefile test/perf/convperf/Makefile test/perf/localecanperf/Makefile test/perf/normperf/Makefile test/perf/DateFmtPerf/Makefile test/perf/howExpensiveIs/Makefile test/perf/strsrchperf/Makefile test/perf/unisetperf/Makefile test/perf/usetperf/Makefile test/perf/ustrperf/Makefile test/perf/utfperf/Makefile test/perf/utrie2perf/Makefile test/perf/leperf/Makefile test/fuzzer/Makefile samples/Makefile samples/date/Makefile samples/cal/Makefile samples/layout/Makefile"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
@ -8762,6 +8762,7 @@ do
|
||||
"test/perf/ubrkperf/Makefile") CONFIG_FILES="$CONFIG_FILES test/perf/ubrkperf/Makefile" ;;
|
||||
"test/perf/charperf/Makefile") CONFIG_FILES="$CONFIG_FILES test/perf/charperf/Makefile" ;;
|
||||
"test/perf/convperf/Makefile") CONFIG_FILES="$CONFIG_FILES test/perf/convperf/Makefile" ;;
|
||||
"test/perf/localecanperf/Makefile") CONFIG_FILES="$CONFIG_FILES test/perf/localecanperf/Makefile" ;;
|
||||
"test/perf/normperf/Makefile") CONFIG_FILES="$CONFIG_FILES test/perf/normperf/Makefile" ;;
|
||||
"test/perf/DateFmtPerf/Makefile") CONFIG_FILES="$CONFIG_FILES test/perf/DateFmtPerf/Makefile" ;;
|
||||
"test/perf/howExpensiveIs/Makefile") CONFIG_FILES="$CONFIG_FILES test/perf/howExpensiveIs/Makefile" ;;
|
||||
|
@ -22,7 +22,7 @@ subdir = test/perf
|
||||
## Files to remove for 'make clean'
|
||||
CLEANFILES = *~
|
||||
|
||||
SUBDIRS = collationperf collperf collperf2 charperf dicttrieperf normperf ubrkperf unisetperf usetperf ustrperf utfperf utrie2perf DateFmtPerf howExpensiveIs
|
||||
SUBDIRS = collationperf collperf collperf2 charperf dicttrieperf localecanperf normperf ubrkperf unisetperf usetperf ustrperf utfperf utrie2perf DateFmtPerf howExpensiveIs
|
||||
|
||||
# Subdirs that support 'xperf'
|
||||
XSUBDIRS = DateFmtPerf
|
||||
|
79
icu4c/source/test/perf/localecanperf/Makefile.in
Normal file
79
icu4c/source/test/perf/localecanperf/Makefile.in
Normal file
@ -0,0 +1,79 @@
|
||||
## Makefile.in for ICU - test/perf/localecanperf
|
||||
## Copyright (C) 2020 and later: Unicode, Inc. and others.
|
||||
## License & terms of use: http://www.unicode.org/copyright.html#License
|
||||
|
||||
## Source directory information
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
top_builddir = ../../..
|
||||
|
||||
include $(top_builddir)/icudefs.mk
|
||||
|
||||
## Build directory information
|
||||
subdir = test/perf/localecanperf
|
||||
|
||||
## Extra files to remove for 'make clean'
|
||||
CLEANFILES = *~ $(DEPS)
|
||||
|
||||
## Target information
|
||||
TARGET = localecanperf
|
||||
|
||||
CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/tools/ctestfw
|
||||
LIBS = $(LIBCTESTFW) $(LIBICUI18N) $(LIBICUUC) $(LIBICUTOOLUTIL) $(DEFAULT_LIBS) $(LIB_M)
|
||||
|
||||
OBJECTS = localecanperf.o
|
||||
|
||||
DEPS = $(OBJECTS:.o=.d)
|
||||
|
||||
## List of phony targets
|
||||
.PHONY : all all-local install install-local clean clean-local \
|
||||
distclean distclean-local dist dist-local check check-local
|
||||
|
||||
## Clear suffix list
|
||||
.SUFFIXES :
|
||||
|
||||
## List of standard targets
|
||||
all: all-local
|
||||
install: install-local
|
||||
clean: clean-local
|
||||
distclean : distclean-local
|
||||
dist: dist-local
|
||||
check: all check-local
|
||||
|
||||
all-local: $(TARGET)
|
||||
|
||||
install-local:
|
||||
|
||||
dist-local:
|
||||
|
||||
clean-local:
|
||||
test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
|
||||
$(RMV) $(OBJECTS) $(TARGET)
|
||||
|
||||
distclean-local: clean-local
|
||||
$(RMV) Makefile
|
||||
|
||||
check-local: all-local
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
$(TARGET) : $(OBJECTS)
|
||||
$(LINK.cc) -o $@ $^ $(LIBS)
|
||||
$(POST_BUILD_STEP)
|
||||
|
||||
invoke:
|
||||
ICU_DATA=$${ICU_DATA:-$(top_builddir)/data/} TZ=PST8PDT $(INVOKE) $(INVOCATION)
|
||||
|
||||
ifeq (,$(MAKECMDGOALS))
|
||||
-include $(DEPS)
|
||||
else
|
||||
ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
|
||||
ifneq ($(patsubst %install,,$(MAKECMDGOALS)),)
|
||||
-include $(DEPS)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
94
icu4c/source/test/perf/localecanperf/localecanperf.cpp
Normal file
94
icu4c/source/test/perf/localecanperf/localecanperf.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
***********************************************************************
|
||||
* © 2020 and later: Unicode, Inc. and others.
|
||||
* License & terms of use: http://www.unicode.org/copyright.html#License
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/uperf.h"
|
||||
|
||||
//
|
||||
// Test case ...
|
||||
//
|
||||
class LocaleCreateCanonical : public UPerfFunction {
|
||||
public:
|
||||
LocaleCreateCanonical() {
|
||||
testCases.push_back("en");
|
||||
testCases.push_back("en-US");
|
||||
testCases.push_back("ja-JP");
|
||||
testCases.push_back("zh-Hant-CN");
|
||||
testCases.push_back("hy-SU");
|
||||
}
|
||||
~LocaleCreateCanonical() { }
|
||||
virtual void call(UErrorCode* /* status */)
|
||||
{
|
||||
std::for_each(testCases.begin(), testCases.end(),
|
||||
[](const std::string& s)
|
||||
{
|
||||
Locale l = Locale::createCanonical(s.c_str());
|
||||
});
|
||||
}
|
||||
virtual long getOperationsPerIteration() { return testCases.size(); }
|
||||
virtual long getEventsPerIteration() { return testCases.size(); }
|
||||
private:
|
||||
std::vector<std::string> testCases;
|
||||
};
|
||||
|
||||
class LocaleCanonicalizationPerfTest : public UPerfTest
|
||||
{
|
||||
public:
|
||||
LocaleCanonicalizationPerfTest(
|
||||
int32_t argc, const char *argv[], UErrorCode &status)
|
||||
: UPerfTest(argc, argv, nullptr, 0, "localecanperf", status)
|
||||
{
|
||||
}
|
||||
|
||||
~LocaleCanonicalizationPerfTest()
|
||||
{
|
||||
}
|
||||
virtual UPerfFunction* runIndexedTest(
|
||||
int32_t index, UBool exec, const char *&name, char *par = nullptr);
|
||||
|
||||
private:
|
||||
UPerfFunction* TestLocaleCreateCanonical()
|
||||
{
|
||||
return new LocaleCreateCanonical();
|
||||
}
|
||||
};
|
||||
|
||||
UPerfFunction*
|
||||
LocaleCanonicalizationPerfTest::runIndexedTest(
|
||||
int32_t index, UBool exec, const char *&name, char *par /*= nullptr*/)
|
||||
{
|
||||
(void)par;
|
||||
TESTCASE_AUTO_BEGIN;
|
||||
|
||||
TESTCASE_AUTO(TestLocaleCreateCanonical);
|
||||
|
||||
TESTCASE_AUTO_END;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
LocaleCanonicalizationPerfTest test(argc, argv, status);
|
||||
|
||||
if (U_FAILURE(status)){
|
||||
fprintf(stderr, "The error is %s\n", u_errorName(status));
|
||||
test.usage();
|
||||
return status;
|
||||
}
|
||||
|
||||
if (test.run() == FALSE){
|
||||
test.usage();
|
||||
fprintf(stderr, "FAILED: Tests could not be run please check the arguments.\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
20
icu4c/source/test/perf/localecanperf/runTest.sh
Executable file
20
icu4c/source/test/perf/localecanperf/runTest.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
# run the test with 1, 10, 100, 1000, 10000, 100000 iterations
|
||||
LD_LIBRARY_PATH=lib:stubdata:tools/ctestfw:../../lib:../../stubdata:../../tools/ctestfw:$LD_LIBRARY_PATH:../../../lib:../../../stubdata:../../../tools/ctestfw:$LD_LIBRARY_PATH \
|
||||
./localecanperf TestLocaleCreateCanonical -i 1
|
||||
|
||||
LD_LIBRARY_PATH=lib:stubdata:tools/ctestfw:../../lib:../../stubdata:../../tools/ctestfw:$LD_LIBRARY_PATH:../../../lib:../../../stubdata:../../../tools/ctestfw:$LD_LIBRARY_PATH \
|
||||
./localecanperf TestLocaleCreateCanonical -i 10
|
||||
|
||||
LD_LIBRARY_PATH=lib:stubdata:tools/ctestfw:../../lib:../../stubdata:../../tools/ctestfw:$LD_LIBRARY_PATH:../../../lib:../../../stubdata:../../../tools/ctestfw:$LD_LIBRARY_PATH \
|
||||
./localecanperf TestLocaleCreateCanonical -i 100
|
||||
|
||||
LD_LIBRARY_PATH=lib:stubdata:tools/ctestfw:../../lib:../../stubdata:../../tools/ctestfw:$LD_LIBRARY_PATH:../../../lib:../../../stubdata:../../../tools/ctestfw:$LD_LIBRARY_PATH \
|
||||
./localecanperf TestLocaleCreateCanonical -i 1000
|
||||
|
||||
LD_LIBRARY_PATH=lib:stubdata:tools/ctestfw:../../lib:../../stubdata:../../tools/ctestfw:$LD_LIBRARY_PATH:../../../lib:../../../stubdata:../../../tools/ctestfw:$LD_LIBRARY_PATH \
|
||||
./localecanperf TestLocaleCreateCanonical -i 10000
|
||||
|
||||
LD_LIBRARY_PATH=lib:stubdata:tools/ctestfw:../../lib:../../stubdata:../../tools/ctestfw:$LD_LIBRARY_PATH:../../../lib:../../../stubdata:../../../tools/ctestfw:$LD_LIBRARY_PATH \
|
||||
./localecanperf TestLocaleCreateCanonical -i 100000
|
Loading…
Reference in New Issue
Block a user