From b944734245bb807839aa8da83e6bb5f27a52dde4 Mon Sep 17 00:00:00 2001 From: Shuo Wu Date: Mon, 27 Nov 2023 10:58:00 +0800 Subject: [PATCH] Implement bandwidth write bench for controller and replica Signed-off-by: Shuo Wu --- pkg/util/util.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/util/util.go b/pkg/util/util.go index e8ce1281c..c51fd6059 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -334,6 +334,9 @@ func Bench(benchType string, thread int, size int64, writeAt, readAt func([]byte lock := sync.Mutex{} blockSize := 4096 // 4KB + if benchType == "bandwidth-read" || benchType == "bandwidth-write" { + blockSize = 1 << 20 // 1MB + } blockBytes := []byte(RandStringRunes(blockSize)) ChunkSize := int(math.Ceil(float64(size) / float64(thread))) @@ -373,6 +376,9 @@ func Bench(benchType string, thread int, size int64, writeAt, readAt func([]byte case "iops-write": res := int(float64(size) / float64(blockSize) / float64(duration) * 1000000000) output = fmt.Sprintf("instance iops write %v/s, size %v, duration %vs, thread count %v", res, size, duration.Seconds(), thread) + case "bandwidth-write": + res := int(float64(size) / float64(duration) * 1000000000 / float64(1<<10)) + output = fmt.Sprintf("instance bandwidth write %vKB/s, size %v, duration %vs, thread count %v", res, size, duration.Seconds(), thread) } return output, nil }