diff options
author | Josh MacDonald <josh.macdonald@gmail.com> | 2015-12-26 21:58:37 -0800 |
---|---|---|
committer | Josh MacDonald <josh.macdonald@gmail.com> | 2015-12-26 21:58:37 -0800 |
commit | 9b895e7bcfb196b40b7760020542ea02ab5390aa (patch) | |
tree | 7ad3922a0afe8bfcd0cfe646157731db9ca64fee /xdelta3 | |
parent | 438e90db9459a4a5880f3663c4da35ed3df64da4 (diff) | |
parent | 318dabfa4bd68711900f59cbc9d75c7b1d15d958 (diff) |
Merge upstream
Diffstat (limited to 'xdelta3')
-rw-r--r-- | xdelta3/go/src/regtest.go | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/xdelta3/go/src/regtest.go b/xdelta3/go/src/regtest.go index 4dc6e36..24229f9 100644 --- a/xdelta3/go/src/regtest.go +++ b/xdelta3/go/src/regtest.go | |||
@@ -69,9 +69,28 @@ type PairTest struct { | |||
69 | source, target string | 69 | source, target string |
70 | 70 | ||
71 | // Output | 71 | // Output |
72 | TestOutput | ||
73 | } | ||
74 | |||
75 | type TestOutput struct { | ||
72 | encoded int64 | 76 | encoded int64 |
73 | encDuration time.Duration | 77 | encDuration time.Duration |
74 | decDuration time.Duration | 78 | decDuration time.Duration |
79 | encSysDuration time.Duration | ||
80 | decSysDuration time.Duration | ||
81 | } | ||
82 | |||
83 | func (to *TestOutput) Add(a TestOutput) { | ||
84 | to.encoded += a.encoded | ||
85 | to.encDuration += a.encDuration | ||
86 | to.decDuration += a.decDuration | ||
87 | to.encSysDuration += a.encSysDuration | ||
88 | to.decSysDuration += a.decSysDuration | ||
89 | } | ||
90 | |||
91 | func (to *TestOutput) String() string { | ||
92 | return fmt.Sprintf("SIZE: %v\tT: %v\tTSYS: %v\tDT: %v\tDTSYS: %v", | ||
93 | to.encoded, to.encDuration, to.encSysDuration, to.decDuration, to.encSysDuration) | ||
75 | } | 94 | } |
76 | 95 | ||
77 | // P is the test program, Q is the reference version. | 96 | // P is the test program, Q is the reference version. |
@@ -94,35 +113,58 @@ func (cfg Config) datasetTest(t *xdelta.TestGroup, p, q xdelta.Program) { | |||
94 | total += d.Size() | 113 | total += d.Size() |
95 | } | 114 | } |
96 | meansize := total / int64(len(dents)) | 115 | meansize := total / int64(len(dents)) |
116 | largest := uint(20) | ||
117 | for ; largest <= 31 && 1<<largest < meansize; largest++ {} | ||
118 | |||
97 | sort.Strings(paths) | 119 | sort.Strings(paths) |
120 | |||
121 | testSum := map[uint]*TestOutput{} | ||
122 | compSum := map[uint]*TestOutput{} | ||
123 | |||
98 | for _, in1 := range paths { | 124 | for _, in1 := range paths { |
99 | for _, in2 := range paths { | 125 | for _, in2 := range paths { |
100 | if in1 == in2 { continue } | 126 | if in1 == in2 { continue } |
101 | 127 | ||
102 | largest := uint(20) | 128 | // 1/4, 1/2, and 1 of the power-of-2 rounded-up mean size |
103 | for ; largest <= 31 && 1<<largest < meansize; largest++ {} | ||
104 | |||
105 | // 1/4, 1/2, and 1/1 of the power-of-2 rounded-up mean size | ||
106 | for b := largest - 2; b <= largest; b++ { | 129 | for b := largest - 2; b <= largest; b++ { |
130 | if _, has := testSum[b]; !has { | ||
131 | testSum[b] = &TestOutput{} | ||
132 | compSum[b] = &TestOutput{} | ||
133 | } | ||
107 | c1 := cfg | 134 | c1 := cfg |
108 | c1.srcbuf_size = 1<<b | 135 | c1.srcbuf_size = 1<<b |
109 | ptest := &PairTest{c1, p, in1, in2, -1, 0, 0} | 136 | ptest := &PairTest{c1, p, in1, in2, TestOutput{-1, 0, 0, 0, 0}} |
110 | ptest.datasetPairTest(t, 1<<b); | 137 | ptest.datasetPairTest(t, 1<<b); |
111 | qtest := &PairTest{c1, q, in1, in2, -1, 0, 0} | 138 | qtest := &PairTest{c1, q, in1, in2, TestOutput{-1, 0, 0, 0, 0}} |
112 | qtest.datasetPairTest(t, 1<<b) | 139 | qtest.datasetPairTest(t, 1<<b) |
113 | 140 | ||
114 | fmt.Printf("%s, %s: %+d/%db, E:%s/%s D:%s/%s [B=%d]\n", | 141 | testSum[b].Add(ptest.TestOutput) |
142 | compSum[b].Add(qtest.TestOutput) | ||
143 | |||
144 | fmt.Printf("%s, %s: %.2f%% %+d/%d\n\tE:%.2f%%/%s(%.2f%%/%s) D:%.2f%%/%s(%.2f%%/%s) [B=%d]\n", | ||
115 | path.Base(in1), path.Base(in2), | 145 | path.Base(in1), path.Base(in2), |
146 | float64(ptest.encoded - qtest.encoded) * 100.0 / float64(qtest.encoded), | ||
116 | ptest.encoded - qtest.encoded, | 147 | ptest.encoded - qtest.encoded, |
117 | qtest.encoded, | 148 | qtest.encoded, |
118 | (ptest.encDuration - qtest.encDuration).String(), | 149 | (ptest.encDuration - qtest.encDuration).Seconds() * 100.0 / qtest.encDuration.Seconds(), |
150 | qtest.encDuration, | ||
151 | (ptest.decDuration - qtest.decDuration).Seconds() * 100.0 / qtest.decDuration.Seconds(), | ||
119 | qtest.encDuration, | 152 | qtest.encDuration, |
120 | (ptest.decDuration - qtest.decDuration).String(), | 153 | (ptest.encSysDuration - qtest.encSysDuration).Seconds() * 100.0 / qtest.encSysDuration.Seconds(), |
121 | qtest.decDuration, | 154 | qtest.encSysDuration, |
155 | (ptest.decSysDuration - qtest.decSysDuration).Seconds() * 100.0 / qtest.decSysDuration.Seconds(), | ||
156 | qtest.decSysDuration, | ||
122 | 1<<b) | 157 | 1<<b) |
123 | } | 158 | } |
124 | } | 159 | } |
125 | } | 160 | } |
161 | var keys []uint | ||
162 | for k, _ := range testSum { | ||
163 | keys = append(keys, k) | ||
164 | } | ||
165 | for _, k := range keys { | ||
166 | fmt.Printf("B=%v\nTEST: %v\nCOMP: %v\n", 1<<k, testSum[k], compSum[k]) | ||
167 | } | ||
126 | } | 168 | } |
127 | 169 | ||
128 | func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) { | 170 | func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) { |
@@ -138,6 +180,7 @@ func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) { | |||
138 | dargs := []string{"-dc", fmt.Sprint("-B", cfg.srcbuf_size), //"-q", | 180 | dargs := []string{"-dc", fmt.Sprint("-B", cfg.srcbuf_size), //"-q", |
139 | fmt.Sprint("-W", cfg.window_size), "-s", pt.source, | 181 | fmt.Sprint("-W", cfg.window_size), "-s", pt.source, |
140 | "-S", "none"} | 182 | "-S", "none"} |
183 | |||
141 | dec, err := t.Exec("decode", pt.program, false, dargs) | 184 | dec, err := t.Exec("decode", pt.program, false, dargs) |
142 | if err != nil { | 185 | if err != nil { |
143 | t.Panic(err) | 186 | t.Panic(err) |
@@ -159,6 +202,8 @@ func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) { | |||
159 | 202 | ||
160 | pt.decDuration = dec.Cmd.ProcessState.UserTime() | 203 | pt.decDuration = dec.Cmd.ProcessState.UserTime() |
161 | pt.encDuration = enc.Cmd.ProcessState.UserTime() | 204 | pt.encDuration = enc.Cmd.ProcessState.UserTime() |
205 | pt.decSysDuration = dec.Cmd.ProcessState.SystemTime() | ||
206 | pt.encSysDuration = enc.Cmd.ProcessState.SystemTime() | ||
162 | } | 207 | } |
163 | 208 | ||
164 | func (cfg Config) offsetTest(t *xdelta.TestGroup, p xdelta.Program, offset, length int64) { | 209 | func (cfg Config) offsetTest(t *xdelta.TestGroup, p xdelta.Program, offset, length int64) { |