]> granicus.if.org Git - icu/commitdiff
ICU-21843 Modifies performance tests and test framework in preparation of
authorgnrunge <nrunge@google.com>
Tue, 8 Feb 2022 23:23:21 +0000 (15:23 -0800)
committerNorbert Runge <41129501+gnrunge@users.noreply.github.com>
Fri, 11 Feb 2022 19:29:19 +0000 (11:29 -0800)
adding performance tests to ICU CI.
- test/perf/Makefile.in:
    adds strsrchperf to list of subdirs.
    changes target 'all' to compile everything in the standard way.
- test/perf/ustrperf/Makefile.in: changes target executable from stringperf to
  ustrperf (i.e. name of directory) to allow uniform handling with other
  perf tests in GHA CI rules.
- tools/ctestfw/uperf.cpp: changes output to ndjson format for processing with
  GHA Benchmark. Keep the previous output, which gets processed by the Perl
  scripts, when executed in 'verbose' mode. Backward compatibility,
  in case someone still wants to use the Perl scripts for the time being.
  May get cleaned up later.
Also remove a few non-essential output lines that would interfer with
GHA Benchmark.
processing

icu4c/source/test/perf/Makefile.in
icu4c/source/test/perf/charperf/charperf.cpp
icu4c/source/test/perf/ustrperf/Makefile.in
icu4c/source/test/perf/ustrperf/stringperf.h
icu4c/source/tools/ctestfw/uperf.cpp

index cb7c2f15943c8b61219b8c2ee700bab3112420e8..85469cf092ff1dc086af92649282b3b82d3afab1 100644 (file)
@@ -22,7 +22,7 @@ subdir = test/perf
 ## Files to remove for 'make clean'
 CLEANFILES = *~
 
-SUBDIRS = collationperf collperf collperf2 charperf dicttrieperf localecanperf normperf ubrkperf unisetperf usetperf ustrperf utfperf utrie2perf DateFmtPerf howExpensiveIs
+SUBDIRS = collationperf collperf collperf2 charperf dicttrieperf localecanperf normperf strsrchperf ubrkperf unisetperf usetperf ustrperf utfperf utrie2perf DateFmtPerf howExpensiveIs
 
 # Subdirs that support 'xperf'
 XSUBDIRS = DateFmtPerf
@@ -38,10 +38,7 @@ check check-recursive check-local xperf xperf-recursive
 
 ## List of standard targets
 everything: all-recursive all-local
-all:
-ifneq ($(RECURSIVE),YES)
-       @echo simply use \`make\' \(or \`make everything\'\) to do all
-endif
+all: everything
 
 install: install-recursive install-local
 clean: clean-recursive clean-local
index 6fc576cd235b704907ccc5f46b0bb5d2fdfc8204..651434b6a49647d7d60cdfb217ad8d1417fd7330 100644 (file)
@@ -81,7 +81,6 @@ CharPerformanceTest::CharPerformanceTest(int32_t argc, const char *argv[],
     else {
         MAX_ = 0xffff;
     }
-    printf("MAX_ size will be 0x%x\n", MAX_);
     if (options[MIN_OPTION_].doesOccur) {
         MIN_ = atoi(options[MIN_OPTION_].value);
     }
index 4d601137ac00b14dd5fe95c14a5ff794b4900487..8ef95af01d23cc91b938a714b6208e04b412f1fa 100644 (file)
@@ -20,7 +20,7 @@ subdir = test/perf/ustrperf
 CLEANFILES = *~ $(DEPS)
 
 ## Target information
-TARGET = stringperf
+TARGET = ustrperf
 
 CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/tools/ctestfw
 LIBS = $(LIBCTESTFW) $(LIBICUI18N) $(LIBICUUC) $(LIBICUTOOLUTIL) $(DEFAULT_LIBS) $(LIB_M)
index 59b841865a3377d80c8aa3ec2835794a1651d1a1..39ca45987c900337735a2715b61430be916f5c0e 100644 (file)
@@ -444,7 +444,6 @@ inline void catenate(const UChar* src,int32_t srcLen, UnicodeString s0)
 
     utimer_getTime(&mystop);
     double mytime = utimer_getDeltaSeconds(&mystart,&mystop);
-    printf("\nmytime=%f \n", mytime);
 
     *catICU += uCatenate_STR;
 }
@@ -533,7 +532,6 @@ inline void StdLibCatenate(const wchar_t* src,int32_t srcLen, stlstring s0)
 
     utimer_getTime(&mystop);
     double mytime = utimer_getDeltaSeconds(&mystart,&mystop);
-    printf("\nmytime=%f \n", mytime);
 
 }
 
index 5605f0d2e3de2948930284d9f2e6f3524d0a8cf8..67b9fe50aae965b6cbffa8dc3ca365141e82261d 100644 (file)
@@ -390,7 +390,7 @@ UBool UPerfTest::runTestLoop( char* testname, char* par )
                         loops = failsafe;
                         failsafe *= 10;
                     } else {
-                        //System.out.println("# " + meth.getName() + " x " + loops + " = " + t);                            
+                        //System.out.println("# " + meth.getName() + " x " + loops + " = " + t);
                         loops = (int)((double)n / t * loops + 0.5);
                         if (loops == 0) {
                             fprintf(stderr,"Unable to converge on desired duration");
@@ -412,15 +412,13 @@ UBool UPerfTest::runTestLoop( char* testname, char* par )
             long events = -1;
 
             for(int32_t ps =0; ps < passes; ps++){
-                fprintf(stdout,"= %s begin " ,name);
                 if(verbose==TRUE){
+                    fprintf(stdout,"= %s begin " ,name);
                     if(iterations > 0) {
                         fprintf(stdout, "%i\n", (int)loops);
                     } else {
                         fprintf(stdout, "%i\n", (int)n);
                     }
-                } else {
-                    fprintf(stdout, "\n");
                 }
                 t = testFunction->time(loops, &status);
                 if(U_FAILURE(status)){
@@ -439,12 +437,6 @@ UBool UPerfTest::runTestLoop( char* testname, char* par )
                     }else{
                         fprintf(stdout, "= %s end: %f loops: %i operations: %li events: %li\n", name, t, (int)loops, ops, events);
                     }
-                }else{
-                    if(events == -1){
-                        fprintf(stdout,"= %s end %f %i %li\n", name, t, (int)loops, ops);
-                    }else{
-                        fprintf(stdout,"= %s end %f %i %li %li\n", name, t, (int)loops, ops, events);
-                    }
                 }
             }
             if(verbose && U_SUCCESS(status)) {
@@ -465,6 +457,12 @@ UBool UPerfTest::runTestLoop( char* testname, char* par )
                             name, min_t, (int)loops, (min_t*1E9)/(loops*ops), (min_t*1E9)/(loops*events));
                 }
             }
+            else if(U_SUCCESS(status)) {
+                // Print results in ndjson format for GHA Benchmark to process.
+                fprintf(stdout,
+                        "{\"biggerIsBetter\":false,\"name\":\"%s\",\"unit\":\"ns/iter\",\"value\":%.4f}\n",
+                        name, (min_t*1E9)/(loops*ops));
+            }
             delete testFunction;
         }
         index++;