diff options
Diffstat (limited to 'xdelta3/go')
-rw-r--r-- | xdelta3/go/src/regtest.go | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/xdelta3/go/src/regtest.go b/xdelta3/go/src/regtest.go index c6691b0..7b23ce0 100644 --- a/xdelta3/go/src/regtest.go +++ b/xdelta3/go/src/regtest.go | |||
@@ -67,7 +67,8 @@ type PairTest struct { | |||
67 | 67 | ||
68 | // Output | 68 | // Output |
69 | encoded int64 | 69 | encoded int64 |
70 | duration time.Duration | 70 | encDuration time.Duration |
71 | decDuration time.Duration | ||
71 | } | 72 | } |
72 | 73 | ||
73 | // P is the test program, Q is the reference version. | 74 | // P is the test program, Q is the reference version. |
@@ -101,17 +102,19 @@ func (cfg Config) datasetTest(t *xdelta.TestGroup, p, q xdelta.Program) { | |||
101 | for b := largest - 2; b <= largest; b++ { | 102 | for b := largest - 2; b <= largest; b++ { |
102 | c1 := cfg | 103 | c1 := cfg |
103 | c1.srcbuf_size = 1<<b | 104 | c1.srcbuf_size = 1<<b |
104 | ptest := &PairTest{c1, p, in1, in2, -1, 0} | 105 | ptest := &PairTest{c1, p, in1, in2, -1, 0, 0} |
105 | ptest.datasetPairTest(t, 1<<b); | 106 | ptest.datasetPairTest(t, 1<<b); |
106 | qtest := &PairTest{c1, q, in1, in2, -1, 0} | 107 | qtest := &PairTest{c1, q, in1, in2, -1, 0, 0} |
107 | qtest.datasetPairTest(t, 1<<b) | 108 | qtest.datasetPairTest(t, 1<<b) |
108 | 109 | ||
109 | fmt.Printf("%s, %s: %+d / %d bytes, %s / %s [B=%d]\n", | 110 | fmt.Printf("%s, %s: %+d/%db, E:%s/%s D:%s/%s [B=%d]\n", |
110 | path.Base(in1), path.Base(in2), | 111 | path.Base(in1), path.Base(in2), |
111 | ptest.encoded - qtest.encoded, | 112 | ptest.encoded - qtest.encoded, |
112 | qtest.encoded, | 113 | qtest.encoded, |
113 | (ptest.duration - qtest.duration).String(), | 114 | (ptest.encDuration - qtest.encDuration).String(), |
114 | qtest.duration, | 115 | qtest.encDuration, |
116 | (ptest.decDuration - qtest.decDuration).String(), | ||
117 | qtest.decDuration, | ||
115 | 1<<b) | 118 | 1<<b) |
116 | } | 119 | } |
117 | } | 120 | } |
@@ -120,14 +123,15 @@ func (cfg Config) datasetTest(t *xdelta.TestGroup, p, q xdelta.Program) { | |||
120 | 123 | ||
121 | func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) { | 124 | func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) { |
122 | cfg := pt.Config | 125 | cfg := pt.Config |
123 | eargs := []string{"-e", fmt.Sprint("-B", cfg.srcbuf_size), "-q", | 126 | eargs := []string{"-e", fmt.Sprint("-B", cfg.srcbuf_size), // "-q", |
124 | fmt.Sprint("-W", cfg.window_size), "-s", pt.source, pt.target} | 127 | fmt.Sprint("-W", cfg.window_size), "-s", pt.source, |
128 | "-I0", pt.target} | ||
125 | enc, err := t.Exec("encode", pt.program, false, eargs) | 129 | enc, err := t.Exec("encode", pt.program, false, eargs) |
126 | if err != nil { | 130 | if err != nil { |
127 | t.Panic(err) | 131 | t.Panic(err) |
128 | } | 132 | } |
129 | 133 | ||
130 | dargs := []string{"-dc", fmt.Sprint("-B", cfg.srcbuf_size), "-q", | 134 | dargs := []string{"-dc", fmt.Sprint("-B", cfg.srcbuf_size), //"-q", |
131 | fmt.Sprint("-W", cfg.window_size), "-s", pt.source} | 135 | fmt.Sprint("-W", cfg.window_size), "-s", pt.source} |
132 | dec, err := t.Exec("decode", pt.program, false, dargs) | 136 | dec, err := t.Exec("decode", pt.program, false, dargs) |
133 | if err != nil { | 137 | if err != nil { |
@@ -148,7 +152,8 @@ func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) { | |||
148 | 152 | ||
149 | t.Wait(enc, dec) | 153 | t.Wait(enc, dec) |
150 | 154 | ||
151 | pt.duration = enc.Cmd.ProcessState.UserTime() | 155 | pt.decDuration = dec.Cmd.ProcessState.UserTime() |
156 | pt.encDuration = enc.Cmd.ProcessState.UserTime() | ||
152 | } | 157 | } |
153 | 158 | ||
154 | func (cfg Config) offsetTest(t *xdelta.TestGroup, p xdelta.Program, offset, length int64) { | 159 | func (cfg Config) offsetTest(t *xdelta.TestGroup, p xdelta.Program, offset, length int64) { |
@@ -204,19 +209,18 @@ func main() { | |||
204 | 209 | ||
205 | r.RunTest("smoketest", func(t *xdelta.TestGroup) { cfg.smokeTest(t, prog) }) | 210 | r.RunTest("smoketest", func(t *xdelta.TestGroup) { cfg.smokeTest(t, prog) }) |
206 | 211 | ||
212 | // for i := uint(19); i <= 30; i += 1 { | ||
213 | // // The arguments to offsetTest are offset, source | ||
214 | // // window size, and file size. The source window size | ||
215 | // // is (2 << i) and (in the 3.0x release branch) is | ||
216 | // // limited to 2^31, so the the greatest value of i is | ||
217 | // // 30. | ||
218 | // cfg.srcbuf_size = 2 << i | ||
219 | // r.RunTest(fmt.Sprint("offset", i), func(t *xdelta.TestGroup) { | ||
220 | // cfg.offsetTest(t, prog, 1 << i, 3 << i) }) | ||
221 | // } | ||
222 | |||
207 | comp := xdelta.Program{xcompare} | 223 | comp := xdelta.Program{xcompare} |
208 | 224 | ||
209 | r.RunTest("dataset", func(t *xdelta.TestGroup) { cfg.datasetTest(t, prog, comp) }) | 225 | r.RunTest("dataset", func(t *xdelta.TestGroup) { cfg.datasetTest(t, prog, comp) }) |
210 | |||
211 | for i := uint(19); i <= 30; i += 1 { | ||
212 | // The arguments to offsetTest are offset, source | ||
213 | // window size, and file size. The source window size | ||
214 | // is (2 << i) and (in the 3.0x release branch) is | ||
215 | // limited to 2^31, so the the greatest value of i is | ||
216 | // 30. | ||
217 | cfg.srcbuf_size = 2 << i | ||
218 | r.RunTest(fmt.Sprint("offset", i), func(t *xdelta.TestGroup) { | ||
219 | cfg.offsetTest(t, prog, 1 << i, 3 << i) }) | ||
220 | } | ||
221 | |||
222 | } | 226 | } |