|
|
@@ -17,7 +17,7 @@ func BenchmarkCompress(b *testing.B) {
|
|
|
b.ResetTimer()
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
- lz4.CompressBlock(pg1661, buf, hashTable[:])
|
|
|
+ _, _ = lz4.CompressBlock(pg1661, buf, hashTable[:])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -30,7 +30,7 @@ func BenchmarkCompressRandom(b *testing.B) {
|
|
|
b.ResetTimer()
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
- lz4.CompressBlock(random, buf, hashTable[:])
|
|
|
+ _, _ = lz4.CompressBlock(random, buf, hashTable[:])
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -41,7 +41,7 @@ func BenchmarkCompressHC(b *testing.B) {
|
|
|
b.ResetTimer()
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
- lz4.CompressBlockHC(pg1661, buf, 16)
|
|
|
+ _, _ = lz4.CompressBlockHC(pg1661, buf, 16)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -52,7 +52,7 @@ func BenchmarkUncompress(b *testing.B) {
|
|
|
b.ResetTimer()
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
- lz4.UncompressBlock(pg1661LZ4, buf)
|
|
|
+ _, _ = lz4.UncompressBlock(pg1661LZ4, buf)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -92,7 +92,7 @@ func benchmarkUncompress(b *testing.B, compressed []byte) {
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
r.Reset(compressed)
|
|
|
zr.Reset(r)
|
|
|
- io.Copy(ioutil.Discard, zr)
|
|
|
+ _, _ = io.Copy(ioutil.Discard, zr)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -122,7 +122,7 @@ func benchmarkCompress(b *testing.B, uncompressed []byte) {
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
r.Reset(uncompressed)
|
|
|
zw.Reset(w)
|
|
|
- io.Copy(zw, r)
|
|
|
+ _, _ = io.Copy(zw, r)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -130,3 +130,21 @@ func BenchmarkCompressPg1661(b *testing.B) { benchmarkCompress(b, pg1661) }
|
|
|
func BenchmarkCompressDigits(b *testing.B) { benchmarkCompress(b, digits) }
|
|
|
func BenchmarkCompressTwain(b *testing.B) { benchmarkCompress(b, twain) }
|
|
|
func BenchmarkCompressRand(b *testing.B) { benchmarkCompress(b, random) }
|
|
|
+
|
|
|
+// Benchmark to check reallocations upon Reset().
|
|
|
+// See issue https://github.com/pierrec/lz4/issues/52.
|
|
|
+func BenchmarkWriterReset(b *testing.B) {
|
|
|
+ b.ReportAllocs()
|
|
|
+
|
|
|
+ zw := lz4.NewWriter(nil)
|
|
|
+ src := mustLoadFile("testdata/gettysburg.txt")
|
|
|
+ var buf bytes.Buffer
|
|
|
+
|
|
|
+ for n := 0; n < b.N; n++ {
|
|
|
+ buf.Reset()
|
|
|
+ zw.Reset(&buf)
|
|
|
+
|
|
|
+ _, _ = zw.Write(src)
|
|
|
+ _ = zw.Close()
|
|
|
+ }
|
|
|
+}
|