diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-04-28 01:50:56 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-04-28 01:50:56 -0700 |
| commit | eab4c9219c066783c42f397c4cf94f5e11bf0d54 (patch) | |
| tree | ac56f678bc178884a219ebd52547eb6c43558ee3 | |
| parent | fb81f12686cca72d10c663b4e39b22ab43b74a4e (diff) | |
| download | seaweedfs-eab4c9219c066783c42f397c4cf94f5e11bf0d54.tar.xz seaweedfs-eab4c9219c066783c42f397c4cf94f5e11bf0d54.zip | |
randomize benchmark content
fix https://github.com/chrislusf/seaweedfs/issues/1294
| -rw-r--r-- | weed/command/benchmark.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go index 6846dc98d..a73a4e81c 100644 --- a/weed/command/benchmark.go +++ b/weed/command/benchmark.go @@ -227,7 +227,7 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stat) { start := time.Now() fileSize := int64(*b.fileSize + random.Intn(64)) fp := &operation.FilePart{ - Reader: &FakeReader{id: uint64(id), size: fileSize}, + Reader: &FakeReader{id: uint64(id), size: fileSize, random: random}, FileSize: fileSize, MimeType: "image/bench", // prevent gzip benchmark content } @@ -550,8 +550,9 @@ func (s *stats) printStats() { // a fake reader to generate content to upload type FakeReader struct { - id uint64 // an id number - size int64 // max bytes + id uint64 // an id number + size int64 // max bytes + random *rand.Rand } func (l *FakeReader) Read(p []byte) (n int, err error) { @@ -567,6 +568,7 @@ func (l *FakeReader) Read(p []byte) (n int, err error) { for i := 0; i < 8; i++ { p[i] = byte(l.id >> uint(i*8)) } + l.random.Read(p[8:]) } l.size -= int64(n) return |
