In this section, we will explore how the size of the write buffer affects the performance of the entire writing operation using the Go code of writingBU.go, which will be presented in five parts.
The writingBU.go program generates dummy files with randomly generated data. The variables of the program are the size of the buffer and the size of the output file.
The first part of writingBU.go is as follows:
package main import ( "fmt" "math/rand" "os" "strconv" ) var BUFFERSIZE int var FILESIZE int func random(min, max int) int { return rand.Intn(max-min) + min }
The second code portion of writingBU.go contains the following Go code:
func createBuffer(buf *[]byte, count int) { *buf = make([]byte, count) if count ...