4
4
"bytes"
5
5
"compress/gzip"
6
6
"encoding/binary"
7
- "io/ioutil "
7
+ "io"
8
8
"math"
9
9
"os"
10
10
"path/filepath"
@@ -72,7 +72,7 @@ func BenchmarkEncode(b *testing.B) {
72
72
for name , bb := range benchs {
73
73
bb := bb
74
74
b .Run (name , func (b * testing.B ) {
75
- enc := NewEncoder (ioutil .Discard )
75
+ enc := NewEncoder (io .Discard )
76
76
b .ResetTimer ()
77
77
for i := 0 ; i < b .N ; i ++ {
78
78
if err := enc .Encode (bb .value ); err != nil {
@@ -86,7 +86,7 @@ func BenchmarkEncode(b *testing.B) {
86
86
b .Run ("Parallel/" + name , func (b * testing.B ) {
87
87
b .RunParallel (func (pb * testing.PB ) {
88
88
for pb .Next () {
89
- enc := NewEncoder (ioutil .Discard )
89
+ enc := NewEncoder (io .Discard )
90
90
if err := enc .Encode (bb .value ); err != nil {
91
91
b .Fatal (err )
92
92
}
@@ -100,7 +100,7 @@ func BenchmarkPackBool(b *testing.B) {
100
100
b .ReportAllocs ()
101
101
102
102
b .Run ("False" , func (b * testing.B ) {
103
- enc := NewEncoder (ioutil .Discard )
103
+ enc := NewEncoder (io .Discard )
104
104
b .ResetTimer ()
105
105
for i := 0 ; i < b .N ; i ++ {
106
106
v := false
@@ -111,7 +111,7 @@ func BenchmarkPackBool(b *testing.B) {
111
111
})
112
112
113
113
b .Run ("True" , func (b * testing.B ) {
114
- enc := NewEncoder (ioutil .Discard )
114
+ enc := NewEncoder (io .Discard )
115
115
b .ResetTimer ()
116
116
for i := 0 ; i < b .N ; i ++ {
117
117
v := true
@@ -125,7 +125,7 @@ func BenchmarkPackBool(b *testing.B) {
125
125
func BenchmarkPackUint8 (b * testing.B ) {
126
126
b .ReportAllocs ()
127
127
128
- enc := NewEncoder (ioutil .Discard )
128
+ enc := NewEncoder (io .Discard )
129
129
b .ResetTimer ()
130
130
for i := 0 ; i < b .N ; i ++ {
131
131
v := uint64 (math .MaxUint8 )
@@ -138,7 +138,7 @@ func BenchmarkPackUint8(b *testing.B) {
138
138
func BenchmarkPackUint16 (b * testing.B ) {
139
139
b .ReportAllocs ()
140
140
141
- enc := NewEncoder (ioutil .Discard )
141
+ enc := NewEncoder (io .Discard )
142
142
b .ResetTimer ()
143
143
for i := 0 ; i < b .N ; i ++ {
144
144
v := uint64 (math .MaxUint16 )
@@ -151,7 +151,7 @@ func BenchmarkPackUint16(b *testing.B) {
151
151
func BenchmarkPackUint32 (b * testing.B ) {
152
152
b .ReportAllocs ()
153
153
154
- enc := NewEncoder (ioutil .Discard )
154
+ enc := NewEncoder (io .Discard )
155
155
b .ResetTimer ()
156
156
for i := 0 ; i < b .N ; i ++ {
157
157
v := uint64 (math .MaxUint32 )
@@ -164,7 +164,7 @@ func BenchmarkPackUint32(b *testing.B) {
164
164
func BenchmarkPackUint64 (b * testing.B ) {
165
165
b .ReportAllocs ()
166
166
167
- enc := NewEncoder (ioutil .Discard )
167
+ enc := NewEncoder (io .Discard )
168
168
b .ResetTimer ()
169
169
for i := 0 ; i < b .N ; i ++ {
170
170
v := uint64 (math .MaxUint64 )
@@ -177,7 +177,7 @@ func BenchmarkPackUint64(b *testing.B) {
177
177
func BenchmarkPackInt8 (b * testing.B ) {
178
178
b .ReportAllocs ()
179
179
180
- enc := NewEncoder (ioutil .Discard )
180
+ enc := NewEncoder (io .Discard )
181
181
b .ResetTimer ()
182
182
for i := 0 ; i < b .N ; i ++ {
183
183
v := int64 (math .MaxInt8 )
@@ -190,7 +190,7 @@ func BenchmarkPackInt8(b *testing.B) {
190
190
func BenchmarkPackInt16 (b * testing.B ) {
191
191
b .ReportAllocs ()
192
192
193
- enc := NewEncoder (ioutil .Discard )
193
+ enc := NewEncoder (io .Discard )
194
194
b .ResetTimer ()
195
195
for i := 0 ; i < b .N ; i ++ {
196
196
v := int64 (math .MaxInt16 )
@@ -203,7 +203,7 @@ func BenchmarkPackInt16(b *testing.B) {
203
203
func BenchmarkPackInt32 (b * testing.B ) {
204
204
b .ReportAllocs ()
205
205
206
- enc := NewEncoder (ioutil .Discard )
206
+ enc := NewEncoder (io .Discard )
207
207
b .ResetTimer ()
208
208
for i := 0 ; i < b .N ; i ++ {
209
209
v := int64 (math .MaxInt32 )
@@ -216,7 +216,7 @@ func BenchmarkPackInt32(b *testing.B) {
216
216
func BenchmarkPackInt64 (b * testing.B ) {
217
217
b .ReportAllocs ()
218
218
219
- enc := NewEncoder (ioutil .Discard )
219
+ enc := NewEncoder (io .Discard )
220
220
b .ResetTimer ()
221
221
for i := 0 ; i < b .N ; i ++ {
222
222
v := int64 (math .MaxInt64 )
@@ -229,7 +229,7 @@ func BenchmarkPackInt64(b *testing.B) {
229
229
func BenchmarkPackFloat32 (b * testing.B ) {
230
230
b .ReportAllocs ()
231
231
232
- enc := NewEncoder (ioutil .Discard )
232
+ enc := NewEncoder (io .Discard )
233
233
b .ResetTimer ()
234
234
for i := 0 ; i < b .N ; i ++ {
235
235
v := float64 (math .MaxFloat32 )
@@ -242,7 +242,7 @@ func BenchmarkPackFloat32(b *testing.B) {
242
242
func BenchmarkPackFloat64 (b * testing.B ) {
243
243
b .ReportAllocs ()
244
244
245
- enc := NewEncoder (ioutil .Discard )
245
+ enc := NewEncoder (io .Discard )
246
246
b .ResetTimer ()
247
247
for i := 0 ; i < b .N ; i ++ {
248
248
v := float64 (math .MaxFloat64 )
@@ -256,7 +256,7 @@ func BenchmarkPackString(b *testing.B) {
256
256
b .ReportAllocs ()
257
257
258
258
b .Run ("MaxUint8" , func (b * testing.B ) {
259
- enc := NewEncoder (ioutil .Discard )
259
+ enc := NewEncoder (io .Discard )
260
260
s := makeString (math .MaxUint8 )
261
261
b .ResetTimer ()
262
262
for i := 0 ; i < b .N ; i ++ {
@@ -267,7 +267,7 @@ func BenchmarkPackString(b *testing.B) {
267
267
})
268
268
269
269
b .Run ("MaxUint8+1" , func (b * testing.B ) {
270
- enc := NewEncoder (ioutil .Discard )
270
+ enc := NewEncoder (io .Discard )
271
271
s := makeString (math .MaxUint8 + 1 )
272
272
b .ResetTimer ()
273
273
for i := 0 ; i < b .N ; i ++ {
@@ -278,7 +278,7 @@ func BenchmarkPackString(b *testing.B) {
278
278
})
279
279
280
280
b .Run ("MaxUint16" , func (b * testing.B ) {
281
- enc := NewEncoder (ioutil .Discard )
281
+ enc := NewEncoder (io .Discard )
282
282
s := makeString (math .MaxUint16 )
283
283
b .ResetTimer ()
284
284
for i := 0 ; i < b .N ; i ++ {
@@ -293,7 +293,7 @@ func BenchmarkPackStringBytes(b *testing.B) {
293
293
b .ReportAllocs ()
294
294
295
295
b .Run ("MaxUint8" , func (b * testing.B ) {
296
- enc := NewEncoder (ioutil .Discard )
296
+ enc := NewEncoder (io .Discard )
297
297
p := []byte (makeString (math .MaxUint8 ))
298
298
b .ResetTimer ()
299
299
for i := 0 ; i < b .N ; i ++ {
@@ -304,7 +304,7 @@ func BenchmarkPackStringBytes(b *testing.B) {
304
304
})
305
305
306
306
b .Run ("MaxUint8+1" , func (b * testing.B ) {
307
- enc := NewEncoder (ioutil .Discard )
307
+ enc := NewEncoder (io .Discard )
308
308
p := []byte (makeString (math .MaxUint8 + 1 ))
309
309
b .ResetTimer ()
310
310
for i := 0 ; i < b .N ; i ++ {
@@ -315,7 +315,7 @@ func BenchmarkPackStringBytes(b *testing.B) {
315
315
})
316
316
317
317
b .Run ("MaxUint16" , func (b * testing.B ) {
318
- enc := NewEncoder (ioutil .Discard )
318
+ enc := NewEncoder (io .Discard )
319
319
p := []byte (makeString (math .MaxUint16 ))
320
320
b .ResetTimer ()
321
321
for i := 0 ; i < b .N ; i ++ {
@@ -330,7 +330,7 @@ func BenchmarkPackBinary(b *testing.B) {
330
330
b .ReportAllocs ()
331
331
332
332
b .Run ("MaxUint8" , func (b * testing.B ) {
333
- enc := NewEncoder (ioutil .Discard )
333
+ enc := NewEncoder (io .Discard )
334
334
p := []byte (makeString (math .MaxUint8 ))
335
335
b .ResetTimer ()
336
336
for i := 0 ; i < b .N ; i ++ {
@@ -341,7 +341,7 @@ func BenchmarkPackBinary(b *testing.B) {
341
341
})
342
342
343
343
b .Run ("MaxUint8+1" , func (b * testing.B ) {
344
- enc := NewEncoder (ioutil .Discard )
344
+ enc := NewEncoder (io .Discard )
345
345
p := []byte (makeString (math .MaxUint8 + 1 ))
346
346
b .ResetTimer ()
347
347
for i := 0 ; i < b .N ; i ++ {
@@ -352,7 +352,7 @@ func BenchmarkPackBinary(b *testing.B) {
352
352
})
353
353
354
354
b .Run ("MaxUint16" , func (b * testing.B ) {
355
- enc := NewEncoder (ioutil .Discard )
355
+ enc := NewEncoder (io .Discard )
356
356
p := []byte (makeString (math .MaxUint16 ))
357
357
b .ResetTimer ()
358
358
for i := 0 ; i < b .N ; i ++ {
@@ -367,7 +367,7 @@ func BenchmarkPackArrayLen(b *testing.B) {
367
367
b .ReportAllocs ()
368
368
369
369
b .Run ("MaxUint8" , func (b * testing.B ) {
370
- enc := NewEncoder (ioutil .Discard )
370
+ enc := NewEncoder (io .Discard )
371
371
v := int64 (math .MaxUint8 )
372
372
b .ResetTimer ()
373
373
for i := 0 ; i < b .N ; i ++ {
@@ -378,7 +378,7 @@ func BenchmarkPackArrayLen(b *testing.B) {
378
378
})
379
379
380
380
b .Run ("MaxUint16" , func (b * testing.B ) {
381
- enc := NewEncoder (ioutil .Discard )
381
+ enc := NewEncoder (io .Discard )
382
382
v := int64 (math .MaxUint16 )
383
383
b .ResetTimer ()
384
384
for i := 0 ; i < b .N ; i ++ {
@@ -389,7 +389,7 @@ func BenchmarkPackArrayLen(b *testing.B) {
389
389
})
390
390
391
391
b .Run ("MaxUint32" , func (b * testing.B ) {
392
- enc := NewEncoder (ioutil .Discard )
392
+ enc := NewEncoder (io .Discard )
393
393
v := int64 (math .MaxUint32 )
394
394
b .ResetTimer ()
395
395
for i := 0 ; i < b .N ; i ++ {
@@ -404,7 +404,7 @@ func BenchmarkPackMapLen(b *testing.B) {
404
404
b .ReportAllocs ()
405
405
406
406
b .Run ("MaxUint8" , func (b * testing.B ) {
407
- enc := NewEncoder (ioutil .Discard )
407
+ enc := NewEncoder (io .Discard )
408
408
v := int64 (math .MaxUint8 )
409
409
b .ResetTimer ()
410
410
for i := 0 ; i < b .N ; i ++ {
@@ -415,7 +415,7 @@ func BenchmarkPackMapLen(b *testing.B) {
415
415
})
416
416
417
417
b .Run ("MaxUint16" , func (b * testing.B ) {
418
- enc := NewEncoder (ioutil .Discard )
418
+ enc := NewEncoder (io .Discard )
419
419
v := int64 (math .MaxUint16 )
420
420
b .ResetTimer ()
421
421
for i := 0 ; i < b .N ; i ++ {
@@ -426,7 +426,7 @@ func BenchmarkPackMapLen(b *testing.B) {
426
426
})
427
427
428
428
b .Run ("MaxUint32" , func (b * testing.B ) {
429
- enc := NewEncoder (ioutil .Discard )
429
+ enc := NewEncoder (io .Discard )
430
430
v := int64 (math .MaxUint32 )
431
431
b .ResetTimer ()
432
432
for i := 0 ; i < b .N ; i ++ {
@@ -1468,7 +1468,7 @@ func extractMpack(tb testing.TB, path string) []byte {
1468
1468
tb .Fatal (err )
1469
1469
}
1470
1470
1471
- data , err := ioutil .ReadAll (gz )
1471
+ data , err := io .ReadAll (gz )
1472
1472
if err != nil {
1473
1473
tb .Fatal (err )
1474
1474
}
@@ -1490,7 +1490,7 @@ func BenchmarkEncodeMpack(b *testing.B) {
1490
1490
b .ResetTimer ()
1491
1491
1492
1492
b .RunParallel (func (pb * testing.PB ) {
1493
- enc := NewEncoder (ioutil .Discard )
1493
+ enc := NewEncoder (io .Discard )
1494
1494
for pb .Next () {
1495
1495
if err := enc .Encode (& structAPI ); err != nil {
1496
1496
b .Fatalf ("Decode: %v" , err )
@@ -1512,7 +1512,7 @@ func BenchmarkEncodeMpack(b *testing.B) {
1512
1512
b .ResetTimer ()
1513
1513
1514
1514
b .RunParallel (func (pb * testing.PB ) {
1515
- enc := NewEncoder (ioutil .Discard )
1515
+ enc := NewEncoder (io .Discard )
1516
1516
for pb .Next () {
1517
1517
if err := enc .Encode (& structAPIMetadata ); err != nil {
1518
1518
b .Fatalf ("Decode: %v" , err )
@@ -1534,7 +1534,7 @@ func BenchmarkEncodeMpack(b *testing.B) {
1534
1534
b .ResetTimer ()
1535
1535
1536
1536
b .RunParallel (func (pb * testing.PB ) {
1537
- enc := NewEncoder (ioutil .Discard )
1537
+ enc := NewEncoder (io .Discard )
1538
1538
for pb .Next () {
1539
1539
if err := enc .Encode (& structAPIMetadata ); err != nil {
1540
1540
b .Fatalf ("Decode: %v" , err )
@@ -1556,7 +1556,7 @@ func BenchmarkEncodeMpack(b *testing.B) {
1556
1556
b .ResetTimer ()
1557
1557
1558
1558
b .RunParallel (func (pb * testing.PB ) {
1559
- enc := NewEncoder (ioutil .Discard )
1559
+ enc := NewEncoder (io .Discard )
1560
1560
for pb .Next () {
1561
1561
if err := enc .Encode (& structFuncsData ); err != nil {
1562
1562
b .Fatalf ("Decode: %v" , err )
0 commit comments