Skip to content

Commit

Permalink
Implement bandwidth write bench for controller and replica
Browse files Browse the repository at this point in the history
Signed-off-by: Shuo Wu <shuo.wu@suse.com>
  • Loading branch information
shuo-wu committed Dec 4, 2023
1 parent 95e4930 commit b944734
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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
}

0 comments on commit b944734

Please sign in to comment.