summaryrefslogtreecommitdiff
path: root/xdelta3
diff options
context:
space:
mode:
authorJoshua MacDonald <josh.macdonald@gmail.com>2015-12-26 21:44:56 -0800
committerJoshua MacDonald <josh.macdonald@gmail.com>2015-12-26 21:44:56 -0800
commit318dabfa4bd68711900f59cbc9d75c7b1d15d958 (patch)
tree25cfe393cb3b180bde4669dae0c1e1b3a22078f3 /xdelta3
parentd6e344ee71da1727e52d8b9f127ccd0946b04a18 (diff)
Sum and print summary by source window size
Diffstat (limited to 'xdelta3')
-rw-r--r--xdelta3/go/src/regtest.go59
1 files changed, 52 insertions, 7 deletions
diff --git a/xdelta3/go/src/regtest.go b/xdelta3/go/src/regtest.go
index 7b23ce0..f5c5480 100644
--- a/xdelta3/go/src/regtest.go
+++ b/xdelta3/go/src/regtest.go
@@ -66,9 +66,28 @@ type PairTest struct {
66 source, target string 66 source, target string
67 67
68 // Output 68 // Output
69 TestOutput
70}
71
72type TestOutput struct {
69 encoded int64 73 encoded int64
70 encDuration time.Duration 74 encDuration time.Duration
71 decDuration time.Duration 75 decDuration time.Duration
76 encSysDuration time.Duration
77 decSysDuration time.Duration
78}
79
80func (to *TestOutput) Add(a TestOutput) {
81 to.encoded += a.encoded
82 to.encDuration += a.encDuration
83 to.decDuration += a.decDuration
84 to.encSysDuration += a.encSysDuration
85 to.decSysDuration += a.decSysDuration
86}
87
88func (to *TestOutput) String() string {
89 return fmt.Sprintf("SIZE: %v\tTIME: %v",
90 to.encoded, to.encDuration)
72} 91}
73 92
74// P is the test program, Q is the reference version. 93// P is the test program, Q is the reference version.
@@ -91,6 +110,8 @@ func (cfg Config) datasetTest(t *xdelta.TestGroup, p, q xdelta.Program) {
91 total += d.Size() 110 total += d.Size()
92 } 111 }
93 meansize := total / int64(len(dents)) 112 meansize := total / int64(len(dents))
113 testSum := map[uint]*TestOutput{}
114 compSum := map[uint]*TestOutput{}
94 for _, in1 := range paths { 115 for _, in1 := range paths {
95 for _, in2 := range paths { 116 for _, in2 := range paths {
96 if in1 == in2 { continue } 117 if in1 == in2 { continue }
@@ -99,26 +120,46 @@ func (cfg Config) datasetTest(t *xdelta.TestGroup, p, q xdelta.Program) {
99 for ; largest <= 31 && 1<<largest < meansize; largest++ {} 120 for ; largest <= 31 && 1<<largest < meansize; largest++ {}
100 121
101 // 1/4, 1/2, and 1/1 of the power-of-2 rounded-up mean size 122 // 1/4, 1/2, and 1/1 of the power-of-2 rounded-up mean size
123 // TODO NOTE
102 for b := largest - 2; b <= largest; b++ { 124 for b := largest - 2; b <= largest; b++ {
125 if _, has := testSum[b]; !has {
126 testSum[b] = &TestOutput{}
127 compSum[b] = &TestOutput{}
128 }
103 c1 := cfg 129 c1 := cfg
104 c1.srcbuf_size = 1<<b 130 c1.srcbuf_size = 1<<b
105 ptest := &PairTest{c1, p, in1, in2, -1, 0, 0} 131 ptest := &PairTest{c1, p, in1, in2, TestOutput{-1, 0, 0, 0, 0}}
106 ptest.datasetPairTest(t, 1<<b); 132 ptest.datasetPairTest(t, 1<<b);
107 qtest := &PairTest{c1, q, in1, in2, -1, 0, 0} 133 qtest := &PairTest{c1, q, in1, in2, TestOutput{-1, 0, 0, 0, 0}}
108 qtest.datasetPairTest(t, 1<<b) 134 qtest.datasetPairTest(t, 1<<b)
109 135
110 fmt.Printf("%s, %s: %+d/%db, E:%s/%s D:%s/%s [B=%d]\n", 136 testSum[b].Add(ptest.TestOutput)
137 compSum[b].Add(qtest.TestOutput)
138
139 fmt.Printf("%s, %s: %.2f%% %+d/%d\n\tE:%.2f%%/%s(%.2f%%/%s) D:%.2f%%/%s(%.2f%%/%s) [B=%d]\n",
111 path.Base(in1), path.Base(in2), 140 path.Base(in1), path.Base(in2),
141 float64(ptest.encoded - qtest.encoded) * 100.0 / float64(qtest.encoded),
112 ptest.encoded - qtest.encoded, 142 ptest.encoded - qtest.encoded,
113 qtest.encoded, 143 qtest.encoded,
114 (ptest.encDuration - qtest.encDuration).String(), 144 (ptest.encDuration - qtest.encDuration).Seconds() * 100.0 / qtest.encDuration.Seconds(),
145 qtest.encDuration,
146 (ptest.decDuration - qtest.decDuration).Seconds() * 100.0 / qtest.decDuration.Seconds(),
115 qtest.encDuration, 147 qtest.encDuration,
116 (ptest.decDuration - qtest.decDuration).String(), 148 (ptest.encSysDuration - qtest.encSysDuration).Seconds() * 100.0 / qtest.encSysDuration.Seconds(),
117 qtest.decDuration, 149 qtest.encSysDuration,
150 (ptest.decSysDuration - qtest.decSysDuration).Seconds() * 100.0 / qtest.decSysDuration.Seconds(),
151 qtest.decSysDuration,
118 1<<b) 152 1<<b)
119 } 153 }
120 } 154 }
121 } 155 }
156 var keys []uint
157 for k, _ := range testSum {
158 keys = append(keys, k)
159 }
160 for _, k := range keys {
161 fmt.Printf("B=%v\nTEST: %v\nCOMP: %v\n", 1<<k, testSum[k], compSum[k])
162 }
122} 163}
123 164
124func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) { 165func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) {
@@ -131,7 +172,9 @@ func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) {
131 t.Panic(err) 172 t.Panic(err)
132 } 173 }
133 174
134 dargs := []string{"-dc", fmt.Sprint("-B", cfg.srcbuf_size), //"-q", 175 // TODO HACK "* 2" for known / fixed bug in decoder. Helps compare
176 // encoder perf in reasonable time, makes invalid decoder results.
177 dargs := []string{"-dc", fmt.Sprint("-B", cfg.srcbuf_size * 2), //"-q",
135 fmt.Sprint("-W", cfg.window_size), "-s", pt.source} 178 fmt.Sprint("-W", cfg.window_size), "-s", pt.source}
136 dec, err := t.Exec("decode", pt.program, false, dargs) 179 dec, err := t.Exec("decode", pt.program, false, dargs)
137 if err != nil { 180 if err != nil {
@@ -154,6 +197,8 @@ func (pt *PairTest) datasetPairTest(t *xdelta.TestGroup, meanSize int64) {
154 197
155 pt.decDuration = dec.Cmd.ProcessState.UserTime() 198 pt.decDuration = dec.Cmd.ProcessState.UserTime()
156 pt.encDuration = enc.Cmd.ProcessState.UserTime() 199 pt.encDuration = enc.Cmd.ProcessState.UserTime()
200 pt.decSysDuration = dec.Cmd.ProcessState.SystemTime()
201 pt.encSysDuration = enc.Cmd.ProcessState.SystemTime()
157} 202}
158 203
159func (cfg Config) offsetTest(t *xdelta.TestGroup, p xdelta.Program, offset, length int64) { 204func (cfg Config) offsetTest(t *xdelta.TestGroup, p xdelta.Program, offset, length int64) {