summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-regtest.py
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3-regtest.py')
-rwxr-xr-xxdelta3/xdelta3-regtest.py61
1 files changed, 27 insertions, 34 deletions
diff --git a/xdelta3/xdelta3-regtest.py b/xdelta3/xdelta3-regtest.py
index 0df2065..cd31cff 100755
--- a/xdelta3/xdelta3-regtest.py
+++ b/xdelta3/xdelta3-regtest.py
@@ -44,7 +44,7 @@ SKIP_DECODE = 1
44MIN_STDDEV_PCT = 1.5 44MIN_STDDEV_PCT = 1.5
45 45
46# How many results per round 46# How many results per round
47MAX_RESULTS = 40 47MAX_RESULTS = 100
48TEST_ROUNDS = 500 48TEST_ROUNDS = 500
49KEEP_P = (0.5) 49KEEP_P = (0.5)
50 50
@@ -98,7 +98,7 @@ def INPUT_SPEC(rand):
98 98
99 # -C 1,2,3,4,5,6,7 99 # -C 1,2,3,4,5,6,7
100 'large_look' : lambda d: rand.choice([9]), 100 'large_look' : lambda d: rand.choice([9]),
101 'large_step' : lambda d: rand.choice([2, 3, 8, 15]), 101 'large_step' : lambda d: rand.choice([3, 5, 7, 8, 15]),
102 'small_chain' : lambda d: rand.choice([40, 10, 4, 1]), 102 'small_chain' : lambda d: rand.choice([40, 10, 4, 1]),
103 'small_lchain' : lambda d: rand.choice([x for x in [10, 4, 2, 1] if x <= d['small_chain']]), 103 'small_lchain' : lambda d: rand.choice([x for x in [10, 4, 2, 1] if x <= d['small_chain']]),
104 'max_lazy' : lambda d: rand.choice([9, 18, 27, 36, 72, 108]), 104 'max_lazy' : lambda d: rand.choice([9, 18, 27, 36, 72, 108]),
@@ -106,7 +106,7 @@ def INPUT_SPEC(rand):
106 'small_look' : lambda d: rand.choice([4]), 106 'small_look' : lambda d: rand.choice([4]),
107 107
108 # -N 108 # -N
109 'nocompress' : lambda d: rand.choice(['false']), 109 'nocompress' : lambda d: rand.choice(['true']),
110 110
111 # -T 111 # -T
112 'altcode' : lambda d: rand.choice(['false']), 112 'altcode' : lambda d: rand.choice(['false']),
@@ -794,7 +794,7 @@ class RcsFinder:
794 testkey = 'rcs%d' % self.biground 794 testkey = 'rcs%d' % self.biground
795 self.biground = self.biground + 1 795 self.biground = self.biground + 1
796 796
797 print 'source %u bytes; target %u bytes; %s' % (f1sz, f2sz, testkey) 797 print '%s; source %u bytes; target %u bytes' % (testkey, f1sz, f2sz)
798 f1.close() 798 f1.close()
799 f2.close() 799 f2.close()
800 return (TMPDIR + "/big.1", 800 return (TMPDIR + "/big.1",
@@ -881,7 +881,7 @@ class RandomTest:
881 self.myconfig = config 881 self.myconfig = config
882 self.tnum = tnum 882 self.tnum = tnum
883 883
884 if syntuple: 884 if syntuple != None:
885 self.runtime = syntuple[0] 885 self.runtime = syntuple[0]
886 self.compsize = syntuple[1] 886 self.compsize = syntuple[1]
887 self.decodetime = None 887 self.decodetime = None
@@ -988,10 +988,20 @@ def RunTestLoop(rand, generator, rounds):
988 tests = [] 988 tests = []
989 for x in xrange(len(configs)): 989 for x in xrange(len(configs)):
990 t = RandomTest(x, tinput, configs[x]) 990 t = RandomTest(x, tinput, configs[x])
991 print 'Test %d: %s' % (x, t) 991 print 'Round %d test %d: %s' % (rnum, x, t)
992 tests.append(t) 992 tests.append(t)
993 #end 993 #end
994 results = ScoreTests(tests) 994 results = ScoreTests(tests)
995
996 for r in results:
997 c = r.config()
998 if not test_all_config_results.has_key(c):
999 test_all_config_results[c] = [r]
1000 else:
1001 test_all_config_results[c].append(r)
1002 #end
1003 #end
1004
995 GraphResults('expt%d' % rnum, results) 1005 GraphResults('expt%d' % rnum, results)
996 GraphSummary('sum%d' % rnum, results) 1006 GraphSummary('sum%d' % rnum, results)
997 1007
@@ -1036,12 +1046,6 @@ def ScoreTests(results):
1036 for (score, test) in scored: 1046 for (score, test) in scored:
1037 pos += 1 1047 pos += 1
1038 test.score_pos = pos 1048 test.score_pos = pos
1039 c = test.config()
1040 if not test_all_config_results.has_key(c):
1041 test_all_config_results[c] = [test]
1042 else:
1043 test_all_config_results[c].append(test)
1044 #end
1045 #end 1049 #end
1046 1050
1047 scored = [x[1] for x in scored] 1051 scored = [x[1] for x in scored]
@@ -1054,22 +1058,7 @@ def ScoreTests(results):
1054 for test in scored: 1058 for test in scored:
1055 c = test.config() 1059 c = test.config()
1056 s = 0.0 1060 s = 0.0
1057 all_r = test_all_config_results[c] 1061 print 'H-Score: %0.9f %s' % (test.score, test)
1058 for t in all_r:
1059 s += float(t.score_pos)
1060 #end
1061 if len(all_r) == 1:
1062 stars = ''
1063 elif len(all_r) >= 10:
1064 stars = ' ***'
1065 elif len(all_r) >= int(1/KEEP_P):
1066 stars = ' **'
1067 else:
1068 stars = ' *'
1069 print 'Score: %0.6f %s (%.1f%s%s)' % \
1070 (test.score, test, s / len(all_r), stars,
1071 (len(all_r) > 2) and
1072 (' in %d' % len(all_r)) or "")
1073 #end 1062 #end
1074 1063
1075 return scored 1064 return scored
@@ -1112,7 +1101,7 @@ def GraphSummary(desc, results_ignore):
1112 # sort configs descending by number of tests 1101 # sort configs descending by number of tests
1113 config_ordered.sort(lambda x, y: len(y) - len(x)) 1102 config_ordered.sort(lambda x, y: len(y) - len(x))
1114 1103
1115 print 'population: %d: %d configs max %d results' % \ 1104 print 'population %d: %d configs %d results' % \
1116 (test_population, 1105 (test_population,
1117 len(config_ordered), 1106 len(config_ordered),
1118 len(config_ordered[0])) 1107 len(config_ordered[0]))
@@ -1129,7 +1118,7 @@ def GraphSummary(desc, results_ignore):
1129 config = config_ordered[i][0].config() 1118 config = config_ordered[i][0].config()
1130 config_tests = config_ordered[i] 1119 config_tests = config_ordered[i]
1131 1120
1132 print '%s has %d tested inputs' % (config, len(config_tests)) 1121 #print '%s has %d tested inputs' % (config, len(config_tests))
1133 1122
1134 if len(input_set) == 0: 1123 if len(input_set) == 0:
1135 input_set = dict([(t.tinput(), [t]) for t in config_tests]) 1124 input_set = dict([(t.tinput(), [t]) for t in config_tests])
@@ -1157,7 +1146,6 @@ def GraphSummary(desc, results_ignore):
1157 # continue if there are more w/ the same number of inputs 1146 # continue if there are more w/ the same number of inputs
1158 if i < (len(config_ordered) - 1) and \ 1147 if i < (len(config_ordered) - 1) and \
1159 len(config_ordered[i + 1]) == len(config_tests): 1148 len(config_ordered[i + 1]) == len(config_tests):
1160 print 'b %s' % i
1161 continue 1149 continue
1162 #end 1150 #end
1163 1151
@@ -1168,12 +1156,14 @@ def GraphSummary(desc, results_ignore):
1168 smap = {} 1156 smap = {}
1169 for (key, tests) in input_set.items(): 1157 for (key, tests) in input_set.items():
1170 if config_num == None: 1158 if config_num == None:
1159 # config_num should be the same in all elements
1171 config_num = len(tests) 1160 config_num = len(tests)
1172 smap = dict([(r.config(), 1161 smap = dict([(r.config(),
1173 (r.time(), 1162 (r.time(),
1174 r.size())) 1163 r.size()))
1175 for r in tests]) 1164 for r in tests])
1176 else: 1165 else:
1166 # compuate the per-config sum of time/size
1177 assert config_num == len(tests) 1167 assert config_num == len(tests)
1178 smap = dict([(r.config(), 1168 smap = dict([(r.config(),
1179 (smap[r.config()][0] + r.time(), 1169 (smap[r.config()][0] + r.time(),
@@ -1183,13 +1173,14 @@ def GraphSummary(desc, results_ignore):
1183 #end 1173 #end
1184 1174
1185 if config_num == 1: 1175 if config_num == 1:
1186 print 'c %s' % smap
1187 continue 1176 continue
1188 #end 1177 #end
1189 1178
1179 if len(input_set) == osize:
1180 break
1181 #end
1182
1190 summary = '%s-%d' % (desc, len(input_set)) 1183 summary = '%s-%d' % (desc, len(input_set))
1191 print "what?", osize, len(input_set), input_set
1192 assert len(input_set) < osize
1193 osize = len(input_set) 1184 osize = len(input_set)
1194 1185
1195 print 'generate %s w/ %d configs' % (summary, config_num) 1186 print 'generate %s w/ %d configs' % (summary, config_num)
@@ -1197,6 +1188,8 @@ def GraphSummary(desc, results_ignore):
1197 syntuple = (smap[config][0], smap[config][1])) 1188 syntuple = (smap[config][0], smap[config][1]))
1198 for config in smap.keys()] 1189 for config in smap.keys()]
1199 syn = ScoreTests(syn) 1190 syn = ScoreTests(syn)
1191 #print 'smap is %s' % (smap,)
1192 #print 'syn is %s' % (' and '.join([str(x) for x in syn]))
1200 GraphResults(summary, syn) 1193 GraphResults(summary, syn)
1201 #end 1194 #end
1202#end 1195#end