From 6b397844b96573808c9c91de67411bba66b78f1a Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 28 Feb 2015 16:54:03 -0800 Subject: [PATCH] Add donut benchmark for 64MB, 128MB, 256MB, 512MB Current average values ~~~ > minio/pkg/storage/donut/v1 *> go test -bench . OK: 2 passed PASS BenchmarkDonut64M 5 266249634 ns/op 252.05 MB/s BenchmarkDonut128M 3 436507394 ns/op 307.48 MB/s BenchmarkDonut256M 2 836116359 ns/op 321.05 MB/s BenchmarkDonut512M 1 1676738951 ns/op 320.19 MB/s ok github.com/minio-io/minio/pkg/storage/donut/v1 8.430s > minio/pkg/storage/donut/v1 *> ~~~ --- pkg/storage/donut/v1/donut_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkg/storage/donut/v1/donut_test.go b/pkg/storage/donut/v1/donut_test.go index dd4c40c1e..09c2f5f98 100644 --- a/pkg/storage/donut/v1/donut_test.go +++ b/pkg/storage/donut/v1/donut_test.go @@ -130,3 +130,29 @@ func (s *MySuite) TestLengthMismatchInWrite(c *C) { err := Write(&testData, bytes.NewBufferString("hello, world"), 5) c.Assert(err, Not(IsNil)) } + +var buf = make([]byte, 1024*1024*1024) + +func benchmarkSize(b *testing.B, size int) { + b.SetBytes(int64(size)) + target := new(bytes.Buffer) + for i := 0; i < b.N; i++ { + Write(target, bytes.NewReader(buf[:size]), uint64(size)) + } +} + +func BenchmarkDonut64M(b *testing.B) { + benchmarkSize(b, 1024*1024*64) +} + +func BenchmarkDonut128M(b *testing.B) { + benchmarkSize(b, 1024*1024*128) +} + +func BenchmarkDonut256M(b *testing.B) { + benchmarkSize(b, 1024*1024*256) +} + +func BenchmarkDonut512M(b *testing.B) { + benchmarkSize(b, 1024*1024*512) +}