Changeset 4d0eb1c
- Timestamp:
- Nov 18, 2021, 2:49:47 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 97d58dc
- Parents:
- 01db301
- Location:
- tests/zombies/string-perf
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/zombies/string-perf/Makefile
r01db301 r4d0eb1c 7 7 PERFFLAGS_CXX = -DNDEBUG -O2 8 8 9 #PERFPROGS can include this one, but it's 10x slower than its peers10 # perfexp-cfa-hl-pta-noshare \11 9 12 10 PERFPROGS = \ … … 15 13 perfexp-cfa-ll-pta-share \ 16 14 perfexp-cfa-ll-peq-share \ 15 perfexp-cfa-hl-pta-noshare \ 17 16 perfexp-cfa-hl-peq-noshare \ 18 17 perfexp-cfa-ll-pta-noshare \ … … 26 25 27 26 perfexp-cfa-hl-pta-share : prog.cfa $(LIBCFA) 28 $(CFA) $(PERFFLAGS_CFA) $ ^-o $@ -DIMPL_CFA_HL_SHARE -DOP_PLUS_THEN_ASSIGN27 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_HL_SHARE -DOP_PLUS_THEN_ASSIGN 29 28 30 29 perfexp-cfa-hl-peq-share : prog.cfa $(LIBCFA) 31 $(CFA) $(PERFFLAGS_CFA) $ ^-o $@ -DIMPL_CFA_HL_SHARE -DOP_PLUSEQ30 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_HL_SHARE -DOP_PLUSEQ 32 31 33 32 perfexp-cfa-ll-pta-share : prog.cfa $(LIBCFA) 34 $(CFA) $(PERFFLAGS_CFA) $ ^-o $@ -DIMPL_CFA_LL_SHARE -DOP_PLUS_THEN_ASSIGN33 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_LL_SHARE -DOP_PLUS_THEN_ASSIGN 35 34 36 35 perfexp-cfa-ll-peq-share : prog.cfa $(LIBCFA) 37 $(CFA) $(PERFFLAGS_CFA) $ ^-o $@ -DIMPL_CFA_LL_SHARE -DOP_PLUSEQ36 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_LL_SHARE -DOP_PLUSEQ 38 37 39 38 perfexp-cfa-hl-pta-noshare : prog.cfa $(LIBCFA) 40 $(CFA) $(PERFFLAGS_CFA) $ ^-o $@ -DIMPL_CFA_HL_NOSHARE -DOP_PLUS_THEN_ASSIGN39 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_HL_NOSHARE -DOP_PLUS_THEN_ASSIGN 41 40 42 41 perfexp-cfa-hl-peq-noshare : prog.cfa $(LIBCFA) 43 $(CFA) $(PERFFLAGS_CFA) $ ^-o $@ -DIMPL_CFA_HL_NOSHARE -DOP_PLUSEQ42 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_HL_NOSHARE -DOP_PLUSEQ 44 43 45 44 perfexp-cfa-ll-pta-noshare : prog.cfa $(LIBCFA) 46 $(CFA) $(PERFFLAGS_CFA) $ ^-o $@ -DIMPL_CFA_LL_NOSHARE -DOP_PLUS_THEN_ASSIGN45 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_LL_NOSHARE -DOP_PLUS_THEN_ASSIGN 47 46 48 47 perfexp-cfa-ll-peq-noshare : prog.cfa $(LIBCFA) 49 $(CFA) $(PERFFLAGS_CFA) $ ^-o $@ -DIMPL_CFA_LL_NOSHARE -DOP_PLUSEQ48 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_LL_NOSHARE -DOP_PLUSEQ 50 49 51 50 perfexp-stl-pta : prog.cfa 52 $(CXX) -xc++ $(PERFFLAGS_CXX) $ ^-o $@ -DIMPL_STL -DOP_PLUS_THEN_ASSIGN51 $(CXX) -xc++ $(PERFFLAGS_CXX) $< -o $@ -DIMPL_STL -DOP_PLUS_THEN_ASSIGN 53 52 54 53 perfexp-stl-peq : prog.cfa 55 $(CXX) -xc++ $(PERFFLAGS_CXX) $ ^-o $@ -DIMPL_STL -DOP_PLUSEQ54 $(CXX) -xc++ $(PERFFLAGS_CXX) $< -o $@ -DIMPL_STL -DOP_PLUSEQ 56 55 57 56 perfexp-buhr94-pta.o : prog.cfa 58 $(CXX) -xc++ -c $(PERFFLAGS_CXX) $ ^-o $@ -DIMPL_BUHR94 -DOP_PLUS_THEN_ASSIGN57 $(CXX) -xc++ -c $(PERFFLAGS_CXX) $< -o $@ -DIMPL_BUHR94 -DOP_PLUS_THEN_ASSIGN 59 58 60 59 perfexp-buhr94-peq.o : prog.cfa 61 $(CXX) -xc++ -c $(PERFFLAGS_CXX) $ ^-o $@ -DIMPL_BUHR94 -DOP_PLUSEQ60 $(CXX) -xc++ -c $(PERFFLAGS_CXX) $< -o $@ -DIMPL_BUHR94 -DOP_PLUSEQ 62 61 63 62 buhr94-string.o: … … 77 76 78 77 MEASURE = $(PERFPROGS) 79 CORPORI = ../corpus-100-*-1.txt78 CORPORI = corpus-100-*-1.txt 80 79 81 measur ment: $(MEASURE)80 measurement: $(MEASURE) 82 81 tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \ 83 82 echo $$tofile ; \ … … 85 84 for corpus in $(CORPORI) ; do \ 86 85 corpusbody=`cat $$corpus` ; \ 87 printed=`./$$prog $$corpusbody` ; \86 printed=`./$$prog 100 10 $$corpusbody` ; \ 88 87 echo $$prog,$$corpus,$$printed >> $$tofile ; \ 89 88 done ; \ -
tests/zombies/string-perf/prog.cfa
r01db301 r4d0eb1c 5 5 #include <cstdio> 6 6 using namespace std; 7 #define IMPL_CXX 7 8 8 9 #elif defined IMPL_CFA_HL_SHARE 9 10 #define IMPL_CFA_HL 11 #define IMPL_CFA 10 12 11 13 #elif defined IMPL_CFA_LL_SHARE 12 14 #define IMPL_CFA_LL 15 #define IMPL_CFA 13 16 14 17 #elif defined IMPL_CFA_HL_NOSHARE 15 18 #define IMPL_CFA_HL 16 19 #define CFA_NOSHARE 20 #define IMPL_CFA 17 21 18 22 #elif defined IMPL_CFA_LL_NOSHARE 19 23 #define IMPL_CFA_LL 20 24 #define CFA_NOSHARE 25 #define IMPL_CFA 21 26 22 27 #elif defined IMPL_BUHR94 … … 24 29 #include <cstdio> 25 30 #include "/u0/mlbrooks/usys1/sm/string/StringSharing/src/string.h" 31 #define IMPL_CXX 26 32 27 33 #else … … 44 50 #endif 45 51 52 #if defined IMPL_CFA 53 #include <math.hfa> 54 #elif defined IMPL_CXX 55 #include <algorithm> 56 using std::min; 57 #endif 46 58 47 59 #include <time.h> 48 60 #include <stdlib.h> // atoi 61 #include <string.h> // strlen, only during setup 49 62 50 63 #if defined IMPL_STL || defined IMPL_BUHR94 … … 56 69 #endif 57 70 71 double meanLen(int N, char ** strings) { 72 int totalLen = 0; 73 for (int i = 0 ; i < N; i ++) { 74 totalLen += strlen(strings[i]); 75 } 76 return (double)totalLen / (double)N; 77 } 78 58 79 volatile int checkthis = 0; 59 80 #define MAYBE( op ) if (checkthis) { op; } … … 61 82 int main( int argc, char ** argv ) { 62 83 63 84 STRING_SHARING_CONTROL 64 85 65 enum { NumConcats = 100, Times = 5000000 };66 clock_t start, end;67 86 68 int corpuslen = argc - 1; 69 char ** corpus = argv + 1; 87 const char * usage_args = "ConcatsPerReset ExecTimeSecs Corpus..."; 88 const int static_arg_posns = 3; 89 90 int concatsPerReset = -1, execTimeSecs = -1; 91 92 switch (min(argc, static_arg_posns)) { 93 case 3: execTimeSecs = atoi(argv[2]); 94 case 2: concatsPerReset = atoi(argv[1]); 95 } 96 97 int corpuslen = argc - static_arg_posns; 98 char ** corpus = argv + static_arg_posns; 99 100 if (execTimeSecs < 1 || concatsPerReset < 1 || corpuslen < 1) { 101 printf("usage: %s %s\n", argv[0], usage_args); 102 printf("output:\nconcatsPerReset,corpusItemCount,corpusMeanLenChars,concatDoneActualCount,execTimeActualSec\n"); 103 exit(1); 104 } 105 106 double meanCorpusLen = meanLen(corpuslen, corpus); 107 108 clock_t start, end_target, end_actual; 70 109 71 110 #if defined IMPL_CFA_LL 72 string_res x = " foo2";111 string_res x = "starter"; 73 112 string_res y; 113 #if defined OP_PLUS_THEN_ASSIGN 74 114 string_res z; 115 #endif 75 116 #define RESET y = x; 76 117 #else 77 string x = " foo2";118 string x = "starter"; 78 119 string y; 79 120 #define RESET y = x; … … 81 122 82 123 start = clock(); 83 for ( volatile unsigned int t = 0; t < Times; t += 1 ) { 124 end_target = start + CLOCKS_PER_SEC * execTimeSecs; 125 volatile unsigned int t = 0; 126 for ( ; t % 100 != 0 || clock() < end_target ; t += 1 ) { 84 127 RESET 85 for ( volatile unsigned int i = 0; i < NumConcats; i += 1 ) {128 for ( volatile unsigned int i = 0; i < concatsPerReset; i += 1 ) { 86 129 MAYBE( PRINT(y) ) 87 char *toAppend = corpus[i %corpuslen];130 char *toAppend = corpus[i % corpuslen]; // ? corpus[rand() % corpuslen] 88 131 #if defined OP_PLUS_THEN_ASSIGN && defined IMPL_CFA_LL 89 132 z = y; … … 97 140 } 98 141 } 99 end = clock(); 100 double elapsed = ((double) (end - start)) / CLOCKS_PER_SEC; 101 printf("%f sec\n", elapsed); 142 end_actual = clock(); 143 unsigned int concatsDone = t * concatsPerReset; 144 double elapsed = ((double) (end_actual - start)) / CLOCKS_PER_SEC; 145 printf("%d,%d,%f,%d,%f\n", concatsPerReset, corpuslen, meanCorpusLen, concatsDone, elapsed); 102 146 103 147 return 0;
Note: See TracChangeset
for help on using the changeset viewer.