Browse Source

Merge pull request #22 from fingon/add-bytes-to-benchmarks

Added SetBytes to the Benchmarks to see bytes/second.
Pierre Curto 8 years ago
parent
commit
ed8d4cc3b4
1 changed files with 6 additions and 0 deletions
  1. 6 0
      lz4_test.go

+ 6 - 0
lz4_test.go

@@ -284,6 +284,7 @@ func TestBlockCompression(t *testing.T) {
 func BenchmarkUncompressBlock(b *testing.B) {
 func BenchmarkUncompressBlock(b *testing.B) {
 	d := make([]byte, len(lorem))
 	d := make([]byte, len(lorem))
 	z := make([]byte, len(lorem))
 	z := make([]byte, len(lorem))
+	b.SetBytes(int64(len(lorem)))
 	n, err := lz4.CompressBlock(lorem, z, 0)
 	n, err := lz4.CompressBlock(lorem, z, 0)
 	if err != nil {
 	if err != nil {
 		b.Errorf("CompressBlock: %s", err)
 		b.Errorf("CompressBlock: %s", err)
@@ -299,6 +300,7 @@ func BenchmarkUncompressConstantBlock(b *testing.B) {
 	d := make([]byte, 4096)
 	d := make([]byte, 4096)
 	z := make([]byte, 4096)
 	z := make([]byte, 4096)
 	source := make([]byte, 4096)
 	source := make([]byte, 4096)
+	b.SetBytes(int64(len(source)))
 	n, err := lz4.CompressBlock(source, z, 0)
 	n, err := lz4.CompressBlock(source, z, 0)
 	if err != nil {
 	if err != nil {
 		b.Errorf("CompressBlock: %s", err)
 		b.Errorf("CompressBlock: %s", err)
@@ -313,6 +315,7 @@ func BenchmarkUncompressConstantBlock(b *testing.B) {
 func BenchmarkCompressBlock(b *testing.B) {
 func BenchmarkCompressBlock(b *testing.B) {
 	d := append([]byte{}, lorem...)
 	d := append([]byte{}, lorem...)
 	z := make([]byte, len(lorem))
 	z := make([]byte, len(lorem))
+	b.SetBytes(int64(len(d)))
 	n, err := lz4.CompressBlock(d, z, 0)
 	n, err := lz4.CompressBlock(d, z, 0)
 	if err != nil {
 	if err != nil {
 		b.Errorf("CompressBlock: %s", err)
 		b.Errorf("CompressBlock: %s", err)
@@ -328,6 +331,7 @@ func BenchmarkCompressBlock(b *testing.B) {
 func BenchmarkCompressConstantBlock(b *testing.B) {
 func BenchmarkCompressConstantBlock(b *testing.B) {
 	d := make([]byte, 4096)
 	d := make([]byte, 4096)
 	z := make([]byte, 4096)
 	z := make([]byte, 4096)
+	b.SetBytes(int64(len(d)))
 	n, err := lz4.CompressBlock(d, z, 0)
 	n, err := lz4.CompressBlock(d, z, 0)
 	if err != nil {
 	if err != nil {
 		b.Errorf("CompressBlock: %s", err)
 		b.Errorf("CompressBlock: %s", err)
@@ -342,6 +346,7 @@ func BenchmarkCompressConstantBlock(b *testing.B) {
 func BenchmarkCompressBlockHC(b *testing.B) {
 func BenchmarkCompressBlockHC(b *testing.B) {
 	d := append([]byte{}, lorem...)
 	d := append([]byte{}, lorem...)
 	z := make([]byte, len(lorem))
 	z := make([]byte, len(lorem))
+	b.SetBytes(int64(len(d)))
 	n, err := lz4.CompressBlockHC(d, z, 0)
 	n, err := lz4.CompressBlockHC(d, z, 0)
 	if err != nil {
 	if err != nil {
 		b.Errorf("CompressBlock: %s", err)
 		b.Errorf("CompressBlock: %s", err)
@@ -355,6 +360,7 @@ func BenchmarkCompressBlockHC(b *testing.B) {
 }
 }
 func BenchmarkCompressEndToEnd(b *testing.B) {
 func BenchmarkCompressEndToEnd(b *testing.B) {
 	w := lz4.NewWriter(ioutil.Discard)
 	w := lz4.NewWriter(ioutil.Discard)
+	b.SetBytes(int64(len(lorem)))
 	b.ResetTimer()
 	b.ResetTimer()
 	for i := 0; i < b.N; i++ {
 	for i := 0; i < b.N; i++ {
 		if _, err := w.Write(lorem); err != nil {
 		if _, err := w.Write(lorem); err != nil {